@liujitcn/kratos-uni-app-core 0.0.55 → 0.0.56
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/dist/module.mjs +2 -0
- package/package.json +1 -1
- package/src/api/base/v1/config.ts +11 -0
- package/src/locales/README.md +1 -1
- package/src/module.ts +2 -0
- package/src/rpc/base/v1/config.ts +13 -1
- package/src/rpc/base/v1/file.ts +1 -1
- package/src/static/tabs/message_default.png +0 -0
- package/src/static/tabs/message_selected.png +0 -0
- package/src/stores/modules/setting.ts +15 -1
- package/src/stores/modules/user.ts +10 -0
package/dist/module.mjs
CHANGED
|
@@ -655,6 +655,8 @@ var coreModule = defineKratosAppModule({
|
|
|
655
655
|
icons: {
|
|
656
656
|
HOME_DEFAULT: "static/tabs/home_default.png",
|
|
657
657
|
HOME_SELECTED: "static/tabs/home_selected.png",
|
|
658
|
+
MESSAGE_DEFAULT: "static/tabs/message_default.png",
|
|
659
|
+
MESSAGE_SELECTED: "static/tabs/message_selected.png",
|
|
658
660
|
USER_DEFAULT: "static/tabs/user_default.png",
|
|
659
661
|
USER_SELECTED: "static/tabs/user_selected.png"
|
|
660
662
|
},
|
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@ import type {
|
|
|
3
3
|
ConfigService,
|
|
4
4
|
GetConfigRequest,
|
|
5
5
|
GetConfigResponse,
|
|
6
|
+
GetI18nCustomRequest,
|
|
7
|
+
GetI18nCustomResponse,
|
|
6
8
|
} from '../../../rpc/base/v1/config'
|
|
7
9
|
|
|
8
10
|
const CONFIG_URL = '/v1/base/config'
|
|
@@ -19,6 +21,15 @@ export class ConfigServiceImpl implements ConfigService {
|
|
|
19
21
|
header: { Authorization: 'no-auth' },
|
|
20
22
|
})
|
|
21
23
|
}
|
|
24
|
+
|
|
25
|
+
/** 获取当前租户的自定义国际化覆盖项。 */
|
|
26
|
+
GetI18nCustom(request: GetI18nCustomRequest): Promise<GetI18nCustomResponse> {
|
|
27
|
+
return http<GetI18nCustomResponse>({
|
|
28
|
+
url: `${CONFIG_URL}/i18n-custom`,
|
|
29
|
+
method: 'GET',
|
|
30
|
+
data: request,
|
|
31
|
+
})
|
|
32
|
+
}
|
|
22
33
|
}
|
|
23
34
|
|
|
24
35
|
export const defConfigService = new ConfigServiceImpl()
|
package/src/locales/README.md
CHANGED
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
| `en-US.json` | 英文 Core 语言包。 | uni-app 切换为英文时使用。 |
|
|
10
10
|
| `ja-JP.json` | 日文 Core 语言包。 | uni-app 切换为日文时使用。 |
|
|
11
11
|
|
|
12
|
-
语言包是标准 JSON,不能在文件内直接写注释;公共键使用 `common.` 或 `core.` 命名空间。新增语言后执行仓库根目录的 `make i18n
|
|
12
|
+
语言包是标准 JSON,不能在文件内直接写注释;公共键使用 `common.` 或 `core.` 命名空间。新增语言后执行仓库根目录的 `make i18n`。语言切换选项固定显示后端 `base_language.native_name`,接口不可用时使用代码内置的原生名称;`common.language.*` 仅用于普通文案和语言迁移初始数据。新增语言的完整文件清单见[国际化语言扩展指南](../../../../../../docs/国际化语言扩展指南.md)。
|
package/src/module.ts
CHANGED
|
@@ -85,6 +85,8 @@ export const coreModule = defineKratosAppModule({
|
|
|
85
85
|
icons: {
|
|
86
86
|
HOME_DEFAULT: 'static/tabs/home_default.png',
|
|
87
87
|
HOME_SELECTED: 'static/tabs/home_selected.png',
|
|
88
|
+
MESSAGE_DEFAULT: 'static/tabs/message_default.png',
|
|
89
|
+
MESSAGE_SELECTED: 'static/tabs/message_selected.png',
|
|
88
90
|
USER_DEFAULT: 'static/tabs/user_default.png',
|
|
89
91
|
USER_SELECTED: 'static/tabs/user_selected.png',
|
|
90
92
|
},
|
|
@@ -40,8 +40,18 @@ export interface GetConfigResponse {
|
|
|
40
40
|
configs: ConfigItem[];
|
|
41
41
|
/** AI 助手是否可用 */
|
|
42
42
|
ai_enabled: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** 当前租户自定义国际化覆盖项查询条件。 */
|
|
46
|
+
export interface GetI18nCustomRequest {
|
|
47
|
+
/** 位置:枚举【BaseConfigSite】 */
|
|
48
|
+
site: BaseConfigSite;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 当前租户自定义国际化覆盖项查询结果。 */
|
|
52
|
+
export interface GetI18nCustomResponse {
|
|
43
53
|
/** 全部语言的自定义国际化覆盖项 */
|
|
44
|
-
|
|
54
|
+
items: I18nCustomItem[];
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
/** 全部语言的自定义国际化覆盖项。 */
|
|
@@ -58,4 +68,6 @@ export interface I18nCustomItem {
|
|
|
58
68
|
export interface ConfigService {
|
|
59
69
|
/** 获取系统配置 */
|
|
60
70
|
GetConfig(request: GetConfigRequest): Promise<GetConfigResponse>;
|
|
71
|
+
/** 获取当前租户的自定义国际化覆盖项 */
|
|
72
|
+
GetI18nCustom(request: GetI18nCustomRequest): Promise<GetI18nCustomResponse>;
|
|
61
73
|
}
|
package/src/rpc/base/v1/file.ts
CHANGED
|
Binary file
|
|
Binary file
|
|
@@ -36,7 +36,6 @@ export const useSettingStore = defineStore('setting', () => {
|
|
|
36
36
|
aiEnabled.value = false
|
|
37
37
|
return
|
|
38
38
|
}
|
|
39
|
-
applyCustomLocaleMessages(res.i18n_customs ?? [])
|
|
40
39
|
const nextData = new Map<string, string>()
|
|
41
40
|
res.configs.forEach((item) => {
|
|
42
41
|
nextData.set(item.key, item.value)
|
|
@@ -63,9 +62,24 @@ export const useSettingStore = defineStore('setting', () => {
|
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
|
|
65
|
+
/** 登录成功后加载当前租户的自定义国际化覆盖项。 */
|
|
66
|
+
const loadI18nCustom = async () => {
|
|
67
|
+
const response = await defConfigService.GetI18nCustom({
|
|
68
|
+
site: BaseConfigSite.BASE_CONFIG_SITE_APP,
|
|
69
|
+
})
|
|
70
|
+
applyCustomLocaleMessages(response.items ?? [])
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** 清空租户自定义翻译并恢复静态语言包。 */
|
|
74
|
+
const resetI18nCustom = () => {
|
|
75
|
+
applyCustomLocaleMessages([])
|
|
76
|
+
}
|
|
77
|
+
|
|
66
78
|
return {
|
|
67
79
|
getData,
|
|
68
80
|
aiEnabled,
|
|
69
81
|
loadData,
|
|
82
|
+
loadI18nCustom,
|
|
83
|
+
resetI18nCustom,
|
|
70
84
|
}
|
|
71
85
|
})
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
setTokenExpiresIn,
|
|
21
21
|
hasValidToken,
|
|
22
22
|
} from '../../utils/auth'
|
|
23
|
+
import { useSettingStore } from './setting'
|
|
23
24
|
|
|
24
25
|
const AUTH_SILENT_LOGOUT_EVENT = 'auth:silent-logout'
|
|
25
26
|
let silentLogoutEventHandler: (() => void) | undefined
|
|
@@ -74,6 +75,12 @@ export const useUserStore = defineStore(
|
|
|
74
75
|
setToken(token_type + ' ' + access_token)
|
|
75
76
|
setRefreshToken(refresh_token)
|
|
76
77
|
setTokenExpiresIn(expires_in)
|
|
78
|
+
const settingStore = useSettingStore()
|
|
79
|
+
try {
|
|
80
|
+
await settingStore.loadI18nCustom()
|
|
81
|
+
} catch {
|
|
82
|
+
settingStore.resetI18nCustom()
|
|
83
|
+
}
|
|
77
84
|
await runUserStoreExtensions('onLogin')
|
|
78
85
|
}
|
|
79
86
|
|
|
@@ -223,6 +230,7 @@ export const useUserStore = defineStore(
|
|
|
223
230
|
async function clearUserData() {
|
|
224
231
|
clearToken()
|
|
225
232
|
userInfo.value = undefined
|
|
233
|
+
useSettingStore().resetI18nCustom()
|
|
226
234
|
await runUserStoreExtensions('onLogout')
|
|
227
235
|
}
|
|
228
236
|
|
|
@@ -230,6 +238,7 @@ export const useUserStore = defineStore(
|
|
|
230
238
|
function silentLogout() {
|
|
231
239
|
clearToken()
|
|
232
240
|
userInfo.value = undefined
|
|
241
|
+
useSettingStore().resetI18nCustom()
|
|
233
242
|
uni.removeStorageSync('user')
|
|
234
243
|
void runUserStoreExtensions('onSilentLogout')
|
|
235
244
|
}
|
|
@@ -248,6 +257,7 @@ export const useUserStore = defineStore(
|
|
|
248
257
|
}
|
|
249
258
|
silentLogoutEventHandler = () => {
|
|
250
259
|
userInfo.value = undefined
|
|
260
|
+
useSettingStore().resetI18nCustom()
|
|
251
261
|
void runUserStoreExtensions('onSilentLogout')
|
|
252
262
|
}
|
|
253
263
|
uni.$on(AUTH_SILENT_LOGOUT_EVENT, silentLogoutEventHandler)
|