@kengic/uni 0.7.14-beta.4 → 0.7.14-beta.5

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.
@@ -1,21 +1,21 @@
1
- // noinspection ES6UnusedImports
2
-
3
- import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
- import * as DEF from '../../../def';
5
- import { keys } from '../../models';
6
-
7
- /** 请求参数. */
8
- export class GetLatestApkVersionQuery {}
9
-
10
- /**
11
- * 获取 APK 最新的版本号.
12
- *
13
- * @param config 请求配置.
14
- * @param option 请求选项.
15
- */
16
- export function GetLatestApkVersion(config?: IRequestConfig<GetLatestApkVersionQuery, {}>, option?: IRequestOptions): Promise<string> {
17
- return httpClient().request({ method: GetLatestApkVersion.method, url: GetLatestApkVersion.url, ...(config ?? {}) }, option);
18
- }
19
-
20
- GetLatestApkVersion.method = 'GET' as const;
21
- GetLatestApkVersion.url = '/sys/common/getLatestApkVersion';
1
+ // noinspection ES6UnusedImports
2
+
3
+ import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
+ import * as DEF from '../../../def';
5
+ import { keys } from '../../models';
6
+
7
+ /** 请求参数. */
8
+ export class GetLatestApkVersionQuery {}
9
+
10
+ /**
11
+ * 获取 APK 最新的版本号.
12
+ *
13
+ * @param config 请求配置.
14
+ * @param option 请求选项.
15
+ */
16
+ export function GetLatestApkVersion(config?: IRequestConfig<GetLatestApkVersionQuery, {}>, option?: IRequestOptions): Promise<string> {
17
+ return httpClient().request({ method: GetLatestApkVersion.method, url: GetLatestApkVersion.url, ...(config ?? {}) }, option);
18
+ }
19
+
20
+ GetLatestApkVersion.method = 'GET' as const;
21
+ GetLatestApkVersion.url = '/sys/common/getLatestApkVersion';
@@ -1 +1 @@
1
- export { GetLatestApkVersion, GetLatestApkVersionQuery } from './GetLatestApkVersion';
1
+ export { GetLatestApkVersion, GetLatestApkVersionQuery } from './GetLatestApkVersion';
@@ -1,21 +1,21 @@
1
- // noinspection ES6UnusedImports
2
-
3
- import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
- import * as DEF from '../../../def';
5
- import { keys } from '../../models';
6
-
7
- /** 请求参数. */
8
- export class GetUserInfoQuery {}
9
-
10
- /**
11
- * 获取用户信息.
12
- *
13
- * @param config 请求配置.
14
- * @param option 请求选项.
15
- */
16
- export function GetUserInfo(config?: IRequestConfig<GetUserInfoQuery, {}>, option?: IRequestOptions): Promise<Record<any, any>> {
17
- return httpClient().request({ method: GetUserInfo.method, url: GetUserInfo.url, ...(config ?? {}) }, option);
18
- }
19
-
20
- GetUserInfo.method = 'GET' as const;
21
- GetUserInfo.url = '/sys/getUserInfo';
1
+ // noinspection ES6UnusedImports
2
+
3
+ import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
+ import * as DEF from '../../../def';
5
+ import { keys } from '../../models';
6
+
7
+ /** 请求参数. */
8
+ export class GetUserInfoQuery {}
9
+
10
+ /**
11
+ * 获取用户信息.
12
+ *
13
+ * @param config 请求配置.
14
+ * @param option 请求选项.
15
+ */
16
+ export function GetUserInfo(config?: IRequestConfig<GetUserInfoQuery, {}>, option?: IRequestOptions): Promise<Record<any, any>> {
17
+ return httpClient().request({ method: GetUserInfo.method, url: GetUserInfo.url, ...(config ?? {}) }, option);
18
+ }
19
+
20
+ GetUserInfo.method = 'GET' as const;
21
+ GetUserInfo.url = '/sys/getUserInfo';
@@ -1,21 +1,21 @@
1
- // noinspection ES6UnusedImports
2
-
3
- import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
- import * as DEF from '../../../def';
5
- import { keys } from '../../models';
6
-
7
- /** 请求参数. */
8
- export class LogoutQuery {}
9
-
10
- /**
11
- * 退出登录.
12
- *
13
- * @param config 请求配置.
14
- * @param option 请求选项.
15
- */
16
- export function Logout(config?: IRequestConfig<LogoutQuery, {}>, option?: IRequestOptions): Promise<Record<any, any>> {
17
- return httpClient().request({ method: Logout.method, url: Logout.url, ...(config ?? {}) }, option);
18
- }
19
-
20
- Logout.method = 'GET' as const;
21
- Logout.url = '/sys/logout';
1
+ // noinspection ES6UnusedImports
2
+
3
+ import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
+ import * as DEF from '../../../def';
5
+ import { keys } from '../../models';
6
+
7
+ /** 请求参数. */
8
+ export class LogoutQuery {}
9
+
10
+ /**
11
+ * 退出登录.
12
+ *
13
+ * @param config 请求配置.
14
+ * @param option 请求选项.
15
+ */
16
+ export function Logout(config?: IRequestConfig<LogoutQuery, {}>, option?: IRequestOptions): Promise<Record<any, any>> {
17
+ return httpClient().request({ method: Logout.method, url: Logout.url, ...(config ?? {}) }, option);
18
+ }
19
+
20
+ Logout.method = 'GET' as const;
21
+ Logout.url = '/sys/logout';
@@ -1,2 +1,2 @@
1
- export { GetUserInfo, GetUserInfoQuery } from './GetUserInfo';
2
- export { Logout, LogoutQuery } from './Logout';
1
+ export { GetUserInfo, GetUserInfoQuery } from './GetUserInfo';
2
+ export { Logout, LogoutQuery } from './Logout';
@@ -1,45 +1,45 @@
1
- // noinspection ES6UnusedImports
2
-
3
- import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
- import * as DEF from '../../../def';
5
- import { keys } from '../../models';
6
-
7
- /** 请求参数. */
8
- export class ListQuery {
9
- /** 排序字段. */
10
- public column?: string | null;
11
- /** 排序方式. */
12
- public order?: 'asc' | 'desc' | null;
13
- /** 当前页数. */
14
- public pageNo?: number | null;
15
- /** 每页条数. */
16
- public pageSize?: number | null;
17
-
18
- public constructor(obj?: ListQuery) {
19
- keys(obj ?? {}).forEach((key: PropertyKey) => {
20
- switch (key) {
21
- case 'column':
22
- case 'order':
23
- case 'pageNo':
24
- case 'pageSize':
25
- Reflect.set(this, key, Reflect.get(obj ?? {}, key));
26
- break;
27
- default:
28
- break;
29
- }
30
- });
31
- }
32
- }
33
-
34
- /**
35
- * 工作站-分页列表查询.
36
- *
37
- * @param config 请求配置.
38
- * @param option 请求选项.
39
- */
40
- export function List(config?: IRequestConfig<ListQuery, {}>, option?: IRequestOptions): Promise<DEF.WMS.IPage<DEF.WMS.WorkstationDTO>> {
41
- return httpClient().request({ method: List.method, url: List.url, ...(config ?? {}) }, option);
42
- }
43
-
44
- List.method = 'GET' as const;
45
- List.url = '/workstation/workstation/list';
1
+ // noinspection ES6UnusedImports
2
+
3
+ import { httpClient, IRequestConfig, IRequestOptions } from '../../../../service';
4
+ import * as DEF from '../../../def';
5
+ import { keys } from '../../models';
6
+
7
+ /** 请求参数. */
8
+ export class ListQuery {
9
+ /** 排序字段. */
10
+ public column?: string | null;
11
+ /** 排序方式. */
12
+ public order?: 'asc' | 'desc' | null;
13
+ /** 当前页数. */
14
+ public pageNo?: number | null;
15
+ /** 每页条数. */
16
+ public pageSize?: number | null;
17
+
18
+ public constructor(obj?: ListQuery) {
19
+ keys(obj ?? {}).forEach((key: PropertyKey) => {
20
+ switch (key) {
21
+ case 'column':
22
+ case 'order':
23
+ case 'pageNo':
24
+ case 'pageSize':
25
+ Reflect.set(this, key, Reflect.get(obj ?? {}, key));
26
+ break;
27
+ default:
28
+ break;
29
+ }
30
+ });
31
+ }
32
+ }
33
+
34
+ /**
35
+ * 工作站-分页列表查询.
36
+ *
37
+ * @param config 请求配置.
38
+ * @param option 请求选项.
39
+ */
40
+ export function List(config?: IRequestConfig<ListQuery, {}>, option?: IRequestOptions): Promise<DEF.WMS.IPage<DEF.WMS.WorkstationDTO>> {
41
+ return httpClient().request({ method: List.method, url: List.url, ...(config ?? {}) }, option);
42
+ }
43
+
44
+ List.method = 'GET' as const;
45
+ List.url = '/workstation/workstation/list';
@@ -1 +1 @@
1
- export { List, ListQuery } from './List';
1
+ export { List, ListQuery } from './List';
package/api/WMS/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * as WMSAPI from './Controllers';
2
- export * as WMSDEF from './models';
1
+ export * as WMSAPI from './Controllers';
2
+ export * as WMSDEF from './models';
package/api/api.ts CHANGED
@@ -1 +1 @@
1
- export { WMSAPI as WMS } from './WMS';
1
+ export { WMSAPI as WMS } from './WMS';
package/api/def.ts CHANGED
@@ -1 +1 @@
1
- export { WMSDEF as WMS } from './WMS';
1
+ export { WMSDEF as WMS } from './WMS';
package/api/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * as API from './api';
2
- export * as DEF from './def';
1
+ export * as API from './api';
2
+ export * as DEF from './def';
@@ -3,8 +3,7 @@
3
3
  <UniCard :isFull="true" :title="'选择语言'">
4
4
  <view>
5
5
  <view class="body">
6
- <view v-for="item in KG.LOCALE_DATA_LIST" :key="item.code" class="item">{{ item.text }}</view>
7
- <UniDataCheckbox v-model="currentLocale$" :localdata="localeDataList$" />
6
+ <UniDataCheckbox :localdata="localeDataList$$" :modelValue="kg.locale" @update:modelValue="kg.setLocale($event)" />
8
7
  </view>
9
8
  <view class="buttons">
10
9
  <button class="btn btn-cancel" @tap.stop="onCancel()">取消</button>
@@ -17,25 +16,23 @@
17
16
 
18
17
  <!--语言选择-->
19
18
  <script lang="ts" setup>
20
- import { UniDataCheckbox, UniPopup } from '../../uni-ui';
21
- import { ref } from 'vue';
19
+ import { UniCard, UniDataCheckbox, UniPopup } from '../../uni-ui';
20
+ import { computed, ref } from 'vue';
22
21
  import { KG } from '../../model';
22
+ import { useKg } from '../../config';
23
23
 
24
- const emit = defineEmits(['ok']);
24
+ const kg = useKg();
25
25
 
26
26
  //region DATA
27
27
  //----------------------------------------------------------------------------------------------------
28
28
  const popupRef$ = ref<any>(null);
29
29
 
30
- /**
31
- * 当前选择的语言.
32
- */
33
- const currentLocale$ = ref<string>('');
34
-
35
30
  /**
36
31
  * 语言数据列表.
37
32
  */
38
- const localeDataList$ = ref<Array<{ text: string; value: string }>>([]);
33
+ const localeDataList$$ = computed<Array<{ text: string; value: string }>>(() => {
34
+ return KG.LOCALE_DATA_LIST.map((i) => ({ text: i.text, value: i.code }));
35
+ });
39
36
  //----------------------------------------------------------------------------------------------------
40
37
  //endregion
41
38
 
@@ -52,7 +49,6 @@
52
49
  * 语言选择--确定.
53
50
  */
54
51
  function onOk() {
55
- console.log('currentLocale$', currentLocale$.value);
56
52
  popupRef$.value?.close();
57
53
  }
58
54
 
@@ -84,6 +80,20 @@
84
80
  padding: 0px !important;
85
81
  }
86
82
 
83
+ .kg-locale-selector :deep(.uni-card) .body {
84
+ border-bottom: 1px solid #eeeeee;
85
+ margin-bottom: 1px;
86
+ }
87
+
88
+ .kg-locale-selector :deep(.uni-card) .body .uni-data-checklist .checklist-group {
89
+ flex-direction: column;
90
+ }
91
+
92
+ .kg-locale-selector :deep(.uni-card) .body .uni-data-checklist .checklist-group .checklist-box {
93
+ margin: 0;
94
+ padding: 12px;
95
+ }
96
+
87
97
  .kg-locale-selector :deep(.uni-card) .buttons {
88
98
  display: flex;
89
99
  align-items: center;
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <view :class="getClass">
3
- <UniPopup ref="popupRef" type="dialog">
3
+ <UniPopup ref="popupRef$" type="dialog">
4
4
  <UniPopupDialog
5
5
  :beforeClose="true"
6
6
  :cancelText="downloadTask ? '取消升级' : '以后再说'"
@@ -40,7 +40,7 @@
40
40
 
41
41
  //region DATA
42
42
  // ----------------------------------------------------------------------------------------------------
43
- const popupRef = ref<any>(null);
43
+ const popupRef$ = ref<any>(null);
44
44
  /** 下载任务. */
45
45
  const downloadTask = ref<UniNamespace.DownloadTask | null>(null);
46
46
  /** 下载进度. [0, 100] 之间的某个数值, 表示百分比的分子. */
@@ -118,7 +118,7 @@
118
118
 
119
119
  clearInterval(downloadProgressTimer.value);
120
120
 
121
- popupRef.value?.close();
121
+ popupRef$.value?.close();
122
122
  }
123
123
 
124
124
  /**
@@ -131,7 +131,7 @@
131
131
 
132
132
  clearInterval(downloadProgressTimer.value);
133
133
 
134
- popupRef.value?.close();
134
+ popupRef$.value?.close();
135
135
  }
136
136
  //endregion
137
137
 
@@ -142,7 +142,7 @@
142
142
  switch (name) {
143
143
  case 'openKgUpdatePopup':
144
144
  version.value = args[0];
145
- popupRef.value?.open();
145
+ popupRef$.value?.open();
146
146
  break;
147
147
  }
148
148
  });
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <UniPopup ref="popupRef" :type="'dialog'">
2
+ <UniPopup ref="popupRef$" :type="'dialog'">
3
3
  <UniPopupDialog :before-close="true" title="选择仓库" @confirm="onOk">
4
4
  <UniDataCheckbox v-model="currentWhId$" :localdata="warehouseDataList$" />
5
5
  </UniPopupDialog>
@@ -21,7 +21,7 @@
21
21
  const appStore = useAppStore();
22
22
  const kgWarehouse = useKgWarehouse();
23
23
 
24
- const popupRef = ref<any>(null);
24
+ const popupRef$ = ref<any>(null);
25
25
 
26
26
  /**
27
27
  * 当前选择的仓库编号.
@@ -46,13 +46,13 @@
46
46
  /** 确定. */
47
47
  function onOk() {
48
48
  kgWarehouse.store.setWarehouse(warehouseList$.value.find((i) => i.whId === currentWhId$.value));
49
- popupRef.value?.close();
49
+ popupRef$.value?.close();
50
50
  emit('ok');
51
51
  }
52
52
 
53
53
  /** 打开弹窗. */
54
54
  function open() {
55
- popupRef.value?.open();
55
+ popupRef$.value?.open();
56
56
  requestWarehouses();
57
57
  }
58
58
 
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <UniPopup ref="popupRef" :type="'dialog'">
2
+ <UniPopup ref="popupRef$" :type="'dialog'">
3
3
  <UniPopupDialog :before-close="true" title="选择工作站" @close="onClose" @confirm="onOk">
4
4
  <div class="row">
5
5
  <div class="label">工作站:</div>
@@ -41,7 +41,7 @@
41
41
 
42
42
  //region DATA
43
43
  // ----------------------------------------------------------------------------------------------------
44
- const popupRef = ref<any>(null);
44
+ const popupRef$ = ref<any>(null);
45
45
 
46
46
  /** 当前选择的工作站编号. */
47
47
  const currentDevcod = ref<string>('');
@@ -167,7 +167,7 @@
167
167
  * 取消.
168
168
  */
169
169
  function onClose() {
170
- popupRef.value?.close();
170
+ popupRef$.value?.close();
171
171
  }
172
172
 
173
173
  /**
@@ -182,13 +182,13 @@
182
182
  kgStation.store.setStation(null);
183
183
  }
184
184
 
185
- popupRef.value?.close();
185
+ popupRef$.value?.close();
186
186
  emit('ok');
187
187
  }
188
188
 
189
189
  /** 打开弹窗. */
190
190
  function open() {
191
- popupRef.value?.open();
191
+ popupRef$.value?.open();
192
192
 
193
193
  currentDevcod.value = kgStation.station.value?.devcod ?? '';
194
194
  currentHmewrkare.value = kgStation.station.value?.hmewrkare ?? '';
@@ -69,7 +69,7 @@ export const useAppStore = defineStore('app', {
69
69
  },
70
70
 
71
71
  setApiUrl(apiUrl: string) {
72
- uni.setStorageSync(KG.STORAGE_KEY.API_URL, apiUrl);
72
+ uni.setStorageSync(KG.STORAGE_KEY__API_URL, apiUrl);
73
73
  this.apiUrl = apiUrl;
74
74
  },
75
75
 
@@ -82,12 +82,12 @@ export const useAppStore = defineStore('app', {
82
82
  },
83
83
 
84
84
  setToken(token: string) {
85
- uni.setStorageSync(KG.STORAGE_KEY.TOKEN, token);
85
+ uni.setStorageSync(KG.STORAGE_KEY__TOKEN, token);
86
86
  this.token = token;
87
87
  },
88
88
 
89
89
  setUser(user: SysUser | null) {
90
- uni.setStorageSync(KG.STORAGE_KEY.USER, user);
90
+ uni.setStorageSync(KG.STORAGE_KEY__USER, user);
91
91
  this.user = user;
92
92
  },
93
93
  },
@@ -121,11 +121,11 @@ export const useAppStore = defineStore('app', {
121
121
  },
122
122
  },
123
123
  state: (): IAppState => ({
124
- apiUrl: uni.getStorageSync(KG.STORAGE_KEY.API_URL) ?? '',
124
+ apiUrl: uni.getStorageSync(KG.STORAGE_KEY__API_URL) ?? '',
125
125
  isUpdateCancel: false,
126
126
  locale: 'zh_CN',
127
- token: uni.getStorageSync(KG.STORAGE_KEY.TOKEN) ?? '',
128
- user: uni.getStorageSync(KG.STORAGE_KEY.USER) ?? {},
127
+ token: uni.getStorageSync(KG.STORAGE_KEY__TOKEN) ?? '',
128
+ user: uni.getStorageSync(KG.STORAGE_KEY__USER) ?? {},
129
129
  userWarehouses: undefined,
130
130
  }),
131
131
  });
@@ -1,29 +1,18 @@
1
- import { computed, ComputedRef, unref } from 'vue';
2
1
  import { useKgStore } from './config.store';
3
2
 
4
- export type IUseKg = {
5
- /**
6
- * 当前语言.
7
- */
8
- currentLocale$$: ComputedRef<string>;
9
- } & ReturnType<typeof useKgStore>;
3
+ export type IUseKg = {} & ReturnType<typeof useKgStore>;
10
4
 
11
5
  export function useKg(): IUseKg {
12
6
  const store = useKgStore();
13
7
 
14
- return new Proxy(
15
- {
16
- currentLocale$$: computed(() => unref(uni.getLocale() || 'zh_CN')),
17
- } as IUseKg,
18
- {
19
- get(target, p): any {
20
- // 将部分属性直接代理给状态管理对象(store), 这样就可以直接访问 store 上的所有属性和方法,
21
- if (!(p in target) && p in store) {
22
- return Reflect.get(store, p);
23
- }
8
+ return new Proxy({} as IUseKg, {
9
+ get(target, p): any {
10
+ // 将部分属性直接代理给状态管理对象(store), 这样就可以直接访问 store 上的所有属性和方法,
11
+ if (!(p in target) && p in store) {
12
+ return Reflect.get(store, p);
13
+ }
24
14
 
25
- return Reflect.get(target, p);
26
- },
15
+ return Reflect.get(target, p);
27
16
  },
28
- );
17
+ });
29
18
  }
@@ -1,26 +1,29 @@
1
- import { ____DEBUG____, KgCoreUtil } from '@kengic/core.core';
2
- import { values } from 'lodash-es';
1
+ import { KgCoreUtil } from '@kengic/core.core';
3
2
  import { defineStore } from 'pinia';
4
3
  import { computed, ref } from 'vue';
5
4
  import { API } from '../api';
6
5
  import { DescriptionDTO, VarConfigDescription } from '../api/WMS/models';
7
6
  import { KG, KgStoreDefinition } from '../model';
8
- import { KgUtil } from '../util';
9
- import { useKg } from './config.hooks';
10
7
 
11
8
  //region GETTERS 类型定义
12
9
  //----------------------------------------------------------------------------------------------------
13
10
  export interface IUseKgStoreGetters {
11
+ /**
12
+ * 默认语言.
13
+ */
14
+ defaultLocale: string;
15
+
14
16
  /**
15
17
  * 根据 codeName 和 codeValue 获取当前语言下的某个描述.
16
18
  */
17
19
  getDescription: (param: { codeName: string | null | undefined; codeValue: string | null | undefined }) => DescriptionDTO | null;
18
20
 
19
21
  /**
20
- * 根据 codeName 获取当前语言下的它的所有描述.
22
+ * 当前语言.
21
23
  */
22
- getDescriptionList: (param: { codeName: string | null | undefined }) => Array<DescriptionDTO>;
24
+ locale: string;
23
25
  }
26
+
24
27
  //----------------------------------------------------------------------------------------------------
25
28
  //endregion
26
29
 
@@ -28,19 +31,18 @@ export interface IUseKgStoreGetters {
28
31
  //----------------------------------------------------------------------------------------------------
29
32
  export interface IUseKgStoreActions {
30
33
  /**
31
- * 请求某组描述数据.
34
+ * 请求某组变量描述数据.
32
35
  *
33
- * @param param.codeName 描述组名.
34
- * @param param.isForceRequest 是否强制请求, 即无论是否已经请求过该组, 始终重新请求, 默认为 true.
36
+ * @param param.fid 界面标识.
35
37
  */
36
- requestDescriptionList(param: { codeName: string | null | undefined; isForceRequest?: boolean | null | undefined }): Promise<void>;
38
+ requestVarConfigDescriptionList(param: { fid: string | null | undefined }): Promise<void>;
37
39
 
38
40
  /**
39
- * 请求某组变量描述数据.
41
+ * 设置默认语言.
40
42
  *
41
- * @param param.fid 界面标识.
43
+ * @param value 默认语言.
42
44
  */
43
- requestVarConfigDescriptionList(param: { fid: string | null | undefined }): Promise<void>;
45
+ setDefaultLocale(value?: string | null): void;
44
46
 
45
47
  /**
46
48
  * 设置某组描述的数据.
@@ -50,6 +52,13 @@ export interface IUseKgStoreActions {
50
52
  */
51
53
  setDescriptionList(param: { codeName: string | null | undefined; descriptions: Array<DescriptionDTO> }): void;
52
54
 
55
+ /**
56
+ * 设置当前语言.
57
+ *
58
+ * @param value 当前语言.
59
+ */
60
+ setLocale(value?: string | null): void;
61
+
53
62
  /**
54
63
  * 翻译.
55
64
  *
@@ -59,6 +68,7 @@ export interface IUseKgStoreActions {
59
68
  */
60
69
  t(key: string | null | undefined, param?: Record<string, any> | null | undefined, defaultValue?: string | null | undefined): string;
61
70
  }
71
+
62
72
  //----------------------------------------------------------------------------------------------------
63
73
  //endregion
64
74
 
@@ -71,8 +81,9 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
71
81
 
72
82
  //region STATE
73
83
  //----------------------------------------------------------------------------------------------------
74
- const descriptionMap$ = ref<Record<string, Record<string, DescriptionDTO>>>({});
75
- const isDescriptionsRequestingMap$ = ref<Record<string, boolean>>({});
84
+ const descriptionRecord$ = ref<Record<string, Record<string, DescriptionDTO>>>({});
85
+ const defaultLocale$ = ref<string>(KG.LOCALE.ZH_CN);
86
+ const locale$ = ref<string>('');
76
87
  //----------------------------------------------------------------------------------------------------
77
88
  //endregion
78
89
 
@@ -84,17 +95,30 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
84
95
  return null;
85
96
  }
86
97
 
87
- return descriptionMap$.value[codeName]?.[codeValue] ?? null;
98
+ return descriptionRecord$.value[codeName]?.[codeValue] ?? null;
88
99
  });
89
100
 
90
- const getDescriptionList$$ = computed<(param: { codeName: string | null | undefined }) => Array<DescriptionDTO>>(() => (param) => {
91
- const { codeName } = param ?? {};
101
+ const defaultLocale$$ = computed<string>(() => defaultLocale$.value);
92
102
 
93
- if (!codeName) {
94
- return [];
103
+ const locale$$ = computed<string>(() => {
104
+ // 如果属性有值, 表示用户已通过语言选择弹窗选择了某个语言,
105
+ if (locale$.value) {
106
+ return locale$.value;
95
107
  }
96
108
 
97
- return [...values(descriptionMap$.value[codeName])];
109
+ // 如果本地存储有值, 表示用户上次已通过语言选择弹窗选择了某个语言, 但是又重新启动了应用,
110
+ const storeLocale = uni.getStorageSync(KG.STORAGE_KEY__LOCALE);
111
+ if (storeLocale) {
112
+ locale$.value = storeLocale;
113
+ return locale$.value;
114
+ }
115
+
116
+ if (defaultLocale$.value) {
117
+ setLocale(defaultLocale$.value);
118
+ return locale$.value;
119
+ }
120
+
121
+ return KG.LOCALE.ZH_CN;
98
122
  });
99
123
 
100
124
  //----------------------------------------------------------------------------------------------------
@@ -102,47 +126,6 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
102
126
 
103
127
  //region ACTIONS
104
128
  //----------------------------------------------------------------------------------------------------
105
-
106
- async function requestDescriptionList(param: { codeName: string | null | undefined; isForceRequest?: boolean | null | undefined }): Promise<void> {
107
- const { codeName, isForceRequest } = param ?? {};
108
-
109
- if (!codeName) {
110
- return;
111
- }
112
-
113
- // 正在请求该组描述, 禁止重复请求,
114
- if (isDescriptionsRequestingMap$.value[codeName]) {
115
- ____DEBUG____(`kg.requestDescriptionList() | 正在查询, 不许重复查询. | { codeName: ${codeName}`);
116
- return;
117
- }
118
-
119
- // 该组描述已经请求过了, 不再请求,
120
- const codeNameMap = descriptionMap$.value[codeName];
121
- if (codeNameMap && isForceRequest === false) {
122
- return;
123
- }
124
-
125
- const kg = useKg();
126
-
127
- try {
128
- isDescriptionsRequestingMap$.value[codeName] = true;
129
-
130
- const { records } =
131
- (await API.WMS.DescriptionController.List({
132
- params: {
133
- codnam: codeName,
134
- localeId: 'TODO LT',
135
- pageNo: 1,
136
- pageSize: 999999,
137
- },
138
- })) ?? {};
139
-
140
- setDescriptionList({ codeName: codeName, descriptions: records ?? [] });
141
- } finally {
142
- isDescriptionsRequestingMap$.value[codeName] = false;
143
- }
144
- }
145
-
146
129
  async function requestVarConfigDescriptionList(param: { fid: string | null | undefined }): Promise<void> {
147
130
  if (!param.fid) {
148
131
  return;
@@ -166,17 +149,21 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
166
149
  });
167
150
  }
168
151
 
152
+ function setDefaultLocale(value?: string | null): void {
153
+ locale$.value = value ?? KG.LOCALE.ZH_CN;
154
+ }
155
+
169
156
  function setDescriptionList(param: { codeName: string | null | undefined; descriptions: Array<DescriptionDTO> }): void {
170
157
  const { codeName, descriptions } = param ?? {};
171
158
  if (!codeName) {
172
159
  return;
173
160
  }
174
161
 
175
- let codeNameMap = descriptionMap$.value[codeName];
162
+ let codeNameMap = descriptionRecord$.value[codeName];
176
163
  if (!codeNameMap) {
177
164
  codeNameMap = {};
178
165
 
179
- descriptionMap$.value[codeName] = codeNameMap;
166
+ descriptionRecord$.value[codeName] = codeNameMap;
180
167
  }
181
168
 
182
169
  for (let description of descriptions) {
@@ -186,6 +173,15 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
186
173
  }
187
174
  }
188
175
 
176
+ function setLocale(value?: string | null): void {
177
+ if (!value) {
178
+ return;
179
+ }
180
+
181
+ locale$.value = value;
182
+ uni.setStorageSync(KG.STORAGE_KEY__LOCALE, value);
183
+ }
184
+
189
185
  function t(key: string | null | undefined, param?: Record<string, any> | null | undefined, defaultValue?: string | null | undefined): string {
190
186
  if (!key) {
191
187
  return '';
@@ -222,13 +218,16 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
222
218
  //endregion
223
219
 
224
220
  return {
225
- descriptionMap$: descriptionMap$,
221
+ defaultLocale: defaultLocale$$,
222
+ defaultLocale$: defaultLocale$,
223
+ descriptionRecord$: descriptionRecord$,
226
224
  getDescription: getDescription$$,
227
- getDescriptionList: getDescriptionList$$,
228
- isDescriptionsRequestingMap$: isDescriptionsRequestingMap$,
229
- requestDescriptionList: requestDescriptionList,
225
+ locale: locale$$,
226
+ locale$: locale$,
230
227
  requestVarConfigDescriptionList: requestVarConfigDescriptionList,
228
+ setDefaultLocale: setDefaultLocale,
231
229
  setDescriptionList: setDescriptionList,
230
+ setLocale: setLocale,
232
231
  t: t,
233
232
  };
234
233
  });
package/config/index.ts CHANGED
@@ -1,13 +1,30 @@
1
+ import { IKgLocale } from '@kengic/core.core';
2
+ import { useKg } from './config.hooks';
3
+
1
4
  //region 配置
2
5
  //----------------------------------------------------------------------------------------------------
3
- type IKgConfigParameter = {};
6
+ type IKgConfigParameter = {
7
+ /**
8
+ * 可选择的语言列表. 默认为所有语言.
9
+ */
10
+ $i18n$AvailableLocaleList?: Array<IKgLocale>;
11
+
12
+ /**
13
+ * 默认语言. 默认为简体中文(zh_CN).
14
+ */
15
+ $i18n$DefaultLocale?: IKgLocale;
16
+ };
4
17
 
5
18
  /**
6
19
  * 初始化组件库.
7
20
  *
8
21
  * @param param 参数.
9
22
  */
10
- function kgConfig(param: IKgConfigParameter): void {}
23
+ function kgConfig(param?: IKgConfigParameter): void {
24
+ const kg = useKg();
25
+
26
+ kg.setDefaultLocale(param?.$i18n$DefaultLocale);
27
+ }
11
28
 
12
29
  /** @deprecated 已废弃, 请使用 {@link kgConfig()} */
13
30
  const setup = kgConfig;
@@ -18,3 +35,4 @@ export { kgConfig, setup };
18
35
 
19
36
  export * from './config.hooks';
20
37
  export * from './config.store';
38
+ export * from './app.store';
package/model/index.ts CHANGED
@@ -95,13 +95,24 @@ const KG = {
95
95
  ...KGCORE,
96
96
 
97
97
  /**
98
- * 本地存储的键.
98
+ * 本地存储的键--后端接口地址.
99
99
  */
100
- STORAGE_KEY: {
101
- API_URL: 'ApiUrl',
102
- TOKEN: 'Token',
103
- USER: 'User',
104
- },
100
+ STORAGE_KEY__API_URL: 'Kg.ApiUrl',
101
+
102
+ /**
103
+ * 本地存储的键--当前语言.
104
+ */
105
+ STORAGE_KEY__LOCALE: 'Kg.Locale',
106
+
107
+ /**
108
+ * 本地存储的键--登录凭证.
109
+ */
110
+ STORAGE_KEY__TOKEN: 'Kg.Token',
111
+
112
+ /**
113
+ * 本地存储的键--当前登录用户.
114
+ */
115
+ STORAGE_KEY__USER: 'Kg.User',
105
116
  };
106
117
 
107
118
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kengic/uni",
3
- "version": "0.7.14-beta.4",
3
+ "version": "0.7.14-beta.5",
4
4
  "scripts": {
5
5
  "postinstall": "node bin/postinstall.mjs"
6
6
  },
@@ -18,7 +18,7 @@
18
18
  "@dcloudio/uni-i18n": "3.0.0-alpha-3080220230428001",
19
19
  "@dcloudio/uni-stacktracey": "3.0.0-alpha-3080220230428001",
20
20
  "@dcloudio/vite-plugin-uni": "3.0.0-alpha-3080220230428001",
21
- "@kengic/core.core": "0.0.2-beta.0",
21
+ "@kengic/core.core": "0.0.2-beta.1",
22
22
  "@kengic/pont": "2.1.2",
23
23
  "@types/lodash-es": "4.17.12",
24
24
  "@types/node": "18.16.3",
package/page/KgPageMy.vue CHANGED
@@ -26,8 +26,8 @@
26
26
 
27
27
  <script setup lang="ts">
28
28
  import { computed, ref } from 'vue';
29
- import { useAppStore } from '../config/app.store';
30
- import { KgTabBar, KgUpdateNotice, KgWarehouseSelector, KgWorkStationSelector, useKgStation, useKgWarehouse } from '../component';
29
+ import { useAppStore } from '../config';
30
+ import { KgLocaleSelector, KgTabBar, KgUpdateNotice, KgWarehouseSelector, KgWorkStationSelector, useKgStation, useKgWarehouse } from '../component';
31
31
  import { UniList, UniListItem } from '../uni-ui';
32
32
  import { KgUtil } from '../util';
33
33