From e5246c1628b789a1b95403cfc5e030f574ccd704 Mon Sep 17 00:00:00 2001 From: Germey Tsui Date: Mon, 8 Jan 2024 23:45:40 +0800 Subject: [PATCH 1/2] update --- hub.config.js | 20 ------------ index.html | 3 +- package.json | 1 - {public => src/assets/images}/favicon.ico | Bin src/config.ts | 32 ++++++++++++++++++- src/main.ts | 4 ++- src/utils/initializer.ts | 36 ++++++++++++++++++++++ 7 files changed, 71 insertions(+), 25 deletions(-) delete mode 100644 hub.config.js rename {public => src/assets/images}/favicon.ico (100%) diff --git a/hub.config.js b/hub.config.js deleted file mode 100644 index dcb30b2..0000000 --- a/hub.config.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = { - site: { - logo: { - url: 'https://hub.zhishuyun.com/assets/logo.da8de841.svg', - width: 'auto', - height: 'auto' - } - }, - apps: { - chat: { - enabled: true - }, - midjourney: { - enabled: true - } - }, - distribution: { - inviterId: '123' - } -}; diff --git a/index.html b/index.html index 13cd284..4c1f044 100644 --- a/index.html +++ b/index.html @@ -2,9 +2,8 @@ - - 知数云 - 数字化服务的智慧之选 +
diff --git a/package.json b/package.json index 73370c8..fad5311 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,6 @@ "sass": "^1.38.1", "tailwindcss": "^3.4.0", "typescript": "^4.9.5", - "unplugin-element-plus": "^0.8.0", "vite": "^2.9.16", "vite-bundle-visualizer": "^1.0.0", "vue-tsc": "^1.2.0" diff --git a/public/favicon.ico b/src/assets/images/favicon.ico similarity index 100% rename from public/favicon.ico rename to src/assets/images/favicon.ico diff --git a/src/config.ts b/src/config.ts index 57a2917..c152edf 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,7 +2,32 @@ export default { /** * The global configuration. */ - global: {}, + global: { + /** + * Title of the app. + * You can change it by your own. + */ + title: '知数云 - 数字化服务的智慧之选', + + /** + * Logo url of the app. + * If provided which starts with http/https prefix, will be used. + * If not provided, will by default use @/assets/images/logo.svg as instead, you can replace it. + */ + logoUrl: undefined, + + /** + * Favicon url of the app. + * If provided which starts with http/https prefix, will be used. + * If not provided, will by default use @/assets/images/favicon.ico as instead, you can replace it. + */ + faviconUrl: undefined, + + /** + * The default language of the app, enum as 'zh-cn', 'en'. + */ + language: 'zh-cn' + }, /** * The left navigation configuration. @@ -64,6 +89,11 @@ export default { * The auth configuration. */ auth: { + /** + * The default auth provider, enum as 'wechat', 'email', 'phone'. + */ + defaultProvider: 'wechat', + /** * The auth provider configuration. */ diff --git a/src/main.ts b/src/main.ts index d965313..fad63e9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,10 +12,12 @@ import { vLoading } from 'element-plus'; import hl from 'highlight.js'; import 'highlight.js/styles/night-owl.css'; import copyToClipboard from 'copy-to-clipboard'; -import { initializeCookies } from './utils/initializer'; +import { initializeCookies, initializeFavicon, initializeTitle } from './utils/initializer'; import config from './plugins/config'; initializeCookies(); +initializeTitle(); +initializeFavicon(); const app = createApp(App); diff --git a/src/utils/initializer.ts b/src/utils/initializer.ts index 97e4149..0072557 100644 --- a/src/utils/initializer.ts +++ b/src/utils/initializer.ts @@ -1,5 +1,10 @@ import { setCookie } from 'typescript-cookie'; +import config from '@/config'; +import favicon from '@/assets/images/favicon.ico'; +/** + * Initialize cookies. + */ export const initializeCookies = () => { // parse the query string and set to cookies const query = new URLSearchParams(window.location.search); @@ -15,3 +20,34 @@ export const initializeCookies = () => { }); } }; + +/** + * Initialize title. + */ +export const initializeTitle = () => { + // set the title from config.global.title + const title = config.global.title; + // find the title element or insert a new one + let titleElement = document.querySelector('title'); + if (!titleElement) { + titleElement = document.createElement('title'); + document.head.appendChild(titleElement); + } + titleElement.innerHTML = title; +}; + +/** + * Initialize favicon. + */ +export const initializeFavicon = () => { + // by default use favicon which imported + // if faviconUrl is set in config, use it instead + const favIconUrl = config.global.faviconUrl; + let faviconElement = document.querySelector('link[rel="icon"]') as HTMLLinkElement; + if (!faviconElement) { + faviconElement = document.createElement('link'); + faviconElement.rel = 'icon'; + document.head.appendChild(faviconElement); + } + faviconElement.href = favIconUrl || favicon; +}; From 09169a79406512b345f15a3d7bb645d00984e2ce Mon Sep 17 00:00:00 2001 From: Germey Tsui Date: Mon, 8 Jan 2024 23:46:27 +0800 Subject: [PATCH 2/2] update log --- ...zhishuyun-hub-74f73d6f-c835-4233-86f8-0ef213a024b5.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@zhishuyun-hub-74f73d6f-c835-4233-86f8-0ef213a024b5.json diff --git a/change/@zhishuyun-hub-74f73d6f-c835-4233-86f8-0ef213a024b5.json b/change/@zhishuyun-hub-74f73d6f-c835-4233-86f8-0ef213a024b5.json new file mode 100644 index 0000000..d02aa4d --- /dev/null +++ b/change/@zhishuyun-hub-74f73d6f-c835-4233-86f8-0ef213a024b5.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "add support for config title and favicon", + "packageName": "@zhishuyun/hub", + "email": "cqc@germey.cn", + "dependentChangeType": "patch" +}