@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.
- package/package.json +1 -1
- package/template/.env +4 -0
- package/template/.prettierignore +2 -0
- package/template/_gitignore +4 -1
- package/template/package.json +10 -0
- package/template/scripts/gen-offline-icons.mjs +84 -0
- package/template/src/components/core/forms/art-wang-editor/index.vue +0 -5
- package/template/src/components/core/layouts/art-guide/index.vue +123 -0
- package/template/src/components/core/layouts/art-header-bar/index.vue +26 -26
- package/template/src/components/core/layouts/art-header-bar/widget/ArtUserMenu.vue +17 -1
- package/template/src/components/core/layouts/art-screen-lock/index.vue +325 -0
- package/template/src/components/core/layouts/art-settings-panel/widget/SettingActions.vue +0 -1
- package/template/src/components/core/media/art-cutter-img/index.vue +0 -1
- package/template/src/components/core/media/art-video-player/index.vue +0 -10
- package/template/src/config/index.ts +4 -1
- package/template/src/config/modules/component.ts +14 -0
- package/template/src/config/modules/guide.ts +122 -0
- package/template/src/config/modules/headerBar.ts +4 -0
- package/template/src/config/setting.ts +2 -2
- package/template/src/hooks/core/useGuide.ts +116 -0
- package/template/src/hooks/core/useHeaderBar.ts +6 -0
- package/template/src/locales/index.ts +0 -1
- package/template/src/locales/langs/en.json +66 -5
- package/template/src/locales/langs/zh.json +66 -5
- package/template/src/main.ts +2 -0
- package/template/src/store/modules/lock.ts +125 -0
- package/template/src/store/modules/setting.ts +8 -15
- package/template/src/store/modules/user.ts +3 -0
- package/template/src/types/config/index.ts +4 -0
- package/template/src/types/import/components.d.ts +2 -0
- package/template/src/utils/http/index.ts +3 -1
- package/template/src/utils/socket/index.ts +27 -2
- package/template/src/utils/sys/mittBus.ts +5 -0
- package/template/src/utils/ui/iconify-loader.ts +32 -18
- package/template/src/utils/ui/offline-icons.json +77 -0
- package/template/src/views/examples/search-table/index.vue +2 -3
- package/template/tests/e2e/auth.spec.ts +24 -6
- package/template/tests/e2e/helpers/guide.ts +9 -0
- package/template/tests/e2e/search-table.spec.ts +2 -0
- package/template/vite.config.ts +3 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
<!-- 锁屏 -->
|
|
2
|
+
<template>
|
|
3
|
+
<Transition name="screen-lock-fade">
|
|
4
|
+
<div v-if="lockStore.isLocked" class="screen-lock">
|
|
5
|
+
<!-- 实时时钟 -->
|
|
6
|
+
<div class="screen-lock__clock">
|
|
7
|
+
<div class="screen-lock__time">{{ currentTime }}</div>
|
|
8
|
+
<div class="screen-lock__date">{{ currentDate }}</div>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<!-- 解锁面板 -->
|
|
12
|
+
<div class="screen-lock__panel">
|
|
13
|
+
<ElAvatar
|
|
14
|
+
:size="72"
|
|
15
|
+
:src="userInfo.avatar || AppConfig.assets.defaultAvatar"
|
|
16
|
+
class="screen-lock__avatar"
|
|
17
|
+
/>
|
|
18
|
+
<div class="screen-lock__name">{{ userInfo.userName || 'User' }}</div>
|
|
19
|
+
|
|
20
|
+
<!-- 已设置密码:输入密码解锁 -->
|
|
21
|
+
<template v-if="lockStore.hasPassword">
|
|
22
|
+
<p class="screen-lock__title">{{ $t('lockScreen.locked') }}</p>
|
|
23
|
+
<ElInput
|
|
24
|
+
v-model="password"
|
|
25
|
+
type="password"
|
|
26
|
+
size="large"
|
|
27
|
+
show-password
|
|
28
|
+
:placeholder="$t('lockScreen.passwordPlaceholder')"
|
|
29
|
+
@keyup.enter="handleUnlock"
|
|
30
|
+
/>
|
|
31
|
+
<p v-if="errorText" class="screen-lock__error">{{ errorText }}</p>
|
|
32
|
+
<ElButton
|
|
33
|
+
type="primary"
|
|
34
|
+
size="large"
|
|
35
|
+
class="screen-lock__btn"
|
|
36
|
+
:loading="loading"
|
|
37
|
+
v-ripple
|
|
38
|
+
@click="handleUnlock"
|
|
39
|
+
>
|
|
40
|
+
{{ $t('lockScreen.unlock') }}
|
|
41
|
+
</ElButton>
|
|
42
|
+
<p class="screen-lock__hint">{{ $t('lockScreen.enterToUnlock') }}</p>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<!-- 未设置密码:首次设置独立锁屏密码 -->
|
|
46
|
+
<template v-else>
|
|
47
|
+
<p class="screen-lock__title">{{ $t('lockScreen.setPasswordTitle') }}</p>
|
|
48
|
+
<p class="screen-lock__tip">{{ $t('lockScreen.setPasswordTip') }}</p>
|
|
49
|
+
<ElInput
|
|
50
|
+
v-model="password"
|
|
51
|
+
type="password"
|
|
52
|
+
size="large"
|
|
53
|
+
show-password
|
|
54
|
+
:placeholder="$t('lockScreen.newPasswordPlaceholder')"
|
|
55
|
+
/>
|
|
56
|
+
<ElInput
|
|
57
|
+
v-model="confirmPassword"
|
|
58
|
+
type="password"
|
|
59
|
+
size="large"
|
|
60
|
+
show-password
|
|
61
|
+
class="screen-lock__confirm"
|
|
62
|
+
:placeholder="$t('lockScreen.confirmPasswordPlaceholder')"
|
|
63
|
+
@keyup.enter="handleSetPassword"
|
|
64
|
+
/>
|
|
65
|
+
<p v-if="errorText" class="screen-lock__error">{{ errorText }}</p>
|
|
66
|
+
<ElButton
|
|
67
|
+
type="primary"
|
|
68
|
+
size="large"
|
|
69
|
+
class="screen-lock__btn"
|
|
70
|
+
:loading="loading"
|
|
71
|
+
v-ripple
|
|
72
|
+
@click="handleSetPassword"
|
|
73
|
+
>
|
|
74
|
+
{{ $t('lockScreen.confirm') }}
|
|
75
|
+
</ElButton>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<!-- 切换账号 -->
|
|
79
|
+
<div class="screen-lock__switch" @click="handleSwitchAccount">
|
|
80
|
+
<ArtSvgIcon icon="ri:logout-box-r-line" />
|
|
81
|
+
<span>{{ $t('lockScreen.switchAccount') }}</span>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
</Transition>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script setup lang="ts">
|
|
89
|
+
import { useI18n } from 'vue-i18n'
|
|
90
|
+
import { ElMessage } from 'element-plus'
|
|
91
|
+
import { useNow } from '@vueuse/core'
|
|
92
|
+
import { useLockStore } from '@/store/modules/lock'
|
|
93
|
+
import { useUserStore } from '@/store/modules/user'
|
|
94
|
+
import { signOut } from '@/services/auth'
|
|
95
|
+
import { mittBus } from '@/utils/sys'
|
|
96
|
+
import AppConfig from '@/config'
|
|
97
|
+
|
|
98
|
+
defineOptions({ name: 'ArtScreenLock' })
|
|
99
|
+
|
|
100
|
+
const { t, locale } = useI18n()
|
|
101
|
+
const lockStore = useLockStore()
|
|
102
|
+
const userStore = useUserStore()
|
|
103
|
+
|
|
104
|
+
const userInfo = computed(() => userStore.getUserInfo)
|
|
105
|
+
|
|
106
|
+
const password = ref('')
|
|
107
|
+
const confirmPassword = ref('')
|
|
108
|
+
const errorText = ref('')
|
|
109
|
+
const loading = ref(false)
|
|
110
|
+
|
|
111
|
+
// 实时时钟
|
|
112
|
+
const now = useNow()
|
|
113
|
+
const currentTime = computed(() =>
|
|
114
|
+
now.value.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false })
|
|
115
|
+
)
|
|
116
|
+
const currentDate = computed(() =>
|
|
117
|
+
now.value.toLocaleDateString(locale.value, {
|
|
118
|
+
year: 'numeric',
|
|
119
|
+
month: 'long',
|
|
120
|
+
day: 'numeric',
|
|
121
|
+
weekday: 'long'
|
|
122
|
+
})
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
/** 顶栏触发锁屏:清空输入并进入锁定态 */
|
|
126
|
+
const handleLock = (): void => {
|
|
127
|
+
password.value = ''
|
|
128
|
+
confirmPassword.value = ''
|
|
129
|
+
errorText.value = ''
|
|
130
|
+
lockStore.lock()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** 校验密码并解锁 */
|
|
134
|
+
const handleUnlock = async (): Promise<void> => {
|
|
135
|
+
if (!password.value) {
|
|
136
|
+
errorText.value = t('lockScreen.passwordRequired')
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
loading.value = true
|
|
140
|
+
try {
|
|
141
|
+
const matched = await lockStore.verifyPassword(password.value)
|
|
142
|
+
if (matched) {
|
|
143
|
+
lockStore.unlock()
|
|
144
|
+
password.value = ''
|
|
145
|
+
errorText.value = ''
|
|
146
|
+
ElMessage.success(t('lockScreen.unlockSuccess'))
|
|
147
|
+
} else {
|
|
148
|
+
errorText.value = t('lockScreen.wrongPassword')
|
|
149
|
+
password.value = ''
|
|
150
|
+
}
|
|
151
|
+
} finally {
|
|
152
|
+
loading.value = false
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** 首次设置锁屏密码,成功后直接进入系统 */
|
|
157
|
+
const handleSetPassword = async (): Promise<void> => {
|
|
158
|
+
if (!password.value) {
|
|
159
|
+
errorText.value = t('lockScreen.passwordRequired')
|
|
160
|
+
return
|
|
161
|
+
}
|
|
162
|
+
if (password.value !== confirmPassword.value) {
|
|
163
|
+
errorText.value = t('lockScreen.passwordMismatch')
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
loading.value = true
|
|
167
|
+
try {
|
|
168
|
+
await lockStore.setPassword(password.value)
|
|
169
|
+
lockStore.unlock()
|
|
170
|
+
password.value = ''
|
|
171
|
+
confirmPassword.value = ''
|
|
172
|
+
errorText.value = ''
|
|
173
|
+
ElMessage.success(t('lockScreen.setSuccess'))
|
|
174
|
+
} finally {
|
|
175
|
+
loading.value = false
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** 切换账号:解除锁定并退出登录 */
|
|
180
|
+
const handleSwitchAccount = async (): Promise<void> => {
|
|
181
|
+
lockStore.unlock()
|
|
182
|
+
await signOut()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
onMounted(() => {
|
|
186
|
+
mittBus.on('openLockScreen', handleLock)
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
onUnmounted(() => {
|
|
190
|
+
mittBus.off('openLockScreen', handleLock)
|
|
191
|
+
})
|
|
192
|
+
</script>
|
|
193
|
+
|
|
194
|
+
<style scoped>
|
|
195
|
+
.screen-lock {
|
|
196
|
+
position: fixed;
|
|
197
|
+
inset: 0;
|
|
198
|
+
z-index: 3000;
|
|
199
|
+
display: flex;
|
|
200
|
+
flex-direction: column;
|
|
201
|
+
gap: 40px;
|
|
202
|
+
align-items: center;
|
|
203
|
+
justify-content: center;
|
|
204
|
+
background: linear-gradient(135deg, rgb(15 23 42 / 92%), rgb(30 41 59 / 88%));
|
|
205
|
+
backdrop-filter: blur(12px);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.screen-lock__clock {
|
|
209
|
+
color: #fff;
|
|
210
|
+
text-align: center;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.screen-lock__time {
|
|
214
|
+
font-size: 72px;
|
|
215
|
+
font-weight: 200;
|
|
216
|
+
line-height: 1;
|
|
217
|
+
letter-spacing: 2px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.screen-lock__date {
|
|
221
|
+
margin-top: 12px;
|
|
222
|
+
font-size: 16px;
|
|
223
|
+
opacity: 0.8;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.screen-lock__panel {
|
|
227
|
+
display: flex;
|
|
228
|
+
flex-direction: column;
|
|
229
|
+
align-items: center;
|
|
230
|
+
width: 320px;
|
|
231
|
+
padding: 32px 28px;
|
|
232
|
+
background: rgb(255 255 255 / 10%);
|
|
233
|
+
border: 1px solid rgb(255 255 255 / 18%);
|
|
234
|
+
border-radius: 16px;
|
|
235
|
+
box-shadow: 0 20px 60px rgb(0 0 0 / 35%);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.screen-lock__avatar {
|
|
239
|
+
border: 2px solid rgb(255 255 255 / 60%);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.screen-lock__name {
|
|
243
|
+
margin-top: 12px;
|
|
244
|
+
font-size: 16px;
|
|
245
|
+
font-weight: 500;
|
|
246
|
+
color: #fff;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.screen-lock__title {
|
|
250
|
+
margin: 16px 0 4px;
|
|
251
|
+
font-size: 15px;
|
|
252
|
+
font-weight: 500;
|
|
253
|
+
color: #fff;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.screen-lock__tip {
|
|
257
|
+
margin-bottom: 16px;
|
|
258
|
+
font-size: 12px;
|
|
259
|
+
line-height: 1.5;
|
|
260
|
+
color: rgb(255 255 255 / 70%);
|
|
261
|
+
text-align: center;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.screen-lock__panel :deep(.el-input) {
|
|
265
|
+
width: 100%;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.screen-lock__confirm {
|
|
269
|
+
margin-top: 12px;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.screen-lock__error {
|
|
273
|
+
width: 100%;
|
|
274
|
+
margin-top: 8px;
|
|
275
|
+
font-size: 12px;
|
|
276
|
+
color: #fca5a5;
|
|
277
|
+
text-align: left;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.screen-lock__btn {
|
|
281
|
+
width: 100%;
|
|
282
|
+
margin-top: 16px;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.screen-lock__hint {
|
|
286
|
+
margin-top: 12px;
|
|
287
|
+
font-size: 12px;
|
|
288
|
+
color: rgb(255 255 255 / 55%);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.screen-lock__switch {
|
|
292
|
+
display: flex;
|
|
293
|
+
gap: 6px;
|
|
294
|
+
align-items: center;
|
|
295
|
+
margin-top: 20px;
|
|
296
|
+
font-size: 13px;
|
|
297
|
+
color: rgb(255 255 255 / 75%);
|
|
298
|
+
cursor: pointer;
|
|
299
|
+
transition: color 0.2s;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.screen-lock__switch:hover {
|
|
303
|
+
color: #fff;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.screen-lock-fade-enter-active,
|
|
307
|
+
.screen-lock-fade-leave-active {
|
|
308
|
+
transition: opacity 0.3s ease;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.screen-lock-fade-enter-from,
|
|
312
|
+
.screen-lock-fade-leave-to {
|
|
313
|
+
opacity: 0;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@media screen and (width <= 640px) {
|
|
317
|
+
.screen-lock__time {
|
|
318
|
+
font-size: 56px;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.screen-lock__panel {
|
|
322
|
+
width: calc(100% - 48px);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
</style>
|
|
@@ -77,7 +77,6 @@
|
|
|
77
77
|
{ comment: '是否显示工作台标签', key: 'showWorkTab' },
|
|
78
78
|
{ comment: '是否显示语言切换', key: 'showLanguage' },
|
|
79
79
|
{ comment: '是否显示进度条', key: 'showNprogress' },
|
|
80
|
-
{ comment: '是否显示设置引导', key: 'showSettingGuide' },
|
|
81
80
|
{ comment: '是否显示节日文本', key: 'showFestivalText' },
|
|
82
81
|
{ comment: '是否显示水印', key: 'watermarkVisible' },
|
|
83
82
|
{ comment: '是否自动关闭', key: 'autoClose' },
|
|
@@ -86,16 +86,6 @@
|
|
|
86
86
|
}
|
|
87
87
|
})
|
|
88
88
|
|
|
89
|
-
// 播放事件监听器
|
|
90
|
-
playerInstance.value.on('play', () => {
|
|
91
|
-
console.log('Video is playing')
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
// 暂停事件监听器
|
|
95
|
-
playerInstance.value.on('pause', () => {
|
|
96
|
-
console.log('Video is paused')
|
|
97
|
-
})
|
|
98
|
-
|
|
99
89
|
// 错误事件监听器
|
|
100
90
|
playerInstance.value.on('error', (error) => {
|
|
101
91
|
console.error('Error occurred:', error)
|
|
@@ -63,8 +63,11 @@ const appConfig: SystemConfig = {
|
|
|
63
63
|
globalSearch: false,
|
|
64
64
|
notification: false,
|
|
65
65
|
chat: false,
|
|
66
|
-
|
|
66
|
+
// 水印功能常驻启用:组件始终挂载,显示/隐藏由设置面板“全局水印”开关(watermarkVisible)控制
|
|
67
|
+
watermark: true,
|
|
67
68
|
festivalEffects: false,
|
|
69
|
+
screenLock: true,
|
|
70
|
+
guide: true,
|
|
68
71
|
examples: true
|
|
69
72
|
},
|
|
70
73
|
storage: {
|
|
@@ -61,6 +61,20 @@ export const globalComponentsConfig: GlobalComponentConfig[] = [
|
|
|
61
61
|
() => import('@/components/core/others/art-watermark/index.vue')
|
|
62
62
|
),
|
|
63
63
|
enabled: AppConfig.features.watermark
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: '锁屏',
|
|
67
|
+
key: 'screen-lock',
|
|
68
|
+
component: defineAsyncComponent(
|
|
69
|
+
() => import('@/components/core/layouts/art-screen-lock/index.vue')
|
|
70
|
+
),
|
|
71
|
+
enabled: AppConfig.features.screenLock
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: '新手引导',
|
|
75
|
+
key: 'guide',
|
|
76
|
+
component: defineAsyncComponent(() => import('@/components/core/layouts/art-guide/index.vue')),
|
|
77
|
+
enabled: AppConfig.features.guide
|
|
64
78
|
}
|
|
65
79
|
]
|
|
66
80
|
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 新手引导步骤配置
|
|
3
|
+
*
|
|
4
|
+
* 集中定义 driver.js 引导的步骤,供 useGuide 消费。
|
|
5
|
+
* 迁移到其他应用时,通常只需调整此文件的步骤与锚点选择器。
|
|
6
|
+
*
|
|
7
|
+
* ## 设计说明
|
|
8
|
+
*
|
|
9
|
+
* - 每一步通过 `element` 指定 CSS 选择器锚点;为空表示居中欢迎弹窗
|
|
10
|
+
* - `feature` 关联 AppConfig.features 开关,未启用的功能对应步骤会被自动跳过
|
|
11
|
+
* - 运行时若锚点元素不存在(如按钮被隐藏),该步同样会被过滤
|
|
12
|
+
* - 标题与描述使用 i18n key,由 useGuide 结合当前语言渲染
|
|
13
|
+
*
|
|
14
|
+
* @module config/modules/guide
|
|
15
|
+
* @author Art Design Pro Team
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { AppFeatureConfig } from '@/types'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 引导步骤配置项
|
|
22
|
+
*/
|
|
23
|
+
export interface GuideStepConfig {
|
|
24
|
+
/** 目标元素 CSS 选择器;缺省表示不聚焦元素的居中弹窗 */
|
|
25
|
+
element?: string
|
|
26
|
+
/** 关联的功能开关,未启用时跳过该步 */
|
|
27
|
+
feature?: keyof AppFeatureConfig
|
|
28
|
+
/** 标题的 i18n key */
|
|
29
|
+
titleKey: string
|
|
30
|
+
/** 描述的 i18n key */
|
|
31
|
+
descKey: string
|
|
32
|
+
/** 弹窗相对锚点的方位 */
|
|
33
|
+
side?: 'top' | 'bottom' | 'left' | 'right'
|
|
34
|
+
/** 弹窗与锚点的对齐方式 */
|
|
35
|
+
align?: 'start' | 'center' | 'end'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 顶栏核心引导步骤
|
|
40
|
+
*
|
|
41
|
+
* 顺序与顶栏从左到右的按钮排布保持一致;
|
|
42
|
+
* 实际播放步骤由 useGuide 依据功能开关与元素存在性动态过滤。
|
|
43
|
+
*/
|
|
44
|
+
export const guideSteps: GuideStepConfig[] = [
|
|
45
|
+
{
|
|
46
|
+
titleKey: 'guide.welcome.title',
|
|
47
|
+
descKey: 'guide.welcome.desc'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
element: '.global-search-entry',
|
|
51
|
+
feature: 'globalSearch',
|
|
52
|
+
titleKey: 'guide.search.title',
|
|
53
|
+
descKey: 'guide.search.desc',
|
|
54
|
+
side: 'bottom',
|
|
55
|
+
align: 'center'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
element: '.fullscreen-entry',
|
|
59
|
+
feature: 'fullscreen',
|
|
60
|
+
titleKey: 'guide.fullscreen.title',
|
|
61
|
+
descKey: 'guide.fullscreen.desc',
|
|
62
|
+
side: 'bottom',
|
|
63
|
+
align: 'center'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
element: '.language-btn',
|
|
67
|
+
feature: 'language',
|
|
68
|
+
titleKey: 'guide.language.title',
|
|
69
|
+
descKey: 'guide.language.desc',
|
|
70
|
+
side: 'bottom',
|
|
71
|
+
align: 'center'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
element: '.notice-button',
|
|
75
|
+
feature: 'notification',
|
|
76
|
+
titleKey: 'guide.notification.title',
|
|
77
|
+
descKey: 'guide.notification.desc',
|
|
78
|
+
side: 'bottom',
|
|
79
|
+
align: 'center'
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
element: '.chat-button',
|
|
83
|
+
feature: 'chat',
|
|
84
|
+
titleKey: 'guide.chat.title',
|
|
85
|
+
descKey: 'guide.chat.desc',
|
|
86
|
+
side: 'bottom',
|
|
87
|
+
align: 'center'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
element: '.setting-btn',
|
|
91
|
+
feature: 'settings',
|
|
92
|
+
titleKey: 'guide.settings.title',
|
|
93
|
+
descKey: 'guide.settings.desc',
|
|
94
|
+
side: 'bottom',
|
|
95
|
+
align: 'center'
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
element: '.theme-toggle-btn',
|
|
99
|
+
feature: 'themeToggle',
|
|
100
|
+
titleKey: 'guide.theme.title',
|
|
101
|
+
descKey: 'guide.theme.desc',
|
|
102
|
+
side: 'bottom',
|
|
103
|
+
align: 'center'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
element: '.screen-lock-btn',
|
|
107
|
+
feature: 'screenLock',
|
|
108
|
+
titleKey: 'guide.lock.title',
|
|
109
|
+
descKey: 'guide.lock.desc',
|
|
110
|
+
side: 'bottom',
|
|
111
|
+
align: 'center'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
element: '.user-menu-avatar',
|
|
115
|
+
titleKey: 'guide.userMenu.title',
|
|
116
|
+
descKey: 'guide.userMenu.desc',
|
|
117
|
+
side: 'bottom',
|
|
118
|
+
align: 'end'
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
export default guideSteps
|
|
@@ -58,6 +58,10 @@ export const headerBarConfig: HeaderBarFeatureConfig = {
|
|
|
58
58
|
themeToggle: {
|
|
59
59
|
enabled: AppConfig.features.themeToggle,
|
|
60
60
|
description: '主题切换功能(明暗主题)'
|
|
61
|
+
},
|
|
62
|
+
screenLock: {
|
|
63
|
+
enabled: AppConfig.features.screenLock,
|
|
64
|
+
description: '锁屏功能,独立密码本地校验'
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
|
|
@@ -57,8 +57,6 @@ export const SETTING_DEFAULT_CONFIG = {
|
|
|
57
57
|
showLanguage: false,
|
|
58
58
|
/** 是否显示进度条 */
|
|
59
59
|
showNprogress: true,
|
|
60
|
-
/** 是否显示设置引导 */
|
|
61
|
-
showSettingGuide: false,
|
|
62
60
|
/** 是否显示节日文本 */
|
|
63
61
|
showFestivalText: false,
|
|
64
62
|
/** 是否显示水印 */
|
|
@@ -73,6 +71,8 @@ export const SETTING_DEFAULT_CONFIG = {
|
|
|
73
71
|
refresh: false,
|
|
74
72
|
/** 是否加载节日烟花 */
|
|
75
73
|
holidayFireworksLoaded: false,
|
|
74
|
+
/** 新手引导是否已完成 */
|
|
75
|
+
hasCompletedGuide: false,
|
|
76
76
|
/** 边框模式 */
|
|
77
77
|
boxBorderMode: true,
|
|
78
78
|
/** 页面过渡效果 */
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useGuide - 新手引导逻辑
|
|
3
|
+
*
|
|
4
|
+
* 基于 driver.js 封装新手引导的启动与销毁,步骤内容集中来自 config/modules/guide。
|
|
5
|
+
*
|
|
6
|
+
* ## 主要功能
|
|
7
|
+
*
|
|
8
|
+
* 1. 步骤构建 - 依据功能开关与锚点元素存在性动态过滤步骤
|
|
9
|
+
* 2. 国际化 - 标题/描述/按钮文案结合当前语言实时渲染
|
|
10
|
+
* 3. 生命周期 - 启动时创建实例,销毁时标记引导已完成
|
|
11
|
+
* 4. 单例保护 - 重复启动前销毁旧实例,避免遮罩叠加
|
|
12
|
+
*
|
|
13
|
+
* ## 使用示例
|
|
14
|
+
*
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const { start, destroy } = useGuide()
|
|
17
|
+
*
|
|
18
|
+
* // 启动引导(首次自动或用户手动触发)
|
|
19
|
+
* start()
|
|
20
|
+
*
|
|
21
|
+
* // 组件卸载时销毁
|
|
22
|
+
* destroy()
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @module useGuide
|
|
26
|
+
* @author Art Design Pro Team
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { driver } from 'driver.js'
|
|
30
|
+
import type { DriveStep, Driver, Popover } from 'driver.js'
|
|
31
|
+
import { useI18n } from 'vue-i18n'
|
|
32
|
+
import { guideSteps } from '@/config/modules/guide'
|
|
33
|
+
import { useSettingStore } from '@/store/modules/setting'
|
|
34
|
+
import AppConfig from '@/config'
|
|
35
|
+
|
|
36
|
+
export function useGuide() {
|
|
37
|
+
const { t } = useI18n()
|
|
38
|
+
const settingStore = useSettingStore()
|
|
39
|
+
|
|
40
|
+
/** driver.js 实例,未启动时为 null */
|
|
41
|
+
let driverInstance: Driver | null = null
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 构建实际播放的步骤
|
|
45
|
+
*
|
|
46
|
+
* 过滤规则:
|
|
47
|
+
* - 关联了 feature 但该功能未启用 -> 跳过
|
|
48
|
+
* - 声明了 element 但页面上找不到该锚点 -> 跳过
|
|
49
|
+
* 居中欢迎弹窗(无 element、无 feature)始终保留。
|
|
50
|
+
*/
|
|
51
|
+
const buildSteps = (): DriveStep[] => {
|
|
52
|
+
return guideSteps
|
|
53
|
+
.filter((step) => !step.feature || AppConfig.features[step.feature])
|
|
54
|
+
.filter((step) => !step.element || document.querySelector(step.element))
|
|
55
|
+
.map((step) => {
|
|
56
|
+
const popover: Popover = {
|
|
57
|
+
title: t(step.titleKey),
|
|
58
|
+
description: t(step.descKey)
|
|
59
|
+
}
|
|
60
|
+
if (step.side) popover.side = step.side
|
|
61
|
+
if (step.align) popover.align = step.align
|
|
62
|
+
|
|
63
|
+
const driveStep: DriveStep = { popover }
|
|
64
|
+
if (step.element) driveStep.element = step.element
|
|
65
|
+
return driveStep
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 销毁当前引导实例(若存在)
|
|
71
|
+
*/
|
|
72
|
+
const destroy = (): void => {
|
|
73
|
+
if (driverInstance) {
|
|
74
|
+
driverInstance.destroy()
|
|
75
|
+
driverInstance = null
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 启动新手引导
|
|
81
|
+
*
|
|
82
|
+
* 每次启动都会重新构建步骤,确保功能开关、锚点与语言为最新状态。
|
|
83
|
+
* 引导结束(完成或跳过)时通过 onDestroyed 标记 hasCompletedGuide。
|
|
84
|
+
*/
|
|
85
|
+
const start = (): void => {
|
|
86
|
+
// 避免重复实例叠加遮罩
|
|
87
|
+
destroy()
|
|
88
|
+
|
|
89
|
+
const steps = buildSteps()
|
|
90
|
+
if (steps.length === 0) return
|
|
91
|
+
|
|
92
|
+
driverInstance = driver({
|
|
93
|
+
steps,
|
|
94
|
+
showProgress: true,
|
|
95
|
+
allowClose: true,
|
|
96
|
+
stagePadding: 6,
|
|
97
|
+
stageRadius: 8,
|
|
98
|
+
popoverClass: 'art-guide-popover',
|
|
99
|
+
nextBtnText: t('guide.buttons.next'),
|
|
100
|
+
prevBtnText: t('guide.buttons.prev'),
|
|
101
|
+
doneBtnText: t('guide.buttons.done'),
|
|
102
|
+
closeBtnLabel: t('guide.buttons.close'),
|
|
103
|
+
onDestroyed: () => {
|
|
104
|
+
settingStore.completeGuide()
|
|
105
|
+
driverInstance = null
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
driverInstance.drive()
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
start, // 启动引导
|
|
114
|
+
destroy // 销毁引导
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -108,6 +108,11 @@ export function useHeaderBar() {
|
|
|
108
108
|
return isFeatureEnabled('themeToggle')
|
|
109
109
|
})
|
|
110
110
|
|
|
111
|
+
// 检查锁屏按钮是否显示
|
|
112
|
+
const shouldShowScreenLock = computed(() => {
|
|
113
|
+
return isFeatureEnabled('screenLock')
|
|
114
|
+
})
|
|
115
|
+
|
|
111
116
|
// 获取快速入口的最小宽度
|
|
112
117
|
const fastEnterMinWidth = computed(() => {
|
|
113
118
|
const config = getFeatureConfig('fastEnter')
|
|
@@ -184,6 +189,7 @@ export function useHeaderBar() {
|
|
|
184
189
|
shouldShowLanguage, // 是否显示语言切换
|
|
185
190
|
shouldShowSettings, // 是否显示设置面板
|
|
186
191
|
shouldShowThemeToggle, // 是否显示主题切换
|
|
192
|
+
shouldShowScreenLock, // 是否显示锁屏按钮
|
|
187
193
|
|
|
188
194
|
// 配置相关
|
|
189
195
|
fastEnterMinWidth, // 快速入口最小宽度
|