@kevairy/template 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +14 -0
- package/package.json +37 -0
- package/template/.env +22 -0
- package/template/.env.development +13 -0
- package/template/.env.production +10 -0
- package/template/.prettierignore +3 -0
- package/template/.prettierrc +20 -0
- package/template/.stylelintignore +9 -0
- package/template/.stylelintrc.cjs +84 -0
- package/template/LICENSE +21 -0
- package/template/README.md +22 -0
- package/template/_gitignore +19 -0
- package/template/eslint-auto-import.json +324 -0
- package/template/eslint.config.mjs +83 -0
- package/template/index.html +25 -0
- package/template/package.json +79 -0
- package/template/playwright.config.ts +25 -0
- package/template/public/favicon.ico +0 -0
- package/template/src/App.vue +39 -0
- package/template/src/adapters/auth/index.ts +9 -0
- package/template/src/adapters/auth/mock.ts +10 -0
- package/template/src/adapters/auth/types.ts +11 -0
- package/template/src/adapters/navigation/index.ts +13 -0
- package/template/src/adapters/navigation/types.ts +6 -0
- package/template/src/api/auth.ts +23 -0
- package/template/src/assets/images/avatar/avatar.webp +0 -0
- package/template/src/assets/images/avatar/avatar1.webp +0 -0
- package/template/src/assets/images/avatar/avatar10.webp +0 -0
- package/template/src/assets/images/avatar/avatar2.webp +0 -0
- package/template/src/assets/images/avatar/avatar3.webp +0 -0
- package/template/src/assets/images/avatar/avatar4.webp +0 -0
- package/template/src/assets/images/avatar/avatar5.webp +0 -0
- package/template/src/assets/images/avatar/avatar6.webp +0 -0
- package/template/src/assets/images/avatar/avatar7.webp +0 -0
- package/template/src/assets/images/avatar/avatar8.webp +0 -0
- package/template/src/assets/images/avatar/avatar9.webp +0 -0
- package/template/src/assets/images/ceremony/hb.png +0 -0
- package/template/src/assets/images/ceremony/sd.png +0 -0
- package/template/src/assets/images/ceremony/xc.png +0 -0
- package/template/src/assets/images/ceremony/yd.png +0 -0
- package/template/src/assets/images/common/logo.webp +0 -0
- package/template/src/assets/images/draw/draw1.png +0 -0
- package/template/src/assets/images/favicon.ico +0 -0
- package/template/src/assets/images/lock/bg_dark.webp +0 -0
- package/template/src/assets/images/lock/bg_light.webp +0 -0
- package/template/src/assets/images/login/kylin-hero-source.png +0 -0
- package/template/src/assets/images/login/lf_icon2.webp +0 -0
- package/template/src/assets/images/settings/menu_layouts/dual_column.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/horizontal.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/mixed.png +0 -0
- package/template/src/assets/images/settings/menu_layouts/vertical.png +0 -0
- package/template/src/assets/images/settings/menu_styles/dark.png +0 -0
- package/template/src/assets/images/settings/menu_styles/design.png +0 -0
- package/template/src/assets/images/settings/menu_styles/light.png +0 -0
- package/template/src/assets/images/settings/theme_styles/dark.png +0 -0
- package/template/src/assets/images/settings/theme_styles/light.png +0 -0
- package/template/src/assets/images/settings/theme_styles/system.png +0 -0
- package/template/src/assets/images/svg/403.svg +1 -0
- package/template/src/assets/images/svg/404.svg +1 -0
- package/template/src/assets/images/svg/500.svg +5 -0
- package/template/src/assets/images/svg/login_icon.svg +1 -0
- package/template/src/assets/images/user/avatar.webp +0 -0
- package/template/src/assets/images/user/bg.webp +0 -0
- package/template/src/assets/styles/core/app.scss +227 -0
- package/template/src/assets/styles/core/dark.scss +93 -0
- package/template/src/assets/styles/core/el-dark.scss +2 -0
- package/template/src/assets/styles/core/el-light.scss +34 -0
- package/template/src/assets/styles/core/el-ui.scss +519 -0
- package/template/src/assets/styles/core/md.scss +1036 -0
- package/template/src/assets/styles/core/mixin.scss +157 -0
- package/template/src/assets/styles/core/reset.scss +41 -0
- package/template/src/assets/styles/core/router-transition.scss +104 -0
- package/template/src/assets/styles/core/tailwind.css +219 -0
- package/template/src/assets/styles/core/theme-animation.scss +63 -0
- package/template/src/assets/styles/core/theme-change.scss +11 -0
- package/template/src/assets/styles/custom/one-dark-pro.scss +98 -0
- package/template/src/assets/styles/index.scss +23 -0
- package/template/src/assets/svg/loading.ts +32 -0
- package/template/src/bootstrap/initializeApp.ts +30 -0
- package/template/src/components/core/banners/art-basic-banner/index.vue +343 -0
- package/template/src/components/core/banners/art-card-banner/index.vue +114 -0
- package/template/src/components/core/base/art-back-to-top/index.vue +40 -0
- package/template/src/components/core/base/art-logo/index.vue +34 -0
- package/template/src/components/core/base/art-svg-icon/index.vue +24 -0
- package/template/src/components/core/cards/art-bar-chart-card/index.vue +103 -0
- package/template/src/components/core/cards/art-data-list-card/index.vue +74 -0
- package/template/src/components/core/cards/art-donut-chart-card/index.vue +124 -0
- package/template/src/components/core/cards/art-image-card/index.vue +89 -0
- package/template/src/components/core/cards/art-line-chart-card/index.vue +126 -0
- package/template/src/components/core/cards/art-progress-card/index.vue +86 -0
- package/template/src/components/core/cards/art-stats-card/index.vue +67 -0
- package/template/src/components/core/cards/art-timeline-list-card/index.vue +69 -0
- package/template/src/components/core/charts/art-bar-chart/index.vue +203 -0
- package/template/src/components/core/charts/art-dual-bar-compare-chart/index.vue +195 -0
- package/template/src/components/core/charts/art-h-bar-chart/index.vue +208 -0
- package/template/src/components/core/charts/art-k-line-chart/index.vue +152 -0
- package/template/src/components/core/charts/art-line-chart/index.vue +371 -0
- package/template/src/components/core/charts/art-radar-chart/index.vue +105 -0
- package/template/src/components/core/charts/art-ring-chart/index.vue +133 -0
- package/template/src/components/core/charts/art-scatter-chart/index.vue +115 -0
- package/template/src/components/core/feedback/art-page-loading/index.vue +281 -0
- package/template/src/components/core/forms/art-button-more/index.vue +71 -0
- package/template/src/components/core/forms/art-button-table/index.vue +59 -0
- package/template/src/components/core/forms/art-drag-verify/index.vue +430 -0
- package/template/src/components/core/forms/art-excel-export/index.vue +390 -0
- package/template/src/components/core/forms/art-excel-import/index.vue +62 -0
- package/template/src/components/core/forms/art-form/index.vue +507 -0
- package/template/src/components/core/forms/art-wang-editor/index.vue +261 -0
- package/template/src/components/core/forms/art-wang-editor/style.scss +273 -0
- package/template/src/components/core/layouts/art-breadcrumb/index.vue +142 -0
- package/template/src/components/core/layouts/art-chat-window/index.vue +262 -0
- package/template/src/components/core/layouts/art-fast-enter/index.vue +113 -0
- package/template/src/components/core/layouts/art-fireworks-effect/index.vue +633 -0
- package/template/src/components/core/layouts/art-global-component/index.vue +14 -0
- package/template/src/components/core/layouts/art-global-search/index.vue +431 -0
- package/template/src/components/core/layouts/art-header-bar/index.vue +485 -0
- package/template/src/components/core/layouts/art-header-bar/widget/ArtUserMenu.vue +118 -0
- package/template/src/components/core/layouts/art-menus/art-horizontal-menu/index.vue +110 -0
- package/template/src/components/core/layouts/art-menus/art-horizontal-menu/widget/HorizontalSubmenu.vue +106 -0
- package/template/src/components/core/layouts/art-menus/art-mixed-menu/index.vue +279 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/index.vue +354 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/style.scss +251 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/theme.scss +258 -0
- package/template/src/components/core/layouts/art-menus/art-sidebar-menu/widget/SidebarSubmenu.vue +190 -0
- package/template/src/components/core/layouts/art-notification/index.vue +456 -0
- package/template/src/components/core/layouts/art-page-content/index.vue +137 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsConfig.ts +248 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsHandlers.ts +167 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsPanel.ts +233 -0
- package/template/src/components/core/layouts/art-settings-panel/composables/useSettingsState.ts +37 -0
- package/template/src/components/core/layouts/art-settings-panel/index.vue +72 -0
- package/template/src/components/core/layouts/art-settings-panel/style.scss +92 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/BasicSettings.vue +77 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/BoxStyleSettings.vue +38 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ColorSettings.vue +35 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ContainerSettings.vue +33 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/MenuLayoutSettings.vue +31 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/MenuStyleSettings.vue +44 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SectionTitle.vue +17 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingActions.vue +236 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingDrawer.vue +51 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingHeader.vue +18 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingItem.vue +101 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/ThemeSettings.vue +28 -0
- package/template/src/components/core/layouts/art-work-tab/index.vue +584 -0
- package/template/src/components/core/media/art-cutter-img/index.vue +350 -0
- package/template/src/components/core/media/art-video-player/index.vue +111 -0
- package/template/src/components/core/others/art-menu-right/index.vue +415 -0
- package/template/src/components/core/others/art-watermark/index.vue +64 -0
- package/template/src/components/core/text-effect/art-count-to/index.vue +310 -0
- package/template/src/components/core/text-effect/art-festival-text-scroll/index.vue +32 -0
- package/template/src/components/core/text-effect/art-text-scroll/index.vue +285 -0
- package/template/src/components/core/theme/theme-svg/index.vue +100 -0
- package/template/src/components/core/views/exception/ArtException.vue +55 -0
- package/template/src/components/core/views/login/AuthTopBar.vue +149 -0
- package/template/src/components/core/views/login/LoginLeftView.vue +602 -0
- package/template/src/components/core/views/result/ArtResultPage.vue +43 -0
- package/template/src/components/core/widget/art-icon-button/index.vue +23 -0
- package/template/src/config/assets/images.ts +61 -0
- package/template/src/config/index.ts +170 -0
- package/template/src/config/modules/component.ts +98 -0
- package/template/src/config/modules/fastEnter.ts +16 -0
- package/template/src/config/modules/festival.ts +51 -0
- package/template/src/config/modules/headerBar.ts +64 -0
- package/template/src/config/setting.ts +109 -0
- package/template/src/directives/core/auth.ts +66 -0
- package/template/src/directives/core/highlight-loader.ts +37 -0
- package/template/src/directives/core/highlight.ts +253 -0
- package/template/src/directives/core/ripple.ts +116 -0
- package/template/src/directives/core/roles.ts +87 -0
- package/template/src/directives/index.ts +14 -0
- package/template/src/enums/appEnum.ts +81 -0
- package/template/src/enums/formEnum.ts +17 -0
- package/template/src/env.d.ts +32 -0
- package/template/src/hooks/core/useAppMode.ts +45 -0
- package/template/src/hooks/core/useAuth.ts +74 -0
- package/template/src/hooks/core/useCeremony.ts +184 -0
- package/template/src/hooks/core/useChart.ts +745 -0
- package/template/src/hooks/core/useCommon.ts +87 -0
- package/template/src/hooks/core/useFastEnter.ts +55 -0
- package/template/src/hooks/core/useHeaderBar.ts +201 -0
- package/template/src/hooks/core/useLayoutHeight.ts +148 -0
- package/template/src/hooks/core/useTableColumns.ts +313 -0
- package/template/src/hooks/core/useTheme.ts +174 -0
- package/template/src/hooks/index.ts +29 -0
- package/template/src/locales/index.ts +123 -0
- package/template/src/locales/langs/en.json +283 -0
- package/template/src/locales/langs/zh.json +283 -0
- package/template/src/main.ts +29 -0
- package/template/src/mock/auth.ts +46 -0
- package/template/src/plugins/echarts.ts +76 -0
- package/template/src/plugins/index.ts +6 -0
- package/template/src/router/core/ComponentLoader.ts +82 -0
- package/template/src/router/core/IframeRouteManager.ts +78 -0
- package/template/src/router/core/MenuProcessor.ts +280 -0
- package/template/src/router/core/RoutePermissionValidator.ts +161 -0
- package/template/src/router/core/RouteRegistry.ts +90 -0
- package/template/src/router/core/RouteTransformer.ts +132 -0
- package/template/src/router/core/RouteValidator.ts +187 -0
- package/template/src/router/core/index.ts +14 -0
- package/template/src/router/guards/afterEach.ts +34 -0
- package/template/src/router/guards/beforeEach.ts +442 -0
- package/template/src/router/index.ts +24 -0
- package/template/src/router/modules/dashboard.ts +23 -0
- package/template/src/router/modules/examples.ts +109 -0
- package/template/src/router/modules/exception.ts +46 -0
- package/template/src/router/modules/index.ts +12 -0
- package/template/src/router/modules/result.ts +32 -0
- package/template/src/router/routes/asyncRoutes.ts +9 -0
- package/template/src/router/routes/staticRoutes.ts +60 -0
- package/template/src/router/routesAlias.ts +8 -0
- package/template/src/services/auth.ts +15 -0
- package/template/src/store/index.ts +52 -0
- package/template/src/store/modules/menu.ts +109 -0
- package/template/src/store/modules/setting.ts +450 -0
- package/template/src/store/modules/user.ts +218 -0
- package/template/src/store/modules/worktab.ts +568 -0
- package/template/src/types/api/api.d.ts +86 -0
- package/template/src/types/common/index.ts +95 -0
- package/template/src/types/common/response.ts +32 -0
- package/template/src/types/component/chart.ts +324 -0
- package/template/src/types/component/index.ts +86 -0
- package/template/src/types/config/index.ts +253 -0
- package/template/src/types/directive/directive.d.ts +15 -0
- package/template/src/types/import/auto-imports.d.ts +319 -0
- package/template/src/types/import/components.d.ts +126 -0
- package/template/src/types/index.ts +22 -0
- package/template/src/types/router/index.ts +80 -0
- package/template/src/types/store/index.ts +157 -0
- package/template/src/utils/form/index.ts +9 -0
- package/template/src/utils/form/validator.ts +316 -0
- package/template/src/utils/http/contract.ts +39 -0
- package/template/src/utils/http/error.ts +182 -0
- package/template/src/utils/http/index.ts +226 -0
- package/template/src/utils/http/status.ts +18 -0
- package/template/src/utils/index.ts +31 -0
- package/template/src/utils/navigation/index.ts +10 -0
- package/template/src/utils/navigation/jump.ts +68 -0
- package/template/src/utils/navigation/route.ts +85 -0
- package/template/src/utils/navigation/worktab.ts +67 -0
- package/template/src/utils/router.ts +63 -0
- package/template/src/utils/socket/index.ts +423 -0
- package/template/src/utils/storage/index.ts +7 -0
- package/template/src/utils/storage/storage-config.ts +127 -0
- package/template/src/utils/storage/storage-key-manager.ts +97 -0
- package/template/src/utils/storage/storage.ts +250 -0
- package/template/src/utils/sys/console.ts +9 -0
- package/template/src/utils/sys/error-handle.ts +143 -0
- package/template/src/utils/sys/index.ts +2 -0
- package/template/src/utils/sys/mittBus.ts +61 -0
- package/template/src/utils/ui/animation.ts +80 -0
- package/template/src/utils/ui/colors.ts +273 -0
- package/template/src/utils/ui/emojo.ts +24 -0
- package/template/src/utils/ui/iconify-loader.ts +31 -0
- package/template/src/utils/ui/index.ts +11 -0
- package/template/src/utils/ui/loading.ts +158 -0
- package/template/src/utils/ui/tabs.ts +60 -0
- package/template/src/views/auth/forget-password/index.vue +62 -0
- package/template/src/views/auth/login/index.vue +166 -0
- package/template/src/views/auth/login/style.css +38 -0
- package/template/src/views/auth/register/index.vue +240 -0
- package/template/src/views/dashboard/console/index.vue +173 -0
- package/template/src/views/examples/analytics/index.vue +389 -0
- package/template/src/views/examples/complex-form/index.vue +395 -0
- package/template/src/views/examples/crud-workspace/index.vue +412 -0
- package/template/src/views/examples/navigation/detail/index.vue +151 -0
- package/template/src/views/examples/navigation/state/index.vue +226 -0
- package/template/src/views/examples/overview/index.vue +309 -0
- package/template/src/views/examples/permissions/index.vue +303 -0
- package/template/src/views/examples/search-table/index.vue +182 -0
- package/template/src/views/examples/search-table/search.config.ts +81 -0
- package/template/src/views/examples/search-table/service.ts +116 -0
- package/template/src/views/examples/search-table/table.config.ts +37 -0
- package/template/src/views/exception/403/index.vue +16 -0
- package/template/src/views/exception/404/index.vue +16 -0
- package/template/src/views/exception/500/index.vue +16 -0
- package/template/src/views/index/index.vue +29 -0
- package/template/src/views/index/style.scss +93 -0
- package/template/src/views/outside/Iframe.vue +42 -0
- package/template/src/views/result/fail/index.vue +28 -0
- package/template/src/views/result/success/index.vue +21 -0
- package/template/tests/e2e/auth.spec.ts +14 -0
- package/template/tests/e2e/search-table.spec.ts +154 -0
- package/template/tests/unit/adapters/auth.spec.ts +38 -0
- package/template/tests/unit/config/app-config.spec.ts +17 -0
- package/template/tests/unit/directives/highlight.spec.ts +20 -0
- package/template/tests/unit/http/contract.spec.ts +47 -0
- package/template/tests/unit/mock/search-table.spec.ts +62 -0
- package/template/tests/unit/router/examples.spec.ts +52 -0
- package/template/tsconfig.json +28 -0
- package/template/vite.config.ts +181 -0
- package/template/vitest.config.ts +27 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 存储兼容性管理模块
|
|
3
|
+
*
|
|
4
|
+
* 提供完整的本地存储兼容性检查和数据验证功能
|
|
5
|
+
*
|
|
6
|
+
* 主要功能
|
|
7
|
+
*
|
|
8
|
+
* - 多版本存储数据检测和验证
|
|
9
|
+
* - 新旧存储格式兼容处理
|
|
10
|
+
* - 存储数据完整性校验
|
|
11
|
+
* - 存储异常自动恢复(清理+登出)
|
|
12
|
+
* - 登录状态验证
|
|
13
|
+
* - 存储为空检测
|
|
14
|
+
* - 版本号管理
|
|
15
|
+
*
|
|
16
|
+
* ## 使用场景
|
|
17
|
+
*
|
|
18
|
+
* - 应用启动时检查存储数据有效性
|
|
19
|
+
* - 路由守卫中验证登录状态
|
|
20
|
+
* - 版本升级时的数据兼容性检查
|
|
21
|
+
* - 存储异常时的自动恢复
|
|
22
|
+
* - 防止因存储数据损坏导致的系统异常
|
|
23
|
+
*
|
|
24
|
+
* ## 工作流程
|
|
25
|
+
*
|
|
26
|
+
* 1. 优先检查当前版本的存储数据
|
|
27
|
+
* 2. 检查其他版本的存储数据
|
|
28
|
+
* 3. 兼容旧格式的存储数据
|
|
29
|
+
* 4. 验证数据完整性
|
|
30
|
+
* 5. 异常时提示用户并执行登出
|
|
31
|
+
*
|
|
32
|
+
* @module utils/storage/storage
|
|
33
|
+
* @author Art Design Pro Team
|
|
34
|
+
*/
|
|
35
|
+
import { router } from '@/router'
|
|
36
|
+
import { useUserStore } from '@/store/modules/user'
|
|
37
|
+
import { StorageConfig } from '@/utils/storage/storage-config'
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 存储兼容性管理器
|
|
41
|
+
* 负责处理不同版本间的存储兼容性检查和数据验证
|
|
42
|
+
*/
|
|
43
|
+
class StorageCompatibilityManager {
|
|
44
|
+
/**
|
|
45
|
+
* 获取系统版本号
|
|
46
|
+
*/
|
|
47
|
+
getSystemVersion(): string | null {
|
|
48
|
+
return localStorage.getItem(StorageConfig.VERSION_KEY)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 获取系统存储数据(兼容旧格式)
|
|
53
|
+
*/
|
|
54
|
+
getSystemStorage(): any {
|
|
55
|
+
const version = this.getSystemVersion() || StorageConfig.CURRENT_VERSION
|
|
56
|
+
const legacyKey = StorageConfig.generateLegacyKey(version)
|
|
57
|
+
const data = localStorage.getItem(legacyKey)
|
|
58
|
+
return data ? JSON.parse(data) : null
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 检查当前版本是否有存储数据
|
|
63
|
+
*/
|
|
64
|
+
private hasCurrentVersionStorage(): boolean {
|
|
65
|
+
const storageKeys = Object.keys(localStorage)
|
|
66
|
+
const currentVersionPattern = StorageConfig.createCurrentVersionPattern()
|
|
67
|
+
|
|
68
|
+
return storageKeys.some(
|
|
69
|
+
(key) => currentVersionPattern.test(key) && localStorage.getItem(key) !== null
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 检查是否存在任何版本的存储数据
|
|
75
|
+
*/
|
|
76
|
+
private hasAnyVersionStorage(): boolean {
|
|
77
|
+
const storageKeys = Object.keys(localStorage)
|
|
78
|
+
const versionPattern = StorageConfig.createVersionPattern()
|
|
79
|
+
|
|
80
|
+
return storageKeys.some((key) => versionPattern.test(key) && localStorage.getItem(key) !== null)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 获取旧格式的本地存储数据
|
|
85
|
+
*/
|
|
86
|
+
private getLegacyStorageData(): Record<string, any> {
|
|
87
|
+
try {
|
|
88
|
+
const systemStorage = this.getSystemStorage()
|
|
89
|
+
return systemStorage || {}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.warn('[Storage] 解析旧格式存储数据失败:', error)
|
|
92
|
+
return {}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 显示存储错误消息
|
|
98
|
+
*/
|
|
99
|
+
private showStorageError(): void {
|
|
100
|
+
ElMessage({
|
|
101
|
+
type: 'error',
|
|
102
|
+
offset: 40,
|
|
103
|
+
duration: 5000,
|
|
104
|
+
message: '系统检测到本地数据异常,请重新登录系统恢复使用!'
|
|
105
|
+
})
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 执行系统登出
|
|
110
|
+
*/
|
|
111
|
+
private performSystemLogout(): void {
|
|
112
|
+
setTimeout(() => {
|
|
113
|
+
try {
|
|
114
|
+
localStorage.clear()
|
|
115
|
+
useUserStore().logOut()
|
|
116
|
+
router.push({ name: 'Login' })
|
|
117
|
+
console.info('[Storage] 已执行系统登出')
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('[Storage] 系统登出失败:', error)
|
|
120
|
+
}
|
|
121
|
+
}, StorageConfig.LOGOUT_DELAY)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 处理存储异常
|
|
126
|
+
*/
|
|
127
|
+
private handleStorageError(): void {
|
|
128
|
+
this.showStorageError()
|
|
129
|
+
this.performSystemLogout()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 验证存储数据完整性
|
|
134
|
+
* @param requireAuth 是否需要验证登录状态(默认 false)
|
|
135
|
+
*/
|
|
136
|
+
validateStorageData(requireAuth: boolean = false): boolean {
|
|
137
|
+
try {
|
|
138
|
+
// 优先检查新版本存储结构
|
|
139
|
+
if (this.hasCurrentVersionStorage()) {
|
|
140
|
+
// console.debug('[Storage] 发现当前版本存储数据')
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 检查是否有任何版本的存储数据
|
|
145
|
+
if (this.hasAnyVersionStorage()) {
|
|
146
|
+
// console.debug('[Storage] 发现其他版本存储数据,可能需要迁移')
|
|
147
|
+
return true
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// 检查旧版本存储结构
|
|
151
|
+
const legacyData = this.getLegacyStorageData()
|
|
152
|
+
if (Object.keys(legacyData).length === 0) {
|
|
153
|
+
// 只有在需要验证登录状态时才执行登出操作
|
|
154
|
+
if (requireAuth) {
|
|
155
|
+
console.warn('[Storage] 未发现任何存储数据,需要重新登录')
|
|
156
|
+
this.performSystemLogout()
|
|
157
|
+
return false
|
|
158
|
+
}
|
|
159
|
+
// 首次访问或访问静态路由,不需要登出
|
|
160
|
+
// console.debug('[Storage] 未发现存储数据,首次访问或访问静态路由')
|
|
161
|
+
return true
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
console.debug('[Storage] 发现旧版本存储数据')
|
|
165
|
+
return true
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('[Storage] 存储数据验证失败:', error)
|
|
168
|
+
// 只有在需要验证登录状态时才处理错误
|
|
169
|
+
if (requireAuth) {
|
|
170
|
+
this.handleStorageError()
|
|
171
|
+
return false
|
|
172
|
+
}
|
|
173
|
+
return true
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* 检查存储是否为空
|
|
179
|
+
*/
|
|
180
|
+
isStorageEmpty(): boolean {
|
|
181
|
+
// 检查新版本存储结构
|
|
182
|
+
if (this.hasCurrentVersionStorage()) {
|
|
183
|
+
return false
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// 检查是否有任何版本的存储数据
|
|
187
|
+
if (this.hasAnyVersionStorage()) {
|
|
188
|
+
return false
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 检查旧版本存储结构
|
|
192
|
+
const legacyData = this.getLegacyStorageData()
|
|
193
|
+
return Object.keys(legacyData).length === 0
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* 检查存储兼容性
|
|
198
|
+
* @param requireAuth 是否需要验证登录状态(默认 false)
|
|
199
|
+
*/
|
|
200
|
+
checkCompatibility(requireAuth: boolean = false): boolean {
|
|
201
|
+
try {
|
|
202
|
+
const isValid = this.validateStorageData(requireAuth)
|
|
203
|
+
const isEmpty = this.isStorageEmpty()
|
|
204
|
+
|
|
205
|
+
if (isValid || isEmpty) {
|
|
206
|
+
// console.debug('[Storage] 存储兼容性检查通过')
|
|
207
|
+
return true
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
console.warn('[Storage] 存储兼容性检查失败')
|
|
211
|
+
return false
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.error('[Storage] 兼容性检查异常:', error)
|
|
214
|
+
return false
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 创建存储兼容性管理器实例
|
|
220
|
+
const storageManager = new StorageCompatibilityManager()
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 获取系统存储数据
|
|
224
|
+
*/
|
|
225
|
+
export function getSystemStorage(): any {
|
|
226
|
+
return storageManager.getSystemStorage()
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 获取系统版本号
|
|
231
|
+
*/
|
|
232
|
+
export function getSysVersion(): string | null {
|
|
233
|
+
return storageManager.getSystemVersion()
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* 验证本地存储数据
|
|
238
|
+
* @param requireAuth 是否需要验证登录状态(默认 false)
|
|
239
|
+
*/
|
|
240
|
+
export function validateStorageData(requireAuth: boolean = false): boolean {
|
|
241
|
+
return storageManager.validateStorageData(requireAuth)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* 检查存储兼容性
|
|
246
|
+
* @param requireAuth 是否需要验证登录状态(默认 false)
|
|
247
|
+
*/
|
|
248
|
+
export function checkStorageCompatibility(requireAuth: boolean = false): boolean {
|
|
249
|
+
return storageManager.checkCompatibility(requireAuth)
|
|
250
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import AppConfig from '@/config'
|
|
2
|
+
|
|
3
|
+
const banner = [
|
|
4
|
+
`%c${AppConfig.systemInfo.name}%c ${AppConfig.systemInfo.description ?? ''}`,
|
|
5
|
+
'padding:4px 8px;border-radius:6px 0 0 6px;background:#1e40af;color:#fff;font-weight:600',
|
|
6
|
+
'padding:4px 8px;border-radius:0 6px 6px 0;background:#dbeafe;color:#1e3a8a;font-weight:500'
|
|
7
|
+
] as const
|
|
8
|
+
|
|
9
|
+
console.info(...banner)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全局错误处理模块
|
|
3
|
+
*
|
|
4
|
+
* 提供统一的错误捕获和处理机制
|
|
5
|
+
*
|
|
6
|
+
* ## 主要功能
|
|
7
|
+
*
|
|
8
|
+
* - Vue 运行时错误捕获(组件错误、生命周期错误等)
|
|
9
|
+
* - 全局脚本错误捕获(语法错误、运行时错误等)
|
|
10
|
+
* - Promise 未捕获错误处理(unhandledrejection)
|
|
11
|
+
* - 静态资源加载错误监控(图片、脚本、样式等)
|
|
12
|
+
* - 错误日志记录和上报
|
|
13
|
+
* - 统一的错误处理入口
|
|
14
|
+
*
|
|
15
|
+
* ## 使用场景
|
|
16
|
+
* - 应用启动时安装全局错误处理器
|
|
17
|
+
* - 捕获和记录所有类型的错误
|
|
18
|
+
* - 错误上报到监控平台
|
|
19
|
+
* - 提升应用稳定性和可维护性
|
|
20
|
+
* - 问题排查和调试
|
|
21
|
+
*
|
|
22
|
+
* ## 错误类型
|
|
23
|
+
*
|
|
24
|
+
* - VueError: Vue 组件相关错误
|
|
25
|
+
* - ScriptError: JavaScript 脚本错误
|
|
26
|
+
* - PromiseError: Promise 未捕获的 rejection
|
|
27
|
+
* - ResourceError: 静态资源加载失败
|
|
28
|
+
*
|
|
29
|
+
* @module utils/sys/error-handle
|
|
30
|
+
* @author Art Design Pro Team
|
|
31
|
+
*/
|
|
32
|
+
import type { App } from 'vue'
|
|
33
|
+
|
|
34
|
+
const IGNORABLE_SCRIPT_ERRORS = [
|
|
35
|
+
'ResizeObserver loop completed with undelivered notifications.',
|
|
36
|
+
'ResizeObserver loop limit exceeded'
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
function normalizeErrorMessage(message: Event | string): string {
|
|
40
|
+
if (typeof message === 'string') {
|
|
41
|
+
return message
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if ('message' in message && typeof message.message === 'string') {
|
|
45
|
+
return message.message
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return ''
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isIgnorableScriptError(message: Event | string, source?: string): boolean {
|
|
52
|
+
const normalizedMessage = normalizeErrorMessage(message)
|
|
53
|
+
|
|
54
|
+
if (!normalizedMessage) {
|
|
55
|
+
return false
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (IGNORABLE_SCRIPT_ERRORS.some((item) => normalizedMessage.includes(item))) {
|
|
59
|
+
// 浏览器/扩展在布局抖动时常见的 ResizeObserver 噪声,不作为真实异常处理
|
|
60
|
+
return true
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 浏览器扩展注入脚本偶发的跨域 Script error 也没有排查价值
|
|
64
|
+
if (normalizedMessage === 'Script error.' && source === '') {
|
|
65
|
+
return true
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return false
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Vue 运行时错误处理
|
|
73
|
+
*/
|
|
74
|
+
export function vueErrorHandler(err: unknown, instance: any, info: string) {
|
|
75
|
+
console.error('[VueError]', err, info, instance)
|
|
76
|
+
// 这里可以上报到服务端,比如:
|
|
77
|
+
// reportError({ type: 'vue', err, info })
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 全局脚本错误处理
|
|
82
|
+
*/
|
|
83
|
+
export function scriptErrorHandler(
|
|
84
|
+
message: Event | string,
|
|
85
|
+
source?: string,
|
|
86
|
+
lineno?: number,
|
|
87
|
+
colno?: number,
|
|
88
|
+
error?: Error
|
|
89
|
+
): boolean {
|
|
90
|
+
if (isIgnorableScriptError(message, source)) {
|
|
91
|
+
return true
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
console.error('[ScriptError]', { message, source, lineno, colno, error })
|
|
95
|
+
// reportError({ type: 'script', message, source, lineno, colno, error })
|
|
96
|
+
return true // 阻止默认控制台报错,可根据需求改
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Promise 未捕获错误处理
|
|
101
|
+
*/
|
|
102
|
+
export function registerPromiseErrorHandler() {
|
|
103
|
+
window.addEventListener('unhandledrejection', (event) => {
|
|
104
|
+
console.error('[PromiseError]', event.reason)
|
|
105
|
+
// reportError({ type: 'promise', reason: event.reason })
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 资源加载错误处理 (img, script, css...)
|
|
111
|
+
*/
|
|
112
|
+
export function registerResourceErrorHandler() {
|
|
113
|
+
window.addEventListener(
|
|
114
|
+
'error',
|
|
115
|
+
(event: Event) => {
|
|
116
|
+
const target = event.target as HTMLElement
|
|
117
|
+
if (
|
|
118
|
+
target &&
|
|
119
|
+
(target.tagName === 'IMG' || target.tagName === 'SCRIPT' || target.tagName === 'LINK')
|
|
120
|
+
) {
|
|
121
|
+
console.error('[ResourceError]', {
|
|
122
|
+
tagName: target.tagName,
|
|
123
|
+
src:
|
|
124
|
+
(target as HTMLImageElement).src ||
|
|
125
|
+
(target as HTMLScriptElement).src ||
|
|
126
|
+
(target as HTMLLinkElement).href
|
|
127
|
+
})
|
|
128
|
+
// reportError({ type: 'resource', target })
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
true // 捕获阶段才能监听到资源错误
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* 安装统一错误处理
|
|
137
|
+
*/
|
|
138
|
+
export function setupErrorHandle(app: App) {
|
|
139
|
+
app.config.errorHandler = vueErrorHandler
|
|
140
|
+
window.onerror = scriptErrorHandler
|
|
141
|
+
registerPromiseErrorHandler()
|
|
142
|
+
registerResourceErrorHandler()
|
|
143
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全局事件总线模块
|
|
3
|
+
*
|
|
4
|
+
* 基于 mitt 库实现的类型安全的事件总线
|
|
5
|
+
*
|
|
6
|
+
* ## 主要功能
|
|
7
|
+
*
|
|
8
|
+
* - 跨组件通信(发布/订阅模式)
|
|
9
|
+
* - 类型安全的事件定义和调用
|
|
10
|
+
* - 全局事件管理(烟花效果、设置面板、搜索对话框等)
|
|
11
|
+
* - 解耦组件间的直接依赖
|
|
12
|
+
*
|
|
13
|
+
* ## 使用场景
|
|
14
|
+
*
|
|
15
|
+
* - 跨层级组件通信
|
|
16
|
+
* - 全局功能触发(设置、搜索、聊天、锁屏等)
|
|
17
|
+
* - 特效触发(烟花效果)
|
|
18
|
+
* - 避免 props 层层传递
|
|
19
|
+
*
|
|
20
|
+
* ## 用法示例
|
|
21
|
+
*
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // 订阅事件
|
|
24
|
+
* mittBus.on('openSetting', () => { ... })
|
|
25
|
+
*
|
|
26
|
+
* // 发布事件
|
|
27
|
+
* mittBus.emit('openSetting')
|
|
28
|
+
*
|
|
29
|
+
* // 带参数的事件
|
|
30
|
+
* mittBus.emit('triggerFireworks', 'image-url')
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* ## 已定义的事件
|
|
34
|
+
*
|
|
35
|
+
* - triggerFireworks: 触发烟花效果(可选图片URL)
|
|
36
|
+
* - openSetting: 打开设置面板
|
|
37
|
+
* - openSearchDialog: 打开搜索对话框
|
|
38
|
+
* - openChat: 打开聊天窗口
|
|
39
|
+
*
|
|
40
|
+
* @module utils/sys/mittBus
|
|
41
|
+
* @author Art Design Pro Team
|
|
42
|
+
*/
|
|
43
|
+
import mitt, { type Emitter } from 'mitt'
|
|
44
|
+
|
|
45
|
+
// 定义事件类型映射
|
|
46
|
+
type Events = {
|
|
47
|
+
// 烟花效果事件 - 可选的图片URL参数
|
|
48
|
+
triggerFireworks: string | undefined
|
|
49
|
+
// 打开设置面板事件 - 无参数
|
|
50
|
+
openSetting: void
|
|
51
|
+
// 打开搜索对话框事件 - 无参数
|
|
52
|
+
openSearchDialog: void
|
|
53
|
+
// 打开聊天窗口事件 - 无参数
|
|
54
|
+
openChat: void
|
|
55
|
+
// 打开锁屏事件 - 无参数
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 创建类型安全的事件总线实例
|
|
59
|
+
const mittBus: Emitter<Events> = mitt<Events>()
|
|
60
|
+
|
|
61
|
+
export default mittBus
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题动画工具模块
|
|
3
|
+
*
|
|
4
|
+
* 提供主题切换的视觉动画效果
|
|
5
|
+
*
|
|
6
|
+
* ## 主要功能
|
|
7
|
+
*
|
|
8
|
+
* - 基于鼠标点击位置的圆形扩散动画
|
|
9
|
+
* - View Transition API 支持(现代浏览器)
|
|
10
|
+
* - 降级处理(不支持动画的浏览器)
|
|
11
|
+
* - 暗黑主题切换过渡效果
|
|
12
|
+
* - 页面刷新时的主题过渡优化
|
|
13
|
+
*
|
|
14
|
+
* ## 使用场景
|
|
15
|
+
*
|
|
16
|
+
* - 明暗主题切换
|
|
17
|
+
* - 提升用户体验的视觉反馈
|
|
18
|
+
* - 页面刷新时的平滑过渡
|
|
19
|
+
*
|
|
20
|
+
* ## 技术实现
|
|
21
|
+
*
|
|
22
|
+
* - 使用 CSS 变量存储点击位置和半径
|
|
23
|
+
* - 利用 View Transition API 实现流畅动画
|
|
24
|
+
* - 通过 CSS class 控制过渡效果
|
|
25
|
+
* - 自动计算最大扩散半径
|
|
26
|
+
*
|
|
27
|
+
* @module utils/theme/animation
|
|
28
|
+
* @author Art Design Pro Team
|
|
29
|
+
*/
|
|
30
|
+
import { useCommon } from '@/hooks/core/useCommon'
|
|
31
|
+
import { useTheme } from '@/hooks/core/useTheme'
|
|
32
|
+
import { SystemThemeEnum } from '@/enums/appEnum'
|
|
33
|
+
import { useSettingStore } from '@/store/modules/setting'
|
|
34
|
+
const { LIGHT, DARK } = SystemThemeEnum
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 主题切换动画
|
|
38
|
+
* @param e 鼠标点击事件
|
|
39
|
+
*/
|
|
40
|
+
export const themeAnimation = (e: any) => {
|
|
41
|
+
const x = e.clientX
|
|
42
|
+
const y = e.clientY
|
|
43
|
+
// 计算鼠标点击位置距离视窗的最大圆半径
|
|
44
|
+
const endRadius = Math.hypot(Math.max(x, innerWidth - x), Math.max(y, innerHeight - y))
|
|
45
|
+
|
|
46
|
+
// 设置CSS变量
|
|
47
|
+
document.documentElement.style.setProperty('--x', x + 'px')
|
|
48
|
+
document.documentElement.style.setProperty('--y', y + 'px')
|
|
49
|
+
document.documentElement.style.setProperty('--r', endRadius + 'px')
|
|
50
|
+
|
|
51
|
+
if (document.startViewTransition) {
|
|
52
|
+
document.startViewTransition(() => toggleTheme())
|
|
53
|
+
} else {
|
|
54
|
+
toggleTheme()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 切换主题
|
|
60
|
+
*/
|
|
61
|
+
const toggleTheme = () => {
|
|
62
|
+
useTheme().switchThemeStyles(useSettingStore().systemThemeType === LIGHT ? DARK : LIGHT)
|
|
63
|
+
useCommon().refresh()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 切换主题过渡效果
|
|
68
|
+
* @param enable 是否启用过渡效果
|
|
69
|
+
*/
|
|
70
|
+
export const toggleTransition = (enable: boolean) => {
|
|
71
|
+
const body = document.body
|
|
72
|
+
|
|
73
|
+
if (enable) {
|
|
74
|
+
body.classList.add('theme-change')
|
|
75
|
+
} else {
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
body.classList.remove('theme-change')
|
|
78
|
+
}, 300)
|
|
79
|
+
}
|
|
80
|
+
}
|