af-mobile-client-vue3 1.6.12 → 1.6.13
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
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import { getConfigByNameAsync } from '@af-mobile-client-vue3/services/api/common'
|
|
2
|
-
import { APP_WEB_CONFIG_KEY } from '@af-mobile-client-vue3/stores/mutation-type'
|
|
3
|
-
import { secureStorageBatchWrite } from '@af-mobile-client-vue3/utils/secureStorage'
|
|
4
|
-
import { createStorage } from '@af-mobile-client-vue3/utils/Storage'
|
|
5
|
-
import { defineStore } from 'pinia'
|
|
6
|
-
import { ref } from 'vue'
|
|
7
|
-
import { useHomeAppStore } from './homeApp'
|
|
8
|
-
|
|
9
|
-
export interface WebConfig {
|
|
10
|
-
isAttendance: boolean | false
|
|
11
|
-
systemName: string
|
|
12
|
-
routerName: string
|
|
13
|
-
systemDesc: string
|
|
14
|
-
homePage: any
|
|
15
|
-
defaultAvatarUrl: string
|
|
16
|
-
wechatLogin: boolean
|
|
17
|
-
wxLoginAge: boolean
|
|
18
|
-
wxAutoLogin: string
|
|
19
|
-
tenantName: string
|
|
20
|
-
systemLogo: string
|
|
21
|
-
homeAppList: Array<any>
|
|
22
|
-
slideshowList: Array<any>
|
|
23
|
-
registerRequire: boolean
|
|
24
|
-
requestEncrypt: boolean
|
|
25
|
-
phoneLoginVerification: boolean
|
|
26
|
-
hiddenTraditionalLogin: boolean
|
|
27
|
-
isFaceRecognition: boolean // 登录是否需要人脸识别
|
|
28
|
-
intervalFaceRecognition: boolean // 登录是否需要开启定时人脸识别
|
|
29
|
-
faceIntervalMinutes: number // 定时时间 单位分钟
|
|
30
|
-
faceRetryCount: number // 定时验证 重试次数
|
|
31
|
-
getPlatformUser: boolean // 获取外部用户信息
|
|
32
|
-
navigationStyle: any // app顶部导航区域样式控制
|
|
33
|
-
captchaEnable: boolean // 是否启用登录验证码(前台本地处理)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// 存放 webConfig 中的 setting 配置
|
|
37
|
-
export const useSettingStore = defineStore('setting', () => {
|
|
38
|
-
const setting = ref<WebConfig>(undefined)
|
|
39
|
-
const isInitialized = ref(false)
|
|
40
|
-
|
|
41
|
-
const setSetting = (newSetting: WebConfig) => {
|
|
42
|
-
setting.value = newSetting
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const getSetting = () => {
|
|
46
|
-
return setting.value
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// 将 init 作为 store 的方法导出
|
|
50
|
-
const init = async () => {
|
|
51
|
-
if (isInitialized.value)
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
const useStore = createStorage()
|
|
55
|
-
const catchWebConfig = useStore.get(APP_WEB_CONFIG_KEY)
|
|
56
|
-
const homeAppStore = useHomeAppStore()
|
|
57
|
-
|
|
58
|
-
if (catchWebConfig?.setting) {
|
|
59
|
-
setSetting(catchWebConfig?.setting)
|
|
60
|
-
// homeAppList 仅在用户缓存没有时才回填,避免覆盖用户自定义
|
|
61
|
-
if (!homeAppStore.homeAppList?.length && catchWebConfig.setting.homeAppList) {
|
|
62
|
-
homeAppStore.setHomeAppList(catchWebConfig.setting.homeAppList)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
const res = await getConfigByNameAsync('webMobileConfig'
|
|
67
|
-
if (res.setting) {
|
|
68
|
-
useStore.set(APP_WEB_CONFIG_KEY, res)
|
|
69
|
-
setSetting(res.setting)
|
|
70
|
-
// homeAppList 仅在用户缓存没有时才回填
|
|
71
|
-
if (!homeAppStore.homeAppList?.length && res.setting.homeAppList) {
|
|
72
|
-
homeAppStore.setHomeAppList(res.setting.homeAppList)
|
|
73
|
-
}
|
|
74
|
-
// 如果有pos相关的配置存储到app安全存储中
|
|
75
|
-
if (res.setting.posConfig) {
|
|
76
|
-
secureStorageBatchWrite([
|
|
77
|
-
{
|
|
78
|
-
key: 'posConfig',
|
|
79
|
-
value: res.setting.posConfig,
|
|
80
|
-
},
|
|
81
|
-
])
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
isInitialized.value = true
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
setSetting,
|
|
90
|
-
getSetting,
|
|
91
|
-
init, // 导出 init 方法
|
|
92
|
-
isInitialized,
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
export default useSettingStore
|
|
1
|
+
import { getConfigByNameAsync } from '@af-mobile-client-vue3/services/api/common'
|
|
2
|
+
import { APP_WEB_CONFIG_KEY } from '@af-mobile-client-vue3/stores/mutation-type'
|
|
3
|
+
import { secureStorageBatchWrite } from '@af-mobile-client-vue3/utils/secureStorage'
|
|
4
|
+
import { createStorage } from '@af-mobile-client-vue3/utils/Storage'
|
|
5
|
+
import { defineStore } from 'pinia'
|
|
6
|
+
import { ref } from 'vue'
|
|
7
|
+
import { useHomeAppStore } from './homeApp'
|
|
8
|
+
|
|
9
|
+
export interface WebConfig {
|
|
10
|
+
isAttendance: boolean | false
|
|
11
|
+
systemName: string
|
|
12
|
+
routerName: string
|
|
13
|
+
systemDesc: string
|
|
14
|
+
homePage: any
|
|
15
|
+
defaultAvatarUrl: string
|
|
16
|
+
wechatLogin: boolean
|
|
17
|
+
wxLoginAge: boolean
|
|
18
|
+
wxAutoLogin: string
|
|
19
|
+
tenantName: string
|
|
20
|
+
systemLogo: string
|
|
21
|
+
homeAppList: Array<any>
|
|
22
|
+
slideshowList: Array<any>
|
|
23
|
+
registerRequire: boolean
|
|
24
|
+
requestEncrypt: boolean
|
|
25
|
+
phoneLoginVerification: boolean
|
|
26
|
+
hiddenTraditionalLogin: boolean
|
|
27
|
+
isFaceRecognition: boolean // 登录是否需要人脸识别
|
|
28
|
+
intervalFaceRecognition: boolean // 登录是否需要开启定时人脸识别
|
|
29
|
+
faceIntervalMinutes: number // 定时时间 单位分钟
|
|
30
|
+
faceRetryCount: number // 定时验证 重试次数
|
|
31
|
+
getPlatformUser: boolean // 获取外部用户信息
|
|
32
|
+
navigationStyle: any // app顶部导航区域样式控制
|
|
33
|
+
captchaEnable: boolean // 是否启用登录验证码(前台本地处理)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 存放 webConfig 中的 setting 配置
|
|
37
|
+
export const useSettingStore = defineStore('setting', () => {
|
|
38
|
+
const setting = ref<WebConfig>(undefined)
|
|
39
|
+
const isInitialized = ref(false)
|
|
40
|
+
|
|
41
|
+
const setSetting = (newSetting: WebConfig) => {
|
|
42
|
+
setting.value = newSetting
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const getSetting = () => {
|
|
46
|
+
return setting.value
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 将 init 作为 store 的方法导出
|
|
50
|
+
const init = async () => {
|
|
51
|
+
if (isInitialized.value)
|
|
52
|
+
return
|
|
53
|
+
|
|
54
|
+
const useStore = createStorage()
|
|
55
|
+
const catchWebConfig = useStore.get(APP_WEB_CONFIG_KEY)
|
|
56
|
+
const homeAppStore = useHomeAppStore()
|
|
57
|
+
|
|
58
|
+
if (catchWebConfig?.setting) {
|
|
59
|
+
setSetting(catchWebConfig?.setting)
|
|
60
|
+
// homeAppList 仅在用户缓存没有时才回填,避免覆盖用户自定义
|
|
61
|
+
if (!homeAppStore.homeAppList?.length && catchWebConfig.setting.homeAppList) {
|
|
62
|
+
homeAppStore.setHomeAppList(catchWebConfig.setting.homeAppList)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const res = await getConfigByNameAsync('webMobileConfig')
|
|
67
|
+
if (res.setting) {
|
|
68
|
+
useStore.set(APP_WEB_CONFIG_KEY, res)
|
|
69
|
+
setSetting(res.setting)
|
|
70
|
+
// homeAppList 仅在用户缓存没有时才回填
|
|
71
|
+
if (!homeAppStore.homeAppList?.length && res.setting.homeAppList) {
|
|
72
|
+
homeAppStore.setHomeAppList(res.setting.homeAppList)
|
|
73
|
+
}
|
|
74
|
+
// 如果有pos相关的配置存储到app安全存储中
|
|
75
|
+
if (res.setting.posConfig) {
|
|
76
|
+
secureStorageBatchWrite([
|
|
77
|
+
{
|
|
78
|
+
key: 'posConfig',
|
|
79
|
+
value: res.setting.posConfig,
|
|
80
|
+
},
|
|
81
|
+
])
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
isInitialized.value = true
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
setSetting,
|
|
90
|
+
getSetting,
|
|
91
|
+
init, // 导出 init 方法
|
|
92
|
+
isInitialized,
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
export default useSettingStore
|
|
@@ -162,7 +162,7 @@ export const useUserStore = defineStore('app-user', () => {
|
|
|
162
162
|
const expiresInSeconds = expiresInMinutes * 60
|
|
163
163
|
const BUFFER_SECONDS = 30
|
|
164
164
|
const safeExpire = Math.max(expiresInSeconds - BUFFER_SECONDS, 0)
|
|
165
|
-
Storage.set('v4-session-key', key,
|
|
165
|
+
Storage.set('v4-session-key', key, safeExpire)
|
|
166
166
|
}
|
|
167
167
|
else {
|
|
168
168
|
localStorage.setItem('v4-session-key', key)
|