From 439be1797df5e5c9246a85c0883296b64abf792c Mon Sep 17 00:00:00 2001 From: AceDataCloud Date: Sun, 7 Jan 2024 19:05:16 +0800 Subject: [PATCH] Add support for collapse navigator and global config (#33) --- ...-3b8e7fee-8ae8-4ea3-aedb-19b2411ab13c.json | 7 + hub.config.js | 20 +++ src/components/common/AuthPanel.vue | 10 +- src/components/common/Chevron.vue | 38 +++++ src/components/common/Navigator.vue | 146 ++++++++++++++---- src/components/console/SidePanel.vue | 16 +- src/config.ts | 62 ++++++++ src/env.d.ts | 3 + src/i18n/zh/common/nav.ts | 2 +- src/layouts/Chat.vue | 2 +- src/layouts/Console.vue | 9 +- src/layouts/Main.vue | 1 - src/layouts/Midjourney.vue | 2 +- src/main.ts | 6 + src/pages/console/distribution/Index.vue | 3 + src/plugins/config.ts | 14 ++ src/plugins/font-awesome.ts | 4 +- src/store/common/models.ts | 4 +- src/store/common/state.ts | 4 + tsconfig.json | 2 +- 20 files changed, 305 insertions(+), 50 deletions(-) create mode 100644 change/@zhishuyun-hub-3b8e7fee-8ae8-4ea3-aedb-19b2411ab13c.json create mode 100644 hub.config.js create mode 100644 src/components/common/Chevron.vue create mode 100644 src/config.ts create mode 100644 src/plugins/config.ts diff --git a/change/@zhishuyun-hub-3b8e7fee-8ae8-4ea3-aedb-19b2411ab13c.json b/change/@zhishuyun-hub-3b8e7fee-8ae8-4ea3-aedb-19b2411ab13c.json new file mode 100644 index 00000000..4588b1fe --- /dev/null +++ b/change/@zhishuyun-hub-3b8e7fee-8ae8-4ea3-aedb-19b2411ab13c.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "add config support global", + "packageName": "@zhishuyun/hub", + "email": "cqc@cuiqingcai.com", + "dependentChangeType": "patch" +} diff --git a/hub.config.js b/hub.config.js new file mode 100644 index 00000000..dcb30b20 --- /dev/null +++ b/hub.config.js @@ -0,0 +1,20 @@ +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/src/components/common/AuthPanel.vue b/src/components/common/AuthPanel.vue index 06db452c..3fa5e0dd 100644 --- a/src/components/common/AuthPanel.vue +++ b/src/components/common/AuthPanel.vue @@ -27,7 +27,15 @@ export default defineComponent({ return `${getBaseUrlAuth()}/auth/login?inviter_id=${this.inviterId}`; }, inviterId() { - const result = this.$route.query.inviter_id?.toString() || getCookie('INVITER_ID'); + // if forceInviterId is set, then use forceInviterId + if (this.$config?.distribution?.forceInviterId) { + return this.$config?.distribution?.defaultInviterId; + } + // Otherwise, use the inviter_id in the url, then use the inviter_id in the cookie, and finally use the default inviter_id + const result = + this.$route.query.inviter_id?.toString() || + getCookie('INVITER_ID') || + this.$config?.distribution?.defaultInviterId; return result; }, authenticated() { diff --git a/src/components/common/Chevron.vue b/src/components/common/Chevron.vue new file mode 100644 index 00000000..374131ff --- /dev/null +++ b/src/components/common/Chevron.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/src/components/common/Navigator.vue b/src/components/common/Navigator.vue index 58819c7e..01e3e274 100644 --- a/src/components/common/Navigator.vue +++ b/src/components/common/Navigator.vue @@ -1,13 +1,26 @@