@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevairy/template",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Project template consumed by @kevairy/cli",
5
5
  "keywords": [
6
6
  "vue",
package/template/.env CHANGED
@@ -18,5 +18,9 @@ VITE_WITH_CREDENTIALS = false
18
18
  # Authorization 头前缀;接入业务后端时可按约定设置为 Bearer 等值。
19
19
  VITE_AUTH_SCHEME =
20
20
 
21
+ # 网络类错误(超时/5xx)的最大重试次数,默认 0(不重试)。
22
+ # 注意:POST 等非幂等请求重试有重复提交风险,开启前请确认后端幂等性。
23
+ VITE_HTTP_MAX_RETRIES = 0
24
+
21
25
  # 是否打开路由信息
22
26
  VITE_OPEN_ROUTE_INFO = false
@@ -1,3 +1,5 @@
1
1
  **/node_modules/*
2
2
  **/dist/*
3
3
  **/src/main.ts
4
+ # 建行对接父页面演示工具为独立 vendored 文件,保持与源仓库一致,不纳入 prettier 重排
5
+ **/public/ccb-parent-demo.html
@@ -6,7 +6,7 @@ dist-ssr
6
6
  *.local
7
7
  .tmp-audit/
8
8
  .cursorrules
9
- local-docs/
9
+ .pnpm-store/
10
10
 
11
11
  # Auto-generated files
12
12
  **/src/types/import/auto-imports.d.ts
@@ -18,3 +18,6 @@ test-results
18
18
  playwright-report
19
19
  coverage
20
20
  **/.vitepress/cache
21
+
22
+ # Local docs (never tracked by git)
23
+ local-docs/
@@ -18,6 +18,7 @@
18
18
  "@wangeditor/editor": "5.1.23",
19
19
  "@wangeditor/editor-for-vue": "5.1.12",
20
20
  "axios": "1.19.0",
21
+ "driver.js": "1.9.0",
21
22
  "echarts": "6.1.0",
22
23
  "element-plus": "2.14.4",
23
24
  "file-saver": "2.0.5",
@@ -52,6 +53,15 @@
52
53
  "stylelint-config-standard": "40.0.0",
53
54
  "stylelint-order": "8.1.1",
54
55
  "typescript-eslint": "8.67.0",
56
+ "@iconify-json/fluent": "1.2.59",
57
+ "@iconify-json/icon-park-outline": "1.2.4",
58
+ "@iconify-json/iconamoon": "1.2.2",
59
+ "@iconify-json/ix": "1.2.13",
60
+ "@iconify-json/ri": "1.2.10",
61
+ "@iconify-json/solar": "1.2.13",
62
+ "@iconify-json/system-uicons": "1.2.4",
63
+ "@iconify-json/vaadin": "1.2.1",
64
+ "@iconify/utils": "3.1.7",
55
65
  "@playwright/test": "1.62.1",
56
66
  "@types/node": "24.13.3",
57
67
  "@vitejs/plugin-vue": "6.0.8",
@@ -0,0 +1,84 @@
1
+ /**
2
+ * 离线图标生成脚本
3
+ *
4
+ * 扫描 src 下所有 Iconify 图标名,对“非全量注册”的图标集(ri 以外)按实际用到的
5
+ * 图标精确提取,生成精简的 offline-icons.json,供 iconify-loader 在内网 / 离线环境
6
+ * 下注册,避免运行时从 CDN 拉取图标数据。
7
+ *
8
+ * - ri(Remix Icon):在 iconify-loader 中全量注册,覆盖动态菜单图标,无需在此提取
9
+ * - 其余图标集:仅提取项目实际用到的图标,体积极小(几 KB)
10
+ *
11
+ * 何时重新运行:当新增 / 修改了“非 ri 图标集”的图标时,执行 `pnpm gen:icons` 更新。
12
+ * 新增图标前需先安装对应图标集:`pnpm add -D @iconify-json/<prefix>`
13
+ *
14
+ * @module scripts/gen-offline-icons
15
+ */
16
+ import { readdirSync, readFileSync, writeFileSync, statSync } from 'node:fs'
17
+ import { createRequire } from 'node:module'
18
+ import path from 'node:path'
19
+ import { fileURLToPath } from 'node:url'
20
+ import { getIcons } from '@iconify/utils'
21
+
22
+ const require = createRequire(import.meta.url)
23
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
24
+ const SRC_DIR = path.resolve(__dirname, '../src')
25
+ const OUT_FILE = path.resolve(SRC_DIR, 'utils/ui/offline-icons.json')
26
+
27
+ /** 全量注册的图标集,无需精确提取 */
28
+ const FULL_COLLECTIONS = new Set(['ri'])
29
+
30
+ /** 匹配 Iconify 图标名 "prefix:name" */
31
+ const ICON_RE = /["'`]([a-z][a-z0-9]*(?:-[a-z0-9]+)*):([a-z0-9]+(?:-[a-z0-9]+)*)["'`]/g
32
+ const SOURCE_EXT = /\.(vue|ts|tsx|js|mjs)$/
33
+
34
+ /** @type {Map<string, Set<string>>} */
35
+ const usedIcons = new Map()
36
+
37
+ function scanDir(dir) {
38
+ for (const entry of readdirSync(dir)) {
39
+ if (entry === 'node_modules') continue
40
+ const full = path.join(dir, entry)
41
+ if (statSync(full).isDirectory()) {
42
+ scanDir(full)
43
+ } else if (SOURCE_EXT.test(entry)) {
44
+ const content = readFileSync(full, 'utf8')
45
+ for (const m of content.matchAll(ICON_RE)) {
46
+ const [, prefix, name] = m
47
+ if (FULL_COLLECTIONS.has(prefix)) continue
48
+ if (!usedIcons.has(prefix)) usedIcons.set(prefix, new Set())
49
+ usedIcons.get(prefix).add(name)
50
+ }
51
+ }
52
+ }
53
+ }
54
+
55
+ scanDir(SRC_DIR)
56
+
57
+ const collections = []
58
+ const extracted = []
59
+ const skipped = []
60
+
61
+ for (const [prefix, names] of [...usedIcons].sort()) {
62
+ let data
63
+ try {
64
+ data = require(`@iconify-json/${prefix}/icons.json`)
65
+ } catch {
66
+ // 无对应图标集包:多为 tailwind 变体(hover:/dark:)、v-model(update:)等误匹配,跳过
67
+ skipped.push(prefix)
68
+ continue
69
+ }
70
+ const subset = getIcons(data, [...names])
71
+ if (subset) {
72
+ collections.push(subset)
73
+ extracted.push(`${prefix} → ${[...names].join(', ')}`)
74
+ }
75
+ }
76
+
77
+ writeFileSync(OUT_FILE, JSON.stringify(collections, null, 2) + '\n', 'utf8')
78
+
79
+ console.log(`[gen-offline-icons] 已提取 ${extracted.length} 个图标集:`)
80
+ for (const item of extracted) console.log(` ✓ ${item}`)
81
+ if (skipped.length) {
82
+ console.log(`[gen-offline-icons] 跳过 ${skipped.length} 个非图标前缀(tailwind 变体 / 误匹配)`)
83
+ }
84
+ console.log(`[gen-offline-icons] 输出 → ${path.relative(process.cwd(), OUT_FILE)}`)
@@ -174,11 +174,6 @@
174
174
  const onCreateEditor = (editor: IDomEditor) => {
175
175
  editorRef.value = editor
176
176
 
177
- // 监听全屏事件
178
- editor.on('fullScreen', () => {
179
- console.log('编辑器进入全屏模式')
180
- })
181
-
182
177
  // 确保在编辑器创建后应用自定义图标
183
178
  applyCustomIcons()
184
179
  }
@@ -0,0 +1,123 @@
1
+ <!-- 新手引导 -->
2
+ <template>
3
+ <!-- 引导弹窗由 driver.js 命令式渲染到 body,本组件无可见输出,
4
+ 仅承载启动/销毁生命周期与全局样式,故根节点恒不渲染 -->
5
+ <span v-if="false" />
6
+ </template>
7
+
8
+ <script setup lang="ts">
9
+ import 'driver.js/dist/driver.css'
10
+ import { useGuide } from '@/hooks/core/useGuide'
11
+ import { useSettingStore } from '@/store/modules/setting'
12
+ import { mittBus } from '@/utils/sys'
13
+ import AppConfig from '@/config'
14
+
15
+ defineOptions({ name: 'ArtGuide' })
16
+
17
+ const settingStore = useSettingStore()
18
+ const { start, destroy } = useGuide()
19
+
20
+ onMounted(() => {
21
+ // 用户菜单「新手引导」入口:手动重新播放
22
+ mittBus.on('startGuide', start)
23
+
24
+ // 首次进入且功能开启时自动播放;延迟等待顶栏各按钮渲染完成
25
+ if (AppConfig.features.guide && !settingStore.hasCompletedGuide) {
26
+ nextTick(() => {
27
+ setTimeout(start, 600)
28
+ })
29
+ }
30
+ })
31
+
32
+ onUnmounted(() => {
33
+ mittBus.off('startGuide', start)
34
+ destroy()
35
+ })
36
+ </script>
37
+
38
+ <style>
39
+ /* driver.js 将弹窗挂载到 body 下,需使用全局样式并适配明暗主题。
40
+ 所有覆盖选择器均为 (0,2,0) 权重,高于 driver.css 默认的 (0,1,0),
41
+ 且不依赖样式加载顺序即可生效。 */
42
+
43
+ /* 弹窗容器:背景/文字/边框跟随主题变量自动切换 */
44
+ .driver-popover.art-guide-popover {
45
+ max-width: 320px;
46
+ background-color: var(--default-box-color);
47
+ border: 1px solid var(--default-border);
48
+ border-radius: 8px;
49
+ box-shadow: 0 6px 24px rgb(0 0 0 / 12%);
50
+ }
51
+
52
+ .art-guide-popover .driver-popover-title {
53
+ font-size: 16px;
54
+ color: var(--art-gray-900);
55
+ }
56
+
57
+ .art-guide-popover .driver-popover-description {
58
+ font-size: 13px;
59
+ line-height: 1.6;
60
+ color: var(--art-gray-600);
61
+ }
62
+
63
+ .art-guide-popover .driver-popover-progress-text {
64
+ font-size: 12px;
65
+ color: var(--art-gray-500);
66
+ }
67
+
68
+ /* 关闭按钮 */
69
+ .art-guide-popover .driver-popover-close-btn {
70
+ color: var(--art-gray-500);
71
+ }
72
+
73
+ .art-guide-popover .driver-popover-close-btn:hover,
74
+ .art-guide-popover .driver-popover-close-btn:focus {
75
+ color: var(--art-gray-900);
76
+ }
77
+
78
+ /* 底部按钮:上一步为描边,下一步/开始使用为主题色 */
79
+ .art-guide-popover .driver-popover-footer-btn {
80
+ padding: 5px 12px;
81
+ color: var(--art-gray-700);
82
+ background-color: var(--default-box-color);
83
+ border: 1px solid var(--default-border);
84
+ border-radius: 6px;
85
+ }
86
+
87
+ .art-guide-popover .driver-popover-footer-btn:hover,
88
+ .art-guide-popover .driver-popover-footer-btn:focus {
89
+ background-color: var(--art-gray-200);
90
+ }
91
+
92
+ .art-guide-popover .driver-popover-next-btn,
93
+ .art-guide-popover .driver-popover-done-btn {
94
+ color: #fff;
95
+ background-color: var(--el-color-primary);
96
+ border-color: var(--el-color-primary);
97
+ }
98
+
99
+ .art-guide-popover .driver-popover-next-btn:hover,
100
+ .art-guide-popover .driver-popover-next-btn:focus,
101
+ .art-guide-popover .driver-popover-done-btn:hover,
102
+ .art-guide-popover .driver-popover-done-btn:focus {
103
+ background-color: var(--el-color-primary-light-3);
104
+ border-color: var(--el-color-primary-light-3);
105
+ }
106
+
107
+ /* 箭头:跟随容器背景色(每个方位仅一条可见边框) */
108
+ .art-guide-popover .driver-popover-arrow-side-bottom {
109
+ border-bottom-color: var(--default-box-color);
110
+ }
111
+
112
+ .art-guide-popover .driver-popover-arrow-side-top {
113
+ border-top-color: var(--default-box-color);
114
+ }
115
+
116
+ .art-guide-popover .driver-popover-arrow-side-left {
117
+ border-left-color: var(--default-box-color);
118
+ }
119
+
120
+ .art-guide-popover .driver-popover-arrow-side-right {
121
+ border-right-color: var(--default-box-color);
122
+ }
123
+ </style>
@@ -64,7 +64,7 @@
64
64
  <!-- 搜索 -->
65
65
  <div
66
66
  v-if="shouldShowGlobalSearch"
67
- class="flex-cb w-40 h-9 px-2.5 c-p border border-g-400 rounded-custom-sm max-md:!hidden"
67
+ class="global-search-entry flex-cb w-40 h-9 px-2.5 c-p border border-g-400 rounded-custom-sm max-md:!hidden"
68
68
  @click="openSearchDialog"
69
69
  >
70
70
  <div class="flex-c">
@@ -83,7 +83,7 @@
83
83
  v-if="shouldShowFullscreen"
84
84
  :icon="isFullscreen ? 'ri:fullscreen-exit-line' : 'ri:fullscreen-fill'"
85
85
  :class="[!isFullscreen ? 'full-screen-btn' : 'exit-full-screen-btn', 'ml-3']"
86
- class="max-md:!hidden"
86
+ class="fullscreen-entry max-md:!hidden"
87
87
  @click="toggleFullScreen"
88
88
  />
89
89
 
@@ -130,31 +130,29 @@
130
130
  </ArtIconButton>
131
131
 
132
132
  <!-- 设置按钮 -->
133
- <div v-if="shouldShowSettings">
134
- <ElPopover :visible="showSettingGuide" placement="bottom-start" :width="190" :offset="0">
135
- <template #reference>
136
- <div class="flex-cc">
137
- <ArtIconButton icon="ri:settings-line" class="setting-btn" @click="openSetting" />
138
- </div>
139
- </template>
140
- <template #default>
141
- <p
142
- >{{ $t('topBar.guide.title')
143
- }}<span :style="{ color: systemThemeColor }"> {{ $t('topBar.guide.theme') }} </span
144
- >、 <span :style="{ color: systemThemeColor }"> {{ $t('topBar.guide.menu') }} </span
145
- >{{ $t('topBar.guide.description') }}
146
- </p>
147
- </template>
148
- </ElPopover>
149
- </div>
133
+ <ArtIconButton
134
+ v-if="shouldShowSettings"
135
+ icon="ri:settings-line"
136
+ class="setting-btn"
137
+ @click="openSetting"
138
+ />
150
139
 
151
140
  <!-- 主题切换按钮 -->
152
141
  <ArtIconButton
153
142
  v-if="shouldShowThemeToggle"
143
+ class="theme-toggle-btn"
154
144
  @click="themeAnimation"
155
145
  :icon="isDark ? 'ri:sun-fill' : 'ri:moon-line'"
156
146
  />
157
147
 
148
+ <!-- 锁屏按钮 -->
149
+ <ArtIconButton
150
+ v-if="shouldShowScreenLock"
151
+ icon="ri:lock-line"
152
+ class="screen-lock-btn"
153
+ @click="openLockScreen"
154
+ />
155
+
158
156
  <!-- 用户头像、菜单 -->
159
157
  <ArtUserMenu />
160
158
  </div>
@@ -210,11 +208,11 @@
210
208
  shouldShowLanguage,
211
209
  shouldShowSettings,
212
210
  shouldShowThemeToggle,
211
+ shouldShowScreenLock,
213
212
  fastEnterMinWidth: headerBarFastEnterMinWidth
214
213
  } = useHeaderBar()
215
214
 
216
- const { menuOpen, systemThemeColor, showSettingGuide, menuType, isDark, tabStyle } =
217
- storeToRefs(settingStore)
215
+ const { menuOpen, menuType, isDark, tabStyle } = storeToRefs(settingStore)
218
216
 
219
217
  const { language } = storeToRefs(userStore)
220
218
  const { menuList } = storeToRefs(menuStore)
@@ -296,11 +294,6 @@
296
294
  */
297
295
  const openSetting = (): void => {
298
296
  mittBus.emit('openSetting')
299
-
300
- // 隐藏设置引导提示
301
- if (showSettingGuide.value) {
302
- settingStore.hideSettingGuide()
303
- }
304
297
  }
305
298
 
306
299
  /**
@@ -341,6 +334,13 @@
341
334
  const openChat = (): void => {
342
335
  mittBus.emit('openChat')
343
336
  }
337
+
338
+ /**
339
+ * 打开锁屏界面
340
+ */
341
+ const openLockScreen = (): void => {
342
+ mittBus.emit('openLockScreen')
343
+ }
344
344
  </script>
345
345
 
346
346
  <style lang="scss" scoped>
@@ -13,7 +13,7 @@
13
13
  >
14
14
  <template #reference>
15
15
  <img
16
- class="size-8.5 mr-5 c-p rounded-full max-sm:w-6.5 max-sm:h-6.5 max-sm:mr-[16px]"
16
+ class="user-menu-avatar size-8.5 mr-5 c-p rounded-full max-sm:w-6.5 max-sm:h-6.5 max-sm:mr-[16px]"
17
17
  :src="userInfo.avatar || AppConfig.assets.defaultAvatar"
18
18
  :alt="userInfo.userName || '用户头像'"
19
19
  />
@@ -34,6 +34,10 @@
34
34
  </div>
35
35
  </div>
36
36
  <ul class="py-4 mt-3 border-t border-g-300/80">
37
+ <div class="btn-item c-p" @click="openGuide">
38
+ <ArtSvgIcon icon="ri:guide-line" />
39
+ <span>{{ $t('topBar.user.guide') }}</span>
40
+ </div>
37
41
  <div class="log-out c-p" @click="loginOut">
38
42
  {{ $t('topBar.user.logout') }}
39
43
  </div>
@@ -48,6 +52,7 @@
48
52
  import { ElMessageBox } from 'element-plus'
49
53
  import { useUserStore } from '@/store/modules/user'
50
54
  import { signOut } from '@/services/auth'
55
+ import { mittBus } from '@/utils/sys'
51
56
  import AppConfig from '@/config'
52
57
 
53
58
  defineOptions({ name: 'ArtUserMenu' })
@@ -58,6 +63,17 @@
58
63
  const { getUserInfo: userInfo } = storeToRefs(userStore)
59
64
  const userMenuPopover = ref()
60
65
 
66
+ /**
67
+ * 打开新手引导
68
+ * 先关闭用户菜单,再触发引导,避免弹层遮挡高亮区域
69
+ */
70
+ const openGuide = (): void => {
71
+ closeUserMenu()
72
+ setTimeout(() => {
73
+ mittBus.emit('startGuide')
74
+ }, 200)
75
+ }
76
+
61
77
  /**
62
78
  * 用户登出确认
63
79
  */