From 13f3af96b796796e2dfdf778880f98b301d814b5 Mon Sep 17 00:00:00 2001 From: vben Date: Sat, 6 Jul 2024 16:19:37 +0800 Subject: [PATCH] feat: add copyright components to enable preferences to configure copyright more accurately --- .../@core/forward/preferences/src/config.ts | 9 +++- .../@core/forward/preferences/src/types.ts | 19 +++++++- .../src/components/back-top/back-top.vue | 2 +- .../layouts/src/authentication/from-view.vue | 6 ++- .../layouts/src/basic/copyright/copyright.vue | 44 +++++++++++++++++++ .../layouts/src/basic/copyright/index.ts | 1 + .../business/layouts/src/basic/layout.vue | 8 +++- .../widgets/src/preferences/blocks/index.ts | 1 + .../preferences/blocks/layout/copyright.vue | 17 +++++++ .../src/preferences/preferences-widget.vue | 4 ++ .../widgets/src/preferences/preferences.vue | 6 +++ packages/locales/src/langs/en-US.yaml | 3 ++ packages/locales/src/langs/zh-CN.yaml | 4 +- 13 files changed, 116 insertions(+), 8 deletions(-) create mode 100644 packages/business/layouts/src/basic/copyright/copyright.vue create mode 100644 packages/business/layouts/src/basic/copyright/index.ts create mode 100644 packages/business/widgets/src/preferences/blocks/layout/copyright.vue diff --git a/packages/@core/forward/preferences/src/config.ts b/packages/@core/forward/preferences/src/config.ts index 65d2b38d..a0b58da5 100644 --- a/packages/@core/forward/preferences/src/config.ts +++ b/packages/@core/forward/preferences/src/config.ts @@ -9,7 +9,6 @@ const defaultPreferences: Preferences = { colorWeakMode: false, compact: false, contentCompact: 'wide', - copyright: 'Copyright © 2024 Vben Admin Pro', defaultAvatar: 'https://cdn.jsdelivr.net/npm/@vbenjs/static-source@0.1.0/source/avatar-v1.webp', dynamicTitle: true, @@ -27,6 +26,14 @@ const defaultPreferences: Preferences = { showIcon: true, styleType: 'normal', }, + copyright: { + companyName: 'Vben Admin Pro', + companySiteLink: 'https://www.vben.pro', + date: '2024', + enable: true, + icp: '', + icpLink: '', + }, footer: { enable: true, fixed: false, diff --git a/packages/@core/forward/preferences/src/types.ts b/packages/@core/forward/preferences/src/types.ts index 88e7982d..00b6db44 100644 --- a/packages/@core/forward/preferences/src/types.ts +++ b/packages/@core/forward/preferences/src/types.ts @@ -32,8 +32,6 @@ interface AppPreferences { compact: boolean; /** 是否开启内容紧凑模式 */ contentCompact: ContentCompactType; - /** 页脚Copyright */ - copyright: string; // /** 应用默认头像 */ defaultAvatar: string; // /** 开启动态标题 */ @@ -65,6 +63,21 @@ interface BreadcrumbPreferences { styleType: BreadcrumbStyleType; } +interface CopyrightPreferences { + /** 版权公司名 */ + companyName: string; + /** 版权公司名链接 */ + companySiteLink: string; + /** 版权日期 */ + date: string; + /** 版权是否可见 */ + enable: boolean; + /** 备案号 */ + icp: string; + /** 备案号链接 */ + icpLink: string; +} + interface FooterPreferences { /** 底栏是否可见 */ enable: boolean; @@ -167,6 +180,8 @@ interface Preferences { app: AppPreferences; /** 顶栏配置 */ breadcrumb: BreadcrumbPreferences; + /** 版权配置 */ + copyright: CopyrightPreferences; /** 底栏配置 */ footer: FooterPreferences; /** 面包屑配置 */ diff --git a/packages/@core/ui-kit/shadcn-ui/src/components/back-top/back-top.vue b/packages/@core/ui-kit/shadcn-ui/src/components/back-top/back-top.vue index 5a162f31..7d19f296 100644 --- a/packages/@core/ui-kit/shadcn-ui/src/components/back-top/back-top.vue +++ b/packages/@core/ui-kit/shadcn-ui/src/components/back-top/back-top.vue @@ -32,7 +32,7 @@ const { handleClick, visible } = useBackTop(props); import { preferences } from '@vben-core/preferences'; +import { Copyright } from '../basic/copyright'; import Toolbar from './toolbar.vue'; defineOptions({ @@ -28,7 +29,10 @@ defineOptions({
- {{ preferences.app.copyright }} +
diff --git a/packages/business/layouts/src/basic/copyright/copyright.vue b/packages/business/layouts/src/basic/copyright/copyright.vue new file mode 100644 index 00000000..005e3f11 --- /dev/null +++ b/packages/business/layouts/src/basic/copyright/copyright.vue @@ -0,0 +1,44 @@ + + + diff --git a/packages/business/layouts/src/basic/copyright/index.ts b/packages/business/layouts/src/basic/copyright/index.ts new file mode 100644 index 00000000..e0620daa --- /dev/null +++ b/packages/business/layouts/src/basic/copyright/index.ts @@ -0,0 +1 @@ +export { default as Copyright } from './copyright.vue'; diff --git a/packages/business/layouts/src/basic/layout.vue b/packages/business/layouts/src/basic/layout.vue index f78d130b..ca503f83 100644 --- a/packages/business/layouts/src/basic/layout.vue +++ b/packages/business/layouts/src/basic/layout.vue @@ -14,6 +14,7 @@ import { mapTree } from '@vben-core/toolkit'; import { MenuRecordRaw } from '@vben-core/typings'; import { LayoutContent } from './content'; +import { Copyright } from './copyright'; import { LayoutFooter } from './footer'; import { LayoutHeader } from './header'; import { @@ -267,8 +268,11 @@ function clearPreferencesAndLogout() { diff --git a/packages/business/widgets/src/preferences/blocks/index.ts b/packages/business/widgets/src/preferences/blocks/index.ts index 4d47f051..cd859154 100644 --- a/packages/business/widgets/src/preferences/blocks/index.ts +++ b/packages/business/widgets/src/preferences/blocks/index.ts @@ -3,6 +3,7 @@ export { default as Animation } from './general/animation.vue'; export { default as General } from './general/general.vue'; export { default as Breadcrumb } from './layout/breadcrumb.vue'; export { default as Content } from './layout/content.vue'; +export { default as Copyright } from './layout/copyright.vue'; export { default as Footer } from './layout/footer.vue'; export { default as Header } from './layout/header.vue'; export { default as Layout } from './layout/layout.vue'; diff --git a/packages/business/widgets/src/preferences/blocks/layout/copyright.vue b/packages/business/widgets/src/preferences/blocks/layout/copyright.vue new file mode 100644 index 00000000..96c1169b --- /dev/null +++ b/packages/business/widgets/src/preferences/blocks/layout/copyright.vue @@ -0,0 +1,17 @@ + + + diff --git a/packages/business/widgets/src/preferences/preferences-widget.vue b/packages/business/widgets/src/preferences/preferences-widget.vue index 43679bdc..70c628ee 100644 --- a/packages/business/widgets/src/preferences/preferences-widget.vue +++ b/packages/business/widgets/src/preferences/preferences-widget.vue @@ -19,6 +19,7 @@ import Preferences from './preferences.vue'; :breadcrumb-show-home="preferences.breadcrumb.showHome" :breadcrumb-show-icon="preferences.breadcrumb.showIcon" :breadcrumb-style-type="preferences.breadcrumb.styleType" + :copyright-enable="preferences.copyright.enable" :footer-enable="preferences.footer.enable" :footer-fixed="preferences.footer.fixed" :header-enable="preferences.header.enable" @@ -85,6 +86,9 @@ import Preferences from './preferences.vue'; @update:breadcrumb-style-type=" (val) => updatePreferences({ breadcrumb: { styleType: val } }) " + @update:copyright-enable=" + (val) => updatePreferences({ copyright: { enable: val } }) + " @update:footer-enable=" (val) => updatePreferences({ footer: { enable: val } }) " diff --git a/packages/business/widgets/src/preferences/preferences.vue b/packages/business/widgets/src/preferences/preferences.vue index ae72544e..5d9a8ec1 100644 --- a/packages/business/widgets/src/preferences/preferences.vue +++ b/packages/business/widgets/src/preferences/preferences.vue @@ -40,6 +40,7 @@ import { BuiltinTheme, ColorMode, Content, + Copyright, Footer, General, GlobalShortcutKeys, @@ -106,6 +107,8 @@ const navigationAccordion = defineModel('navigationAccordion'); const footerEnable = defineModel('footerEnable'); const footerFixed = defineModel('footerFixed'); +const copyrightEnable = defineModel('copyrightEnable'); + const shortcutKeysEnable = defineModel('shortcutKeysEnable'); const shortcutKeysGlobalSearch = defineModel( 'shortcutKeysGlobalSearch', @@ -321,6 +324,9 @@ async function handleReset() { v-model:footer-fixed="footerFixed" /> + + +