@kevairy/template 0.1.2 → 0.1.3

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.
Files changed (40) hide show
  1. package/package.json +1 -1
  2. package/template/.env +4 -0
  3. package/template/.prettierignore +2 -0
  4. package/template/_gitignore +4 -1
  5. package/template/package.json +10 -0
  6. package/template/scripts/gen-offline-icons.mjs +84 -0
  7. package/template/src/components/core/forms/art-wang-editor/index.vue +0 -5
  8. package/template/src/components/core/layouts/art-guide/index.vue +123 -0
  9. package/template/src/components/core/layouts/art-header-bar/index.vue +26 -26
  10. package/template/src/components/core/layouts/art-header-bar/widget/ArtUserMenu.vue +17 -1
  11. package/template/src/components/core/layouts/art-screen-lock/index.vue +325 -0
  12. package/template/src/components/core/layouts/art-settings-panel/widget/SettingActions.vue +0 -1
  13. package/template/src/components/core/media/art-cutter-img/index.vue +0 -1
  14. package/template/src/components/core/media/art-video-player/index.vue +0 -10
  15. package/template/src/config/index.ts +4 -1
  16. package/template/src/config/modules/component.ts +14 -0
  17. package/template/src/config/modules/guide.ts +122 -0
  18. package/template/src/config/modules/headerBar.ts +4 -0
  19. package/template/src/config/setting.ts +2 -2
  20. package/template/src/hooks/core/useGuide.ts +116 -0
  21. package/template/src/hooks/core/useHeaderBar.ts +6 -0
  22. package/template/src/locales/index.ts +0 -1
  23. package/template/src/locales/langs/en.json +66 -5
  24. package/template/src/locales/langs/zh.json +66 -5
  25. package/template/src/main.ts +2 -0
  26. package/template/src/store/modules/lock.ts +125 -0
  27. package/template/src/store/modules/setting.ts +8 -15
  28. package/template/src/store/modules/user.ts +3 -0
  29. package/template/src/types/config/index.ts +4 -0
  30. package/template/src/types/import/components.d.ts +2 -0
  31. package/template/src/utils/http/index.ts +3 -1
  32. package/template/src/utils/socket/index.ts +27 -2
  33. package/template/src/utils/sys/mittBus.ts +5 -0
  34. package/template/src/utils/ui/iconify-loader.ts +32 -18
  35. package/template/src/utils/ui/offline-icons.json +77 -0
  36. package/template/src/views/examples/search-table/index.vue +2 -3
  37. package/template/tests/e2e/auth.spec.ts +24 -6
  38. package/template/tests/e2e/helpers/guide.ts +9 -0
  39. package/template/tests/e2e/search-table.spec.ts +2 -0
  40. package/template/vite.config.ts +3 -0
@@ -22,13 +22,74 @@
22
22
  "userCenter": "User center",
23
23
  "docs": "Document",
24
24
  "github": "Github",
25
+ "lockScreen": "Lock screen",
26
+ "guide": "Guide",
25
27
  "logout": "Log out"
28
+ }
29
+ },
30
+ "lockScreen": {
31
+ "locked": "Screen Locked",
32
+ "setPasswordTitle": "Set Lock Password",
33
+ "setPasswordTip": "First time using screen lock, please set an independent unlock password",
34
+ "passwordPlaceholder": "Enter lock password",
35
+ "newPasswordPlaceholder": "Set lock password",
36
+ "confirmPasswordPlaceholder": "Re-enter password",
37
+ "unlock": "Unlock",
38
+ "confirm": "Confirm",
39
+ "passwordRequired": "Please enter password",
40
+ "passwordMismatch": "Passwords do not match",
41
+ "wrongPassword": "Incorrect password, please try again",
42
+ "setSuccess": "Lock password set successfully",
43
+ "unlockSuccess": "Unlocked",
44
+ "switchAccount": "Switch account",
45
+ "enterToUnlock": "Press Enter to unlock"
46
+ },
47
+ "guide": {
48
+ "buttons": {
49
+ "prev": "Previous",
50
+ "next": "Next",
51
+ "done": "Get Started",
52
+ "close": "Skip"
53
+ },
54
+ "welcome": {
55
+ "title": "Welcome",
56
+ "desc": "Take a minute to learn the core features in the top bar. You can replay this guide anytime from the avatar menu."
57
+ },
58
+ "search": {
59
+ "title": "Global Search",
60
+ "desc": "Quickly search menus and pages. Shortcut: Ctrl/Cmd + K."
61
+ },
62
+ "fullscreen": {
63
+ "title": "Fullscreen",
64
+ "desc": "Enter or exit browser fullscreen for more workspace."
65
+ },
66
+ "language": {
67
+ "title": "Language",
68
+ "desc": "Switch between interface languages."
69
+ },
70
+ "notification": {
71
+ "title": "Notifications",
72
+ "desc": "View system notifications and messages."
73
+ },
74
+ "chat": {
75
+ "title": "Chat",
76
+ "desc": "Open the chat window for real-time communication."
77
+ },
78
+ "settings": {
79
+ "title": "Settings",
80
+ "desc": "Customize theme, menu layout and interface preferences."
81
+ },
82
+ "theme": {
83
+ "title": "Theme Toggle",
84
+ "desc": "Quickly switch between light and dark themes."
85
+ },
86
+ "lock": {
87
+ "title": "Screen Lock",
88
+ "desc": "Lock the screen for privacy, unlock with an independent password."
26
89
  },
27
- "guide": {
28
- "title": "Click here to view",
29
- "theme": "Theme style",
30
- "menu": "Open top menu",
31
- "description": "More configurations"
90
+ "userMenu": {
91
+ "title": "User Menu",
92
+ "desc": "View your profile, replay the guide, or log out."
32
93
  }
33
94
  },
34
95
  "common": {
@@ -22,13 +22,74 @@
22
22
  "userCenter": "个人中心",
23
23
  "docs": "使用文档",
24
24
  "github": "Github",
25
+ "lockScreen": "锁屏",
26
+ "guide": "新手引导",
25
27
  "logout": "退出登录"
28
+ }
29
+ },
30
+ "lockScreen": {
31
+ "locked": "屏幕已锁定",
32
+ "setPasswordTitle": "设置锁屏密码",
33
+ "setPasswordTip": "首次使用锁屏,请设置一个独立的解锁密码",
34
+ "passwordPlaceholder": "请输入锁屏密码",
35
+ "newPasswordPlaceholder": "请设置锁屏密码",
36
+ "confirmPasswordPlaceholder": "请再次输入密码",
37
+ "unlock": "解锁",
38
+ "confirm": "确认设置",
39
+ "passwordRequired": "请输入密码",
40
+ "passwordMismatch": "两次输入的密码不一致",
41
+ "wrongPassword": "密码错误,请重新输入",
42
+ "setSuccess": "锁屏密码设置成功",
43
+ "unlockSuccess": "已解锁",
44
+ "switchAccount": "切换账号",
45
+ "enterToUnlock": "按 Enter 键解锁"
46
+ },
47
+ "guide": {
48
+ "buttons": {
49
+ "prev": "上一步",
50
+ "next": "下一步",
51
+ "done": "开始使用",
52
+ "close": "跳过"
53
+ },
54
+ "welcome": {
55
+ "title": "欢迎使用",
56
+ "desc": "花一分钟了解顶栏的核心功能,随时可从右上角头像菜单重新查看。"
57
+ },
58
+ "search": {
59
+ "title": "全局搜索",
60
+ "desc": "快速搜索菜单与页面,支持快捷键 Ctrl/Cmd + K。"
61
+ },
62
+ "fullscreen": {
63
+ "title": "全屏模式",
64
+ "desc": "一键进入或退出浏览器全屏,获得更大的操作空间。"
65
+ },
66
+ "language": {
67
+ "title": "语言切换",
68
+ "desc": "在多种界面语言之间切换。"
69
+ },
70
+ "notification": {
71
+ "title": "通知中心",
72
+ "desc": "查看系统通知与消息提醒。"
73
+ },
74
+ "chat": {
75
+ "title": "消息聊天",
76
+ "desc": "打开聊天窗口,进行实时沟通。"
77
+ },
78
+ "settings": {
79
+ "title": "系统设置",
80
+ "desc": "自定义主题、菜单布局与界面显示等偏好。"
81
+ },
82
+ "theme": {
83
+ "title": "主题切换",
84
+ "desc": "在明亮与暗色主题之间快速切换。"
85
+ },
86
+ "lock": {
87
+ "title": "锁屏",
88
+ "desc": "锁定屏幕保护隐私,使用独立密码解锁。"
26
89
  },
27
- "guide": {
28
- "title": "点击这里查看",
29
- "theme": "主题风格",
30
- "menu": "开启顶栏菜单",
31
- "description": "等更多配置"
90
+ "userMenu": {
91
+ "title": "用户菜单",
92
+ "desc": "查看个人信息、重新观看引导或退出登录。"
32
93
  }
33
94
  },
34
95
  "common": {
@@ -11,8 +11,10 @@ import '@utils/sys/console.ts' // 控制台输出内容
11
11
  import { setupGlobDirectives } from './directives'
12
12
  import { setupErrorHandle } from './utils/sys/error-handle'
13
13
  import { initializeApp } from './bootstrap/initializeApp'
14
+ import { setupOfflineIcons } from '@utils/ui/iconify-loader' // 离线图标集(内网可用)
14
15
 
15
16
  initializeApp()
17
+ setupOfflineIcons()
16
18
 
17
19
  const app = createApp(App)
18
20
  initStore(app)
@@ -0,0 +1,125 @@
1
+ /**
2
+ * 锁屏状态管理模块
3
+ *
4
+ * 管理锁屏的锁定状态与「独立锁屏密码」。
5
+ *
6
+ * ## 主要功能
7
+ *
8
+ * - 锁定 / 解锁状态管理
9
+ * - 独立锁屏密码的设置与校验(与登录密码无关)
10
+ * - 密码以哈希形式本地存储,避免明文落盘
11
+ *
12
+ * ## 使用场景
13
+ *
14
+ * - 顶栏锁屏按钮触发锁定
15
+ * - 锁屏界面校验密码后解锁
16
+ * - 退出登录时解除锁定状态
17
+ *
18
+ * ## 持久化
19
+ *
20
+ * - 使用 localStorage 存储
21
+ * - 存储键:sys-v{version}-lock
22
+ * - 持久化 isLocked 与 passwordHash,刷新页面后仍保持锁定
23
+ *
24
+ * @module store/modules/lock
25
+ * @author Art Design Pro Team
26
+ */
27
+ import { defineStore } from 'pinia'
28
+ import { ref, computed } from 'vue'
29
+
30
+ /**
31
+ * 对锁屏密码做哈希,避免明文存储。
32
+ * 优先使用 Web Crypto 的 SHA-256;在不支持的安全上下文下降级为 FNV-1a。
33
+ * @param password 明文密码
34
+ * @returns 哈希字符串
35
+ */
36
+ async function hashPassword(password: string): Promise<string> {
37
+ try {
38
+ if (globalThis.crypto?.subtle) {
39
+ const data = new TextEncoder().encode(password)
40
+ const digest = await crypto.subtle.digest('SHA-256', data)
41
+ return Array.from(new Uint8Array(digest))
42
+ .map((byte) => byte.toString(16).padStart(2, '0'))
43
+ .join('')
44
+ }
45
+ } catch {
46
+ // 忽略异常,走降级方案
47
+ }
48
+
49
+ // 降级:FNV-1a 32 位哈希(仅用于不支持 Web Crypto 的环境)
50
+ let hash = 0x811c9dc5
51
+ for (let i = 0; i < password.length; i++) {
52
+ hash ^= password.charCodeAt(i)
53
+ hash = Math.imul(hash, 0x01000193) >>> 0
54
+ }
55
+ return `fnv-${hash.toString(16)}`
56
+ }
57
+
58
+ /**
59
+ * 锁屏状态管理
60
+ * 管理锁定状态与独立锁屏密码
61
+ */
62
+ export const useLockStore = defineStore(
63
+ 'lockStore',
64
+ () => {
65
+ /** 是否处于锁定状态 */
66
+ const isLocked = ref(false)
67
+ /** 锁屏密码哈希(独立于登录密码,仅本地存储) */
68
+ const passwordHash = ref('')
69
+
70
+ /** 是否已设置锁屏密码 */
71
+ const hasPassword = computed(() => Boolean(passwordHash.value))
72
+
73
+ /** 进入锁定状态 */
74
+ const lock = () => {
75
+ isLocked.value = true
76
+ }
77
+
78
+ /** 解除锁定状态(保留已设置的密码) */
79
+ const unlock = () => {
80
+ isLocked.value = false
81
+ }
82
+
83
+ /**
84
+ * 设置锁屏密码(存储哈希)
85
+ * @param password 明文密码
86
+ */
87
+ const setPassword = async (password: string) => {
88
+ passwordHash.value = await hashPassword(password)
89
+ }
90
+
91
+ /**
92
+ * 校验解锁密码是否正确
93
+ * @param password 待校验的明文密码
94
+ * @returns 是否匹配
95
+ */
96
+ const verifyPassword = async (password: string): Promise<boolean> => {
97
+ if (!passwordHash.value) return false
98
+ return (await hashPassword(password)) === passwordHash.value
99
+ }
100
+
101
+ /** 清空锁屏状态与密码 */
102
+ const reset = () => {
103
+ isLocked.value = false
104
+ passwordHash.value = ''
105
+ }
106
+
107
+ return {
108
+ isLocked,
109
+ passwordHash,
110
+ hasPassword,
111
+ lock,
112
+ unlock,
113
+ setPassword,
114
+ verifyPassword,
115
+ reset
116
+ }
117
+ },
118
+ {
119
+ persist: {
120
+ key: 'lock',
121
+ storage: localStorage,
122
+ pick: ['isLocked', 'passwordHash']
123
+ }
124
+ }
125
+ )
@@ -82,8 +82,6 @@ export const useSettingStore = defineStore(
82
82
  const showLanguage = ref(SETTING_DEFAULT_CONFIG.showLanguage)
83
83
  /** 是否显示进度条 */
84
84
  const showNprogress = ref(SETTING_DEFAULT_CONFIG.showNprogress)
85
- /** 是否显示设置引导 */
86
- const showSettingGuide = ref(SETTING_DEFAULT_CONFIG.showSettingGuide)
87
85
  /** 是否显示节日文本 */
88
86
  const showFestivalText = ref(SETTING_DEFAULT_CONFIG.showFestivalText)
89
87
  /** 是否显示水印 */
@@ -100,6 +98,8 @@ export const useSettingStore = defineStore(
100
98
  const refresh = ref(SETTING_DEFAULT_CONFIG.refresh)
101
99
  /** 是否加载节日烟花 */
102
100
  const holidayFireworksLoaded = ref(SETTING_DEFAULT_CONFIG.holidayFireworksLoaded)
101
+ /** 新手引导是否已完成(控制首次自动播放) */
102
+ const hasCompletedGuide = ref(SETTING_DEFAULT_CONFIG.hasCompletedGuide)
103
103
 
104
104
  // 样式设置
105
105
  /** 边框模式 */
@@ -290,17 +290,11 @@ export const useSettingStore = defineStore(
290
290
  }
291
291
 
292
292
  /**
293
- * 隐藏设置引导
293
+ * 标记新手引导已完成
294
+ * 首次自动播放结束或用户手动关闭后调用,避免重复自动弹出
294
295
  */
295
- const hideSettingGuide = () => {
296
- showSettingGuide.value = false
297
- }
298
-
299
- /**
300
- * 显示设置引导
301
- */
302
- const openSettingGuide = () => {
303
- showSettingGuide.value = true
296
+ const completeGuide = () => {
297
+ hasCompletedGuide.value = true
304
298
  }
305
299
 
306
300
  /**
@@ -393,7 +387,7 @@ export const useSettingStore = defineStore(
393
387
  showLanguage,
394
388
  showNprogress,
395
389
  colorWeak,
396
- showSettingGuide,
390
+ hasCompletedGuide,
397
391
  pageTransition,
398
392
  tabStyle,
399
393
  menuOpen,
@@ -427,8 +421,7 @@ export const useSettingStore = defineStore(
427
421
  setLanguage,
428
422
  setNprogress,
429
423
  setColorWeak,
430
- hideSettingGuide,
431
- openSettingGuide,
424
+ completeGuide,
432
425
  setPageTransition,
433
426
  setTabStyle,
434
427
  setMenuOpen,
@@ -41,6 +41,7 @@ import { AppRouteRecord } from '@/types/router'
41
41
  import { setPageTitle } from '@/utils/router'
42
42
  import { resetRouterState } from '@/router/guards/beforeEach'
43
43
  import { useMenuStore } from './menu'
44
+ import { useLockStore } from './lock'
44
45
  import { StorageConfig } from '@/utils/storage/storage-config'
45
46
 
46
47
  /**
@@ -143,6 +144,8 @@ export const useUserStore = defineStore(
143
144
  sessionStorage.removeItem('iframeRoutes')
144
145
  // 清空主页路径
145
146
  useMenuStore().setHomePath('')
147
+ // 解除锁屏状态并清除独立锁屏密码,避免下次登录被遗留的锁定态拦截
148
+ useLockStore().reset()
146
149
  // 重置路由状态
147
150
  resetRouterState(500)
148
151
  if (!redirectToLogin) return
@@ -110,6 +110,8 @@ export interface AppFeatureConfig {
110
110
  chat: boolean
111
111
  watermark: boolean
112
112
  festivalEffects: boolean
113
+ screenLock: boolean
114
+ guide: boolean
113
115
  examples: boolean
114
116
  }
115
117
 
@@ -250,4 +252,6 @@ export interface HeaderBarFeatureConfig {
250
252
  settings: FeatureConfigItem
251
253
  /** 主题切换 */
252
254
  themeToggle: FeatureConfigItem
255
+ /** 锁屏功能 */
256
+ screenLock: FeatureConfigItem
253
257
  }
@@ -35,6 +35,7 @@ declare module 'vue' {
35
35
  ArtForm: typeof import('./../../components/core/forms/art-form/index.vue')['default']
36
36
  ArtGlobalComponent: typeof import('./../../components/core/layouts/art-global-component/index.vue')['default']
37
37
  ArtGlobalSearch: typeof import('./../../components/core/layouts/art-global-search/index.vue')['default']
38
+ ArtGuide: typeof import('./../../components/core/layouts/art-guide/index.vue')['default']
38
39
  ArtHBarChart: typeof import('./../../components/core/charts/art-h-bar-chart/index.vue')['default']
39
40
  ArtHeaderBar: typeof import('./../../components/core/layouts/art-header-bar/index.vue')['default']
40
41
  ArtHorizontalMenu: typeof import('./../../components/core/layouts/art-menus/art-horizontal-menu/index.vue')['default']
@@ -54,6 +55,7 @@ declare module 'vue' {
54
55
  ArtResultPage: typeof import('./../../components/core/views/result/ArtResultPage.vue')['default']
55
56
  ArtRingChart: typeof import('./../../components/core/charts/art-ring-chart/index.vue')['default']
56
57
  ArtScatterChart: typeof import('./../../components/core/charts/art-scatter-chart/index.vue')['default']
58
+ ArtScreenLock: typeof import('./../../components/core/layouts/art-screen-lock/index.vue')['default']
57
59
  ArtSettingsPanel: typeof import('./../../components/core/layouts/art-settings-panel/index.vue')['default']
58
60
  ArtSidebarMenu: typeof import('./../../components/core/layouts/art-menus/art-sidebar-menu/index.vue')['default']
59
61
  ArtStatsCard: typeof import('./../../components/core/cards/art-stats-card/index.vue')['default']
@@ -12,7 +12,9 @@ import type { BaseResponse } from '@/types'
12
12
  import { createRequestKey, isApiSuccessCode, normalizeApiCode } from './contract'
13
13
 
14
14
  const REQUEST_TIMEOUT = 15000
15
- const MAX_RETRIES = 0
15
+ // 网络类错误(超时/5xx)的最大重试次数,通过 VITE_HTTP_MAX_RETRIES 配置,默认 0(不重试)。
16
+ // 注意:POST 等非幂等请求重试存在重复提交风险,开启前请确认后端幂等性。
17
+ const MAX_RETRIES = Math.max(0, Math.floor(Number(import.meta.env.VITE_HTTP_MAX_RETRIES) || 0))
16
18
  const RETRY_DELAY = 1000
17
19
  const UNAUTHORIZED_DEBOUNCE_TIME = 3000
18
20
  const REQUEST_CANCELLED_CODE = 499
@@ -1,3 +1,17 @@
1
+ /**
2
+ * WebSocket 客户端(可选工具)
3
+ *
4
+ * 单例封装,内置心跳检测、断线重连(指数退避 + 抖动)、连接超时与离线消息队列。
5
+ *
6
+ * ## 使用说明
7
+ *
8
+ * - 模板默认不接线任何业务实时通道,本工具作为可复用能力导出,业务项目按需引入:
9
+ * `import { WebSocketClient } from '@/utils'`(或默认导出 `@/utils/socket`)。
10
+ * - 连接地址优先取 `getInstance({ url })`,否则回退到环境变量 `VITE_WEBSOCKET_URL`;
11
+ * 两者均未配置时跳过连接,不会抛错。
12
+ *
13
+ * @module utils/socket
14
+ */
1
15
  interface WebSocketOptions {
2
16
  url?: string
3
17
  messageHandler: (event: MessageEvent) => void
@@ -9,7 +23,7 @@ interface WebSocketOptions {
9
23
  connectionTimeout?: number // 连接建立超时时间(ms)
10
24
  }
11
25
 
12
- export default class WebSocketClient {
26
+ export class WebSocketClient {
13
27
  private static instance: WebSocketClient | null = null
14
28
  private ws: WebSocket | null = null
15
29
  private url: string
@@ -39,7 +53,8 @@ export default class WebSocketClient {
39
53
  private isReconnecting: boolean = false
40
54
 
41
55
  private constructor(options: WebSocketOptions) {
42
- this.url = options.url || (process.env.VUE_APP_LOGIN_WEBSOCKET as string)
56
+ // 使用 Vite 环境变量(VITE_ 前缀);模板默认未配置,接入业务时通过 .env 提供 VITE_WEBSOCKET_URL
57
+ this.url = options.url || (import.meta.env.VITE_WEBSOCKET_URL as string) || ''
43
58
  this.messageHandler = options.messageHandler
44
59
  this.reconnectInterval = options.reconnectInterval ?? 20 * 1000 // 默认20秒
45
60
  this.heartbeatInterval = options.heartbeatInterval ?? 5 * 1000 // 默认5秒
@@ -72,6 +87,12 @@ export default class WebSocketClient {
72
87
  }
73
88
 
74
89
  private connect(resetReconnectAttempts: boolean = false): void {
90
+ // 未配置 WebSocket 地址时直接跳过,避免 new WebSocket('') 抛错
91
+ if (!this.url) {
92
+ console.warn('WebSocket 地址未配置(VITE_WEBSOCKET_URL),已跳过连接')
93
+ return
94
+ }
95
+
75
96
  // 如果正在连接中,不重复连接
76
97
  if (this.isConnecting) {
77
98
  console.log('正在建立WebSocket连接中...')
@@ -421,3 +442,7 @@ export default class WebSocketClient {
421
442
  }
422
443
  }
423
444
  }
445
+
446
+ // 同时保留默认导出,兼容 `import WebSocketClient from '@/utils/socket'` 的旧用法;
447
+ // 命名导出使其可经由 `@/utils` 桶文件(export * from './socket')转发。
448
+ export default WebSocketClient
@@ -36,6 +36,8 @@
36
36
  * - openSetting: 打开设置面板
37
37
  * - openSearchDialog: 打开搜索对话框
38
38
  * - openChat: 打开聊天窗口
39
+ * - openLockScreen: 打开锁屏界面
40
+ * - startGuide: 启动新手引导
39
41
  *
40
42
  * @module utils/sys/mittBus
41
43
  * @author Art Design Pro Team
@@ -53,6 +55,9 @@ type Events = {
53
55
  // 打开聊天窗口事件 - 无参数
54
56
  openChat: void
55
57
  // 打开锁屏事件 - 无参数
58
+ openLockScreen: void
59
+ // 启动新手引导事件 - 无参数
60
+ startGuide: void
56
61
  }
57
62
 
58
63
  // 创建类型安全的事件总线实例
@@ -1,31 +1,45 @@
1
1
  /**
2
2
  * 离线图标加载器
3
3
  *
4
- * 用于在内网环境下支持 Iconify 图标的离线加载。
5
- * 通过预加载图标集数据,避免运行时从 CDN 获取图标。
4
+ * 内网 / 离线环境下,Iconify 无法从公共 CDN(api.iconify.design)拉取图标数据,会导致
5
+ * 图标空白。此模块在应用启动时预注册图标集数据,使 <ArtSvgIcon icon="ri:xxx" /> 等用法
6
+ * 完全离线可用。
6
7
  *
7
- * 使用方式:
8
- * 1. 安装所需图标集:pnpm add -D @iconify-json/[icon-set-name]
9
- * 2. 在此文件中导入并注册图标集
10
- * 3. 在组件中使用:<ArtSvgIcon icon="ri:home-line" />
8
+ * 图标集策略(兼顾体积与覆盖):
9
+ * - ri(Remix Icon):全量注册。它是项目主力图标集,菜单 / 路由的动态图标名基本都来自它,
10
+ * 全量注册可让业务后续新增任意 ri 图标都开箱即用(约 1MB,gzip 后 ~280KB)。
11
+ * - 其余图标集:仅注册项目实际用到的图标(由 scripts/gen-offline-icons.mjs 精确提取,几 KB),
12
+ * 避免全量打包(如 fluent / solar 单集达 10MB+)。
13
+ *
14
+ * 新增“非 ri 图标集”图标的步骤:
15
+ * 1. 安装图标集:pnpm add -D @iconify-json/<prefix>
16
+ * 2. 重新生成精简数据:pnpm gen:icons
11
17
  *
12
18
  * @module utils/ui/iconify-loader
13
- * @author Art Design Pro Team
14
19
  */
20
+ import { addCollection, type IconifyJSON } from '@iconify/vue'
15
21
 
16
- // import { addCollection } from '@iconify/vue'
22
+ // 主力图标集:全量数据
23
+ import riIcons from '@iconify-json/ri/icons.json'
24
+ // 其余图标集的精简数据(脚本生成,请勿手动编辑)
25
+ import offlineIcons from './offline-icons.json'
17
26
 
18
- // // 导入离线图标数据
27
+ /** 幂等标记,避免重复注册 */
28
+ let registered = false
19
29
 
20
- // // 系统必要图标库
21
- // import riIcons from '@iconify-json/ri/icons.json'
30
+ /**
31
+ * 注册离线图标集(幂等,重复调用只生效一次)
32
+ */
33
+ export function setupOfflineIcons(): void {
34
+ if (registered) return
22
35
 
23
- // // 演示图标库(可选,生产环境可移除)
24
- // import svgSpinners from '@iconify-json/svg-spinners/icons.json'
25
- // import lineMd from '@iconify-json/line-md/icons.json'
36
+ // 主力图标集:全量注册,覆盖所有菜单动态图标与业务常用图标
37
+ addCollection(riIcons as unknown as IconifyJSON)
26
38
 
27
- // // 注册离线图标集
39
+ // 其余图标集:注册精确提取的子集
40
+ for (const collection of offlineIcons as unknown as IconifyJSON[]) {
41
+ addCollection(collection)
42
+ }
28
43
 
29
- // addCollection(riIcons)
30
- // addCollection(svgSpinners)
31
- // addCollection(lineMd)
44
+ registered = true
45
+ }
@@ -0,0 +1,77 @@
1
+ [
2
+ {
3
+ "prefix": "fluent",
4
+ "icons": {
5
+ "arrow-enter-left-20-filled": {
6
+ "body": "<path fill=\"currentColor\" d=\"m4.641 12.5l2.873 2.704a.75.75 0 0 1-1.028 1.092l-4.25-4a.75.75 0 0 1 0-1.092l4.25-4a.75.75 0 1 1 1.028 1.092L4.641 11H14.75a1.75 1.75 0 0 0 1.75-1.75v-4.5a.75.75 0 0 1 1.5 0v4.5a3.25 3.25 0 0 1-3.25 3.25z\"/>"
7
+ }
8
+ },
9
+ "lastModified": 1790422098,
10
+ "width": 20,
11
+ "height": 20
12
+ },
13
+ {
14
+ "prefix": "icon-park-outline",
15
+ "icons": {
16
+ "auto-width": {
17
+ "body": "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"4\" d=\"M11.988 32L4 24.006L12 16m24.012 0L44 23.994L36 32M4 24h40\"/>"
18
+ }
19
+ },
20
+ "lastModified": 1754899616,
21
+ "width": 48,
22
+ "height": 48
23
+ },
24
+ {
25
+ "prefix": "iconamoon",
26
+ "icons": {
27
+ "arrow-down-2-thin": {
28
+ "body": "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"m7 10l5 5l5-5\"/>"
29
+ }
30
+ },
31
+ "lastModified": 1722794093,
32
+ "width": 24,
33
+ "height": 24
34
+ },
35
+ {
36
+ "prefix": "ix",
37
+ "icons": {
38
+ "width": {
39
+ "body": "<path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M85.333 128H42.667v256h42.666V256l79.085 79.085l30.17-30.17l-27.582-27.582h178.017l-27.583 27.584l30.17 30.17l79.057-79.057V384h42.666V128h-42.666v127.973l-79.057-79.056l-30.17 30.17l27.58 27.58H167.006l27.582-27.582l-30.17-30.17l-79.085 79.084z\" clip-rule=\"evenodd\"/>"
40
+ }
41
+ },
42
+ "lastModified": 1790785405,
43
+ "width": 512,
44
+ "height": 512
45
+ },
46
+ {
47
+ "prefix": "solar",
48
+ "icons": {
49
+ "double-alt-arrow-right-linear": {
50
+ "body": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\"><path d=\"M11 19L17 12L11 5\"/><path d=\"M7 19L13 12L7 5\"/></g>"
51
+ }
52
+ },
53
+ "lastModified": 1790422589,
54
+ "width": 24,
55
+ "height": 24
56
+ },
57
+ {
58
+ "prefix": "system-uicons",
59
+ "icons": {
60
+ "inbox": {
61
+ "body": "<g fill=\"none\" fill-rule=\"evenodd\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6.16 4.5h8.68a1 1 0 0 1 .92.606L18.5 11.5v4a2 2 0 0 1-2 2h-12a2 2 0 0 1-2-2v-4l2.74-6.394a1 1 0 0 1 .92-.606\"/><path d=\"M2.5 11.5h4a1 1 0 0 1 1 1v1a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h4\"/></g>"
62
+ }
63
+ },
64
+ "lastModified": 1754901428,
65
+ "width": 21,
66
+ "height": 21
67
+ },
68
+ {
69
+ "prefix": "vaadin",
70
+ "icons": {
71
+ "ctrl-a": {
72
+ "body": "<path fill=\"currentColor\" d=\"M9 7V6H8V5H7v1h-.5v1H7v3.56a1.823 1.823 0 0 0 2.009 1.439L9 11a.9.9 0 0 1-.998-.495L8 7zm5-4h1v9h-1zm-1 3l-.085-.001c-.773 0-1.462.358-1.911.917L11 6.001h-1v6h1v-3a1.88 1.88 0 0 1 2.006-2l-.006-1zm-8.81 6C2.16 12 1 10.54 1 8s1.16-4 3.19-4h.029c.539 0 1.052.114 1.515.32l-.424.901a2.7 2.7 0 0 0-1.08-.22h-.042C2.38 5.001 2 6.631 2 8.001s.38 3 2.19 3c.497-.013.96-.145 1.366-.368l.444.898a3.94 3.94 0 0 1-1.806.47z\"/>"
73
+ }
74
+ },
75
+ "lastModified": 1722796111
76
+ }
77
+ ]
@@ -27,7 +27,7 @@
27
27
  <template #name="{ row }">
28
28
  <div class="service-name">
29
29
  <span class="service-name__icon" aria-hidden="true">
30
- <ElIcon><Connection /></ElIcon>
30
+ <ArtSvgIcon icon="ri:link" />
31
31
  </span>
32
32
  <div class="service-name__content">
33
33
  <strong>{{ row.name }}</strong>
@@ -51,8 +51,7 @@
51
51
  </template>
52
52
 
53
53
  <script setup lang="ts">
54
- import { Connection } from '@element-plus/icons-vue'
55
- import { ElButton, ElIcon, ElMessage, ElTag } from 'element-plus'
54
+ import { ElButton, ElMessage, ElTag } from 'element-plus'
56
55
  import { KvSearchTablePage } from '@kevairy/components'
57
56
  import { searchItems, statusMeta } from './search.config'
58
57
  import { serviceTableColumns } from './table.config'