@kevairy/template 0.1.2 → 0.1.4
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/.env.production +6 -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/adapters/auth/index.ts +1 -1
- package/template/src/adapters/auth/types.ts +6 -1
- package/template/src/api/auth.ts +3 -2
- package/template/src/components/core/forms/art-wang-editor/index.vue +0 -5
- package/template/src/components/core/layouts/art-guide/index.vue +131 -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-page-content/index.vue +8 -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 +8 -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/directives/core/access.ts +125 -0
- package/template/src/directives/core/auth.ts +7 -62
- package/template/src/directives/core/roles.ts +5 -83
- package/template/src/env.d.ts +1 -0
- package/template/src/hooks/core/useAuth.ts +2 -74
- package/template/src/hooks/core/useGuide.ts +122 -0
- package/template/src/hooks/core/useHeaderBar.ts +6 -0
- package/template/src/hooks/core/usePermission.ts +41 -0
- package/template/src/hooks/index.ts +1 -0
- package/template/src/locales/index.ts +0 -1
- package/template/src/locales/langs/en.json +77 -6
- package/template/src/locales/langs/zh.json +77 -6
- package/template/src/main.ts +19 -9
- package/template/src/router/core/IframeRouteManager.ts +4 -2
- package/template/src/router/core/MenuProcessor.ts +5 -40
- package/template/src/router/core/RoutePermissionValidator.ts +6 -149
- package/template/src/router/core/access.ts +79 -0
- package/template/src/router/guards/afterEach.ts +6 -10
- package/template/src/router/guards/beforeEach.ts +143 -100
- package/template/src/router/guards/error.ts +42 -0
- package/template/src/router/index.ts +2 -0
- package/template/src/router/modules/examples.ts +4 -3
- package/template/src/router/routes/staticRoutes.ts +5 -3
- package/template/src/services/auth.ts +32 -10
- package/template/src/services/permission.ts +21 -0
- package/template/src/store/modules/lock.ts +125 -0
- package/template/src/store/modules/menu.ts +28 -8
- package/template/src/store/modules/setting.ts +8 -15
- package/template/src/store/modules/user.ts +73 -33
- package/template/src/store/modules/worktab.ts +1 -1
- package/template/src/types/api/api.d.ts +4 -1
- package/template/src/types/config/index.ts +9 -0
- package/template/src/types/directive/directive.d.ts +1 -0
- package/template/src/types/import/components.d.ts +2 -0
- package/template/src/types/router/index.ts +6 -0
- package/template/src/utils/http/contract.ts +51 -19
- package/template/src/utils/http/error.ts +73 -26
- package/template/src/utils/http/index.ts +160 -165
- package/template/src/utils/http/request-manager.ts +124 -0
- package/template/src/utils/http/status.ts +1 -0
- package/template/src/utils/permission/index.ts +66 -0
- package/template/src/utils/session.ts +24 -0
- package/template/src/utils/socket/index.ts +27 -2
- package/template/src/utils/storage/storage-config.ts +15 -0
- package/template/src/utils/storage/storage.ts +5 -3
- package/template/src/utils/sys/diagnostics.ts +180 -0
- package/template/src/utils/sys/error-handle.ts +56 -126
- package/template/src/utils/sys/mittBus.ts +5 -0
- package/template/src/utils/sys/recovery.ts +31 -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/permissions/index.vue +69 -13
- package/template/src/views/examples/search-table/index.vue +2 -3
- package/template/src/views/exception/403/index.vue +33 -0
- package/template/src/views/exception/500/index.vue +52 -10
- package/template/tests/e2e/auth.spec.ts +24 -6
- package/template/tests/e2e/helpers/guide.ts +9 -0
- package/template/tests/e2e/permissions.spec.ts +53 -0
- package/template/tests/e2e/search-table.spec.ts +2 -0
- package/template/tests/e2e/session-recovery.spec.ts +49 -0
- package/template/tests/unit/diagnostics/diagnostics.spec.ts +132 -0
- package/template/tests/unit/diagnostics/router.spec.ts +84 -0
- package/template/tests/unit/http/auth-lifecycle.spec.ts +203 -0
- package/template/tests/unit/http/contract.spec.ts +46 -0
- package/template/tests/unit/http/request.spec.ts +487 -0
- package/template/tests/unit/permissions/guard.spec.ts +261 -0
- package/template/tests/unit/permissions/guide.spec.ts +30 -0
- package/template/tests/unit/permissions/rules.spec.ts +106 -0
- package/template/tests/unit/permissions/state-and-directives.spec.ts +176 -0
- package/template/tests/unit/router/examples.spec.ts +5 -1
- package/template/vite.config.ts +8 -2
|
@@ -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)
|
|
@@ -50,6 +50,10 @@ const appConfig: SystemConfig = {
|
|
|
50
50
|
loginRouteName: 'Login',
|
|
51
51
|
titleTemplate: '{page} - {app}'
|
|
52
52
|
},
|
|
53
|
+
accessControl: {
|
|
54
|
+
// 设置为 false 可关闭超级权限通配符;不根据角色名称推断超级权限。
|
|
55
|
+
wildcardPermission: '*:*:*'
|
|
56
|
+
},
|
|
53
57
|
features: {
|
|
54
58
|
menuButton: true,
|
|
55
59
|
refreshButton: true,
|
|
@@ -63,8 +67,11 @@ const appConfig: SystemConfig = {
|
|
|
63
67
|
globalSearch: false,
|
|
64
68
|
notification: false,
|
|
65
69
|
chat: false,
|
|
66
|
-
|
|
70
|
+
// 水印功能常驻启用:组件始终挂载,显示/隐藏由设置面板“全局水印”开关(watermarkVisible)控制
|
|
71
|
+
watermark: true,
|
|
67
72
|
festivalEffects: false,
|
|
73
|
+
screenLock: true,
|
|
74
|
+
guide: true,
|
|
68
75
|
examples: true
|
|
69
76
|
},
|
|
70
77
|
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,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
shallowRef,
|
|
3
|
+
watchEffect,
|
|
4
|
+
type ObjectDirective,
|
|
5
|
+
type ShallowRef,
|
|
6
|
+
type WatchStopHandle
|
|
7
|
+
} from 'vue'
|
|
8
|
+
import { usePermission } from '@/hooks/core/usePermission'
|
|
9
|
+
import type { PermissionRequirement } from '@/utils/permission'
|
|
10
|
+
|
|
11
|
+
interface ElementState {
|
|
12
|
+
binding: ShallowRef<{ value: PermissionRequirement; disabled: boolean; all: boolean }>
|
|
13
|
+
stop: WatchStopHandle
|
|
14
|
+
restore: () => void
|
|
15
|
+
capture: () => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** 隐藏而非移除节点,权限恢复时 Vue 仍能管理、更新原节点。 */
|
|
19
|
+
export function createAccessDirective(
|
|
20
|
+
role = false
|
|
21
|
+
): ObjectDirective<HTMLElement, PermissionRequirement> {
|
|
22
|
+
const states = new WeakMap<HTMLElement, ElementState>()
|
|
23
|
+
return {
|
|
24
|
+
beforeMount(el, binding) {
|
|
25
|
+
const permission = usePermission()
|
|
26
|
+
const original = {
|
|
27
|
+
display: el.style.display,
|
|
28
|
+
displayPriority: el.style.getPropertyPriority('display'),
|
|
29
|
+
disabled: el.getAttribute('disabled'),
|
|
30
|
+
ariaDisabled: el.getAttribute('aria-disabled'),
|
|
31
|
+
disabledClass: el.classList.contains('is-disabled'),
|
|
32
|
+
pointerEvents: el.style.pointerEvents
|
|
33
|
+
}
|
|
34
|
+
let applied = false
|
|
35
|
+
const current = shallowRef({
|
|
36
|
+
value: binding.value,
|
|
37
|
+
disabled: !!binding.modifiers.disabled,
|
|
38
|
+
all: !!binding.modifiers.all
|
|
39
|
+
})
|
|
40
|
+
const restore = () => {
|
|
41
|
+
if (!applied) return
|
|
42
|
+
el.style.setProperty('display', original.display, original.displayPriority)
|
|
43
|
+
el.style.pointerEvents = original.pointerEvents
|
|
44
|
+
if (original.disabled === null) el.removeAttribute('disabled')
|
|
45
|
+
else el.setAttribute('disabled', original.disabled)
|
|
46
|
+
if (original.ariaDisabled === null) el.removeAttribute('aria-disabled')
|
|
47
|
+
else el.setAttribute('aria-disabled', original.ariaDisabled)
|
|
48
|
+
el.classList.toggle('is-disabled', original.disabledClass)
|
|
49
|
+
applied = false
|
|
50
|
+
}
|
|
51
|
+
const allowed = () => {
|
|
52
|
+
const { value, all } = current.value
|
|
53
|
+
return role
|
|
54
|
+
? all
|
|
55
|
+
? permission.hasAllRoles(value)
|
|
56
|
+
: permission.hasRole(value)
|
|
57
|
+
: all
|
|
58
|
+
? permission.hasAllPermissions(value)
|
|
59
|
+
: permission.hasPermission(value)
|
|
60
|
+
}
|
|
61
|
+
// disabled 属性只对原生表单元素生效,其他元素同时拦截鼠标和键盘激活。
|
|
62
|
+
const block = (event: Event) => {
|
|
63
|
+
if (event instanceof KeyboardEvent && !['Enter', ' '].includes(event.key)) return
|
|
64
|
+
if (!allowed()) {
|
|
65
|
+
event.preventDefault()
|
|
66
|
+
event.stopImmediatePropagation()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
el.addEventListener('click', block, true)
|
|
70
|
+
el.addEventListener('keydown', block, true)
|
|
71
|
+
const stop = watchEffect(
|
|
72
|
+
() => {
|
|
73
|
+
restore()
|
|
74
|
+
if (allowed()) return
|
|
75
|
+
applied = true
|
|
76
|
+
if (current.value.disabled) {
|
|
77
|
+
el.setAttribute('disabled', '')
|
|
78
|
+
el.setAttribute('aria-disabled', 'true')
|
|
79
|
+
el.classList.add('is-disabled')
|
|
80
|
+
el.style.pointerEvents = 'none'
|
|
81
|
+
} else {
|
|
82
|
+
el.style.setProperty('display', 'none', 'important')
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{ flush: 'sync' }
|
|
86
|
+
)
|
|
87
|
+
states.set(el, {
|
|
88
|
+
binding: current,
|
|
89
|
+
restore,
|
|
90
|
+
capture: () => {
|
|
91
|
+
original.display = el.style.display
|
|
92
|
+
original.displayPriority = el.style.getPropertyPriority('display')
|
|
93
|
+
original.disabled = el.getAttribute('disabled')
|
|
94
|
+
original.ariaDisabled = el.getAttribute('aria-disabled')
|
|
95
|
+
original.disabledClass = el.classList.contains('is-disabled')
|
|
96
|
+
original.pointerEvents = el.style.pointerEvents
|
|
97
|
+
},
|
|
98
|
+
stop: () => {
|
|
99
|
+
stop()
|
|
100
|
+
el.removeEventListener('click', block, true)
|
|
101
|
+
el.removeEventListener('keydown', block, true)
|
|
102
|
+
restore()
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
beforeUpdate(el) {
|
|
107
|
+
states.get(el)?.restore()
|
|
108
|
+
},
|
|
109
|
+
updated(el, binding) {
|
|
110
|
+
const state = states.get(el)
|
|
111
|
+
if (state) {
|
|
112
|
+
state.capture()
|
|
113
|
+
state.binding.value = {
|
|
114
|
+
value: binding.value,
|
|
115
|
+
disabled: !!binding.modifiers.disabled,
|
|
116
|
+
all: !!binding.modifiers.all
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
unmounted(el) {
|
|
121
|
+
states.get(el)?.stop()
|
|
122
|
+
states.delete(el)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|