@liujitcn/kratos-uni-app-core 0.0.55 → 0.0.57

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 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
@@ -7,7 +7,7 @@
7
7
  "type": "git",
8
8
  "url": "git@github.com:liujitcn/kratos-admin.git"
9
9
  },
10
- "version": "0.0.55",
10
+ "version": "0.0.57",
11
11
  "type": "module",
12
12
  "files": [
13
13
  "dist",
@@ -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()
@@ -54,6 +54,9 @@ const messageBadge = useAppMenuBadge('MESSAGE_INBOX')
54
54
 
55
55
  <style scoped>
56
56
  .kratos-tab-bar {
57
+ --kratos-tab-bar-color: #333;
58
+ --kratos-tab-bar-active-color: #27ba9b;
59
+
57
60
  position: fixed;
58
61
  right: 0;
59
62
  bottom: 0;
@@ -74,7 +77,7 @@ const messageBadge = useAppMenuBadge('MESSAGE_INBOX')
74
77
  justify-content: center;
75
78
  flex-direction: column;
76
79
  transform: translateY(clamp(1px, env(safe-area-inset-bottom), 7px));
77
- color: #333;
80
+ color: var(--kratos-tab-bar-color);
78
81
  font-size: 10px;
79
82
  line-height: 12px;
80
83
  }
@@ -88,7 +91,7 @@ const messageBadge = useAppMenuBadge('MESSAGE_INBOX')
88
91
  width: 22px;
89
92
  height: 18px;
90
93
  margin-bottom: 6px;
91
- border: 2px solid #9aa4b2;
94
+ border: 2px solid var(--kratos-tab-bar-color);
92
95
  border-radius: 6px;
93
96
  box-sizing: border-box;
94
97
  }
@@ -99,10 +102,10 @@ const messageBadge = useAppMenuBadge('MESSAGE_INBOX')
99
102
  width: 3px;
100
103
  height: 3px;
101
104
  border-radius: 50%;
102
- background: #9aa4b2;
105
+ background: var(--kratos-tab-bar-color);
103
106
  box-shadow:
104
- 5px 0 #9aa4b2,
105
- 10px 0 #9aa4b2;
107
+ 5px 0 var(--kratos-tab-bar-color),
108
+ 10px 0 var(--kratos-tab-bar-color);
106
109
  content: '';
107
110
  }
108
111
  .kratos-tab-bar__message-icon::after {
@@ -111,26 +114,26 @@ const messageBadge = useAppMenuBadge('MESSAGE_INBOX')
111
114
  left: 3px;
112
115
  width: 7px;
113
116
  height: 7px;
114
- border-right: 2px solid #9aa4b2;
115
- border-bottom: 2px solid #9aa4b2;
117
+ border-right: 2px solid var(--kratos-tab-bar-color);
118
+ border-bottom: 2px solid var(--kratos-tab-bar-color);
116
119
  background: #fff;
117
120
  content: '';
118
121
  transform: rotate(45deg);
119
122
  }
120
123
  .kratos-tab-bar__message-icon--active {
121
- border-color: #27ba9b;
124
+ border-color: var(--kratos-tab-bar-active-color);
122
125
  }
123
126
  .kratos-tab-bar__message-icon--active::before {
124
- background: #27ba9b;
127
+ background: var(--kratos-tab-bar-active-color);
125
128
  box-shadow:
126
- 5px 0 #27ba9b,
127
- 10px 0 #27ba9b;
129
+ 5px 0 var(--kratos-tab-bar-active-color),
130
+ 10px 0 var(--kratos-tab-bar-active-color);
128
131
  }
129
132
  .kratos-tab-bar__message-icon--active::after {
130
- border-color: #27ba9b;
133
+ border-color: var(--kratos-tab-bar-active-color);
131
134
  }
132
135
  .kratos-tab-bar__text--active {
133
- color: #27ba9b;
136
+ color: var(--kratos-tab-bar-active-color);
134
137
  }
135
138
  .kratos-tab-bar__badge {
136
139
  position: absolute;
@@ -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-sync`。语言切换选项固定显示后端 `base_language.native_name`,接口不可用时使用代码内置的原生名称;`common.language.*` 仅用于普通文案和语言迁移初始数据。新增语言的完整文件清单见[国际化语言扩展指南](../../../../../../docs/国际化语言扩展指南.md)。
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
- i18n_customs: I18nCustomItem[];
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
  }
@@ -1,6 +1,6 @@
1
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
2
  // versions:
3
- // protoc-gen-ts_proto v2.12.1
3
+ // protoc-gen-ts_proto v2.11.8
4
4
  // protoc unknown
5
5
  // source: base/v1/file.proto
6
6
 
@@ -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)