@kengic/uni 0.7.15 → 0.7.16

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/bin/bin.mjs CHANGED
@@ -4,15 +4,6 @@ import { bump } from './bump.mjs';
4
4
 
5
5
  const program = new Command();
6
6
 
7
- /**
8
- * 打印日志.
9
- *
10
- * @param message 日志消息.
11
- */
12
- function log(message) {
13
- console.log(`[${new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ')}] [@kengic/uni] COPY-DIST-TO-ANDROID | ${message}`);
14
- }
15
-
16
7
  async function bin() {
17
8
  try {
18
9
  program
@@ -20,6 +11,15 @@ async function bin() {
20
11
  .description('COPY DIST TO ANDROID')
21
12
  .option('--appid <appid>', 'APPID', '')
22
13
  .action(async (args) => {
14
+ /**
15
+ * 打印日志.
16
+ *
17
+ * @param message 日志消息.
18
+ */
19
+ function log(message) {
20
+ console.log(`[${new Date(Date.now() + 1000 * 60 * 60 * 8).toISOString().substring(0, 23).replace('T', ' ')}] [@kengic/uni] COPY-DIST-TO-ANDROID | ${message}`);
21
+ }
22
+
23
23
  try {
24
24
  log(`命令参数 | ${JSON.stringify(args)}`);
25
25
  log(`当前目录 | ${process.cwd()}`);
@@ -3,7 +3,7 @@
3
3
  <UniCard :isFull="true" class="popupCard" :title="kg.t('pda.KgApiUil.Title', {}, '配置后端服务地址')">
4
4
  <view>
5
5
  <view class="body">
6
- <UniEasyinput v-model="apiUrl$" :clearSize="24" :disabled="isRequestDoing$" :focus="true" placeholder="http://127.0.0.1:8080/" trim></UniEasyinput>
6
+ <UniEasyinput v-model="apiUrl$" :clearSize="24" :disabled="isRequestDoing$" :focus="true" :trim="true" placeholder="http://127.0.0.1:8080/" />
7
7
  </view>
8
8
  <view class="buttons">
9
9
  <button :disabled="isRequestDoing$" :type="'default' as any" class="btn btn-cancel" @tap.stop="onCancel()">{{ kg.t('kg.cancel02', {}, '取消') }}</button>
@@ -53,29 +53,36 @@
53
53
  try {
54
54
  appStore.setApiUrl(apiUrl$.value!);
55
55
 
56
- await kg.requestVarConfigDescriptionList();
57
-
58
56
  uni.showToast({ icon: 'none', title: kg.t('pda.KgApiUil.SuccessMessage', {}, '配置成功') });
59
57
 
60
- uni.showModal({
61
- title: kg.t('kg.tip02', {}, '提示'),
62
- content: kg.t('pda.KgApiUil.RelaunchContent', {}, '翻译加载成功, 需要重启应用.'),
63
- confirmText: kg.t('pda.KgApiUil.RelaunchOkText', {}, '立即重启'),
64
- showCancel: false,
65
- success: function (result) {
66
- if (result.confirm) {
67
- kg.setLocale(kg.locale);
68
-
69
- /* #ifdef H5 */
70
- window.location.reload();
71
- /* #endif */
72
-
73
- /* #ifdef APP-PLUS */
74
- popupRef$.value?.close();
75
- /* #endif */
76
- }
77
- },
78
- });
58
+ // 启用国际化,
59
+ if (kg.$i18n$IsOn) {
60
+ await kg.requestVarConfigDescriptionList();
61
+
62
+ uni.showModal({
63
+ title: kg.t('kg.tip02', {}, '提示'),
64
+ content: kg.t('pda.KgApiUil.RelaunchContent', {}, '翻译加载成功, 需要重启应用.'),
65
+ confirmText: kg.t('pda.KgApiUil.RelaunchOkText', {}, '立即重启'),
66
+ showCancel: false,
67
+ success: function (result) {
68
+ if (result.confirm) {
69
+ kg.setLocale(kg.locale);
70
+
71
+ /* #ifdef H5 */
72
+ window.location.reload();
73
+ /* #endif */
74
+
75
+ /* #ifdef APP-PLUS */
76
+ popupRef$.value?.close();
77
+ /* #endif */
78
+ }
79
+ },
80
+ });
81
+ }
82
+ // 禁用国际化,
83
+ else {
84
+ popupRef$.value?.close();
85
+ }
79
86
  } finally {
80
87
  isRequestDoing$.value = false;
81
88
  }
@@ -36,7 +36,7 @@
36
36
  * 回到首页.
37
37
  */
38
38
  function gotoHomePage() {
39
- uni.redirectTo({ url: `/${kg.homePagePath}` });
39
+ uni.redirectTo({ url: `/${kg.$PagePath$Home}` });
40
40
  }
41
41
 
42
42
  //endregion
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <view :id='ID' ref='ref01' class='kg-tab-bar'>
3
- <view :class="{ active: page?.route === kg.homePagePath }" class="item" @tap.stop="goto(kg.homePagePath)">
3
+ <view :class="{ active: page?.route === kg.$PagePath$Home }" class="item" @tap.stop="goto(kg.$PagePath$Home)">
4
4
  <UniIcons :type="'home'" size="24"></UniIcons>
5
5
  <text class="text">{{ kg.t('pda.KgTabBar.Home', {}, '首页') }}</text>
6
6
  </view>
@@ -10,19 +10,29 @@ import { useKg } from './config.hooks';
10
10
  //----------------------------------------------------------------------------------------------------
11
11
  interface IUseKgStoreGetters {
12
12
  /**
13
- * 默认语言.
13
+ * 页面路径--首页. 默认为 'pages/home/index'.
14
14
  */
15
- defaultLocale: string;
15
+ $PagePath$Home: string;
16
16
 
17
17
  /**
18
- * 根据 codeName 和 codeValue 获取当前语言下的某个描述.
18
+ * 页面路径--登录. 默认为 'pages/login/Login'.
19
19
  */
20
- getDescription: (param: { codeName: string | null | undefined; codeValue: string | null | undefined }) => DescriptionDTO | null;
20
+ $PagePath$Login: string;
21
+
22
+ /**
23
+ * 国际化--默认语言. 默认为简体中文(zh_CN).
24
+ */
25
+ $i18n$DefaultLocale: string;
21
26
 
22
27
  /**
23
- * 首页路径. 默认为 'pages/home/index'.
28
+ * 国际化--是否启用功能. 默认为 true.
24
29
  */
25
- homePagePath: string;
30
+ $i18n$IsOn: boolean;
31
+
32
+ /**
33
+ * 根据 codeName 和 codeValue 获取当前语言下的某个描述.
34
+ */
35
+ getDescription: (param: { codeName: string | null | undefined; codeValue: string | null | undefined }) => DescriptionDTO | null;
26
36
 
27
37
  /**
28
38
  * 是否正在请求翻译数据.
@@ -38,11 +48,6 @@ interface IUseKgStoreGetters {
38
48
  * 当前语言名称.
39
49
  */
40
50
  localeText: string;
41
-
42
- /**
43
- * 登录页面路径. 默认为 'pages/login/Login'.
44
- */
45
- loginPagePath: string;
46
51
  }
47
52
 
48
53
  //----------------------------------------------------------------------------------------------------
@@ -57,40 +62,47 @@ interface IUseKgStoreActions {
57
62
  requestVarConfigDescriptionList(): Promise<void>;
58
63
 
59
64
  /**
60
- * 设置默认语言.
65
+ * 页面路径--设置首页页面路径.
61
66
  *
62
- * @param value 默认语言.
67
+ * @param value 首页页面路径.
63
68
  */
64
- setDefaultLocale(value?: string | null): void;
69
+ set$PagePath$Home(value?: string | null): void;
65
70
 
66
71
  /**
67
- * 设置某组描述的数据.
72
+ * 页面路径--设置登录页面路径.
68
73
  *
69
- * @param param.codeName 描述组名.
70
- * @param param.descriptionList 描述数据列表.
74
+ * @param value 登录页面路径.
71
75
  */
72
- setDescriptionList(param: { codeName: string | null | undefined; descriptionList: Array<DescriptionDTO> }): void;
76
+ set$PagePath$Login(value?: string | null): void;
73
77
 
74
78
  /**
75
- * 设置首页路径.
79
+ * 国际化--设置默认语言.
76
80
  *
77
- * @param value 首页路径.
81
+ * @param value 默认语言.
78
82
  */
79
- setHomePagePath(value?: string | null): void;
83
+ set$i18n$DefaultLocale(value?: string | null): void;
80
84
 
81
85
  /**
82
- * 设置当前语言.
86
+ * 国际化--设置是否启用功能.
83
87
  *
84
- * @param value 当前语言.
88
+ * @param value 是否启用功能.
85
89
  */
86
- setLocale(value?: string | null): void;
90
+ set$i18n$IsOn(value?: boolean | null): void;
87
91
 
88
92
  /**
89
- * 设置登录页面路径.
93
+ * 设置某组描述的数据.
90
94
  *
91
- * @param value 登录页面路径.
95
+ * @param param.codeName 描述组名.
96
+ * @param param.descriptionList 描述数据列表.
97
+ */
98
+ setDescriptionList(param: { codeName: string | null | undefined; descriptionList: Array<DescriptionDTO> }): void;
99
+
100
+ /**
101
+ * 设置当前语言.
102
+ *
103
+ * @param value 当前语言.
92
104
  */
93
- setLoginPagePath(value?: string | null): void;
105
+ setLocale(value?: string | null): void;
94
106
 
95
107
  /**
96
108
  * 翻译.
@@ -115,9 +127,10 @@ const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreActions> = de
115
127
  //region STATE
116
128
  //----------------------------------------------------------------------------------------------------
117
129
  const descriptionRecord$ = ref<Record<string, Record<string, DescriptionDTO>>>({});
118
- const defaultLocale$ = ref<string>(KG.LOCALE.ZH_CN);
119
- const homePagePath$ = ref<string>('pages/home/index');
120
- const loginPagePath$ = ref<string>('pages/login/Login');
130
+ const $i18n$DefaultLocale$ = ref<string>(KG.LOCALE.ZH_CN);
131
+ const $i18n$IsOn$ = ref<boolean>(true);
132
+ const $PagePath$Home$ = ref<string>('pages/home/index');
133
+ const $PagePath$Login$ = ref<string>('pages/login/Login');
121
134
  const isRequestVarConfigDescriptionListDoing$ = ref<boolean>(false);
122
135
  const locale$ = ref<string>('');
123
136
  //----------------------------------------------------------------------------------------------------
@@ -134,9 +147,10 @@ const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreActions> = de
134
147
  return descriptionRecord$.value[codeName]?.[codeValue] ?? null;
135
148
  });
136
149
 
137
- const defaultLocale$$ = computed<string>(() => defaultLocale$.value);
138
- const homePagePath$$ = computed<string>(() => homePagePath$.value);
139
- const loginPagePath$$ = computed<string>(() => loginPagePath$.value);
150
+ const $i18n$DefaultLocale$$ = computed<string>(() => $i18n$DefaultLocale$.value);
151
+ const $i18n$IsOn$$ = computed<boolean>(() => $i18n$IsOn$.value);
152
+ const $PagePath$Home$$ = computed<string>(() => $PagePath$Home$.value);
153
+ const $PagePath$Login$$ = computed<string>(() => $PagePath$Login$.value);
140
154
  const isRequestVarConfigDescriptionListDoing$$ = computed<boolean>(() => isRequestVarConfigDescriptionListDoing$.value);
141
155
 
142
156
  const locale$$ = computed<string>(() => {
@@ -151,8 +165,8 @@ const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreActions> = de
151
165
  return storeLocale;
152
166
  }
153
167
 
154
- if (defaultLocale$.value) {
155
- return defaultLocale$.value;
168
+ if ($i18n$DefaultLocale$.value) {
169
+ return $i18n$DefaultLocale$.value;
156
170
  }
157
171
 
158
172
  return KG.LOCALE.ZH_CN;
@@ -215,8 +229,12 @@ const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreActions> = de
215
229
  }
216
230
  }
217
231
 
218
- function setDefaultLocale(value?: string | null): void {
219
- defaultLocale$.value = value ?? KG.LOCALE.ZH_CN;
232
+ function set$i18n$DefaultLocale(value?: string | null): void {
233
+ $i18n$DefaultLocale$.value = value ?? KG.LOCALE.ZH_CN;
234
+ }
235
+
236
+ function set$i18n$IsOn(value?: boolean | null): void {
237
+ $i18n$IsOn$.value = value ?? true;
220
238
  }
221
239
 
222
240
  function setDescriptionList(param: { codeName: string | null | undefined; descriptionList: Array<DescriptionDTO> }): void {
@@ -237,12 +255,12 @@ const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreActions> = de
237
255
  }
238
256
  }
239
257
 
240
- function setHomePagePath(value?: string | null) {
241
- homePagePath$.value = value ?? 'pages/home/index';
258
+ function set$PagePath$Home(value?: string | null) {
259
+ $PagePath$Home$.value = value ?? 'pages/home/index';
242
260
  }
243
261
 
244
- function setLoginPagePath(value?: string | null) {
245
- loginPagePath$.value = value ?? 'pages/login/Login';
262
+ function set$PagePath$Login(value?: string | null) {
263
+ $PagePath$Login$.value = value ?? 'pages/login/Login';
246
264
  }
247
265
 
248
266
  function setLocale(value?: string | null): void {
@@ -301,25 +319,28 @@ const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreActions> = de
301
319
  //endregion
302
320
 
303
321
  return {
304
- defaultLocale: defaultLocale$$,
305
- defaultLocale$: defaultLocale$,
322
+ $PagePath$Home: $PagePath$Home$$,
323
+ $PagePath$Home$: $PagePath$Home$,
324
+ $PagePath$Login: $PagePath$Login$$,
325
+ $PagePath$Login$: $PagePath$Login$,
326
+ $i18n$DefaultLocale: $i18n$DefaultLocale$$,
327
+ $i18n$DefaultLocale$: $i18n$DefaultLocale$,
328
+ $i18n$IsOn: $i18n$IsOn$$,
329
+ $i18n$IsOn$: $i18n$IsOn$,
306
330
  descriptionRecord$: descriptionRecord$,
307
331
  getDescription: getDescription$$,
308
- homePagePath: homePagePath$$,
309
- homePagePath$: homePagePath$,
310
332
  isRequestVarConfigDescriptionListDoing: isRequestVarConfigDescriptionListDoing$$,
311
333
  isRequestVarConfigDescriptionListDoing$: isRequestVarConfigDescriptionListDoing$,
312
334
  locale: locale$$,
313
335
  locale$: locale$,
314
336
  localeText: localeText$$,
315
- loginPagePath: loginPagePath$$,
316
- loginPagePath$: loginPagePath$,
317
337
  requestVarConfigDescriptionList: requestVarConfigDescriptionList,
318
- setDefaultLocale: setDefaultLocale,
338
+ set$PagePath$Home: set$PagePath$Home,
339
+ set$PagePath$Login: set$PagePath$Login,
340
+ set$i18n$DefaultLocale: set$i18n$DefaultLocale,
341
+ set$i18n$IsOn: set$i18n$IsOn,
319
342
  setDescriptionList: setDescriptionList,
320
- setHomePagePath: setHomePagePath,
321
343
  setLocale: setLocale,
322
- setLoginPagePath: setLoginPagePath,
323
344
  t: t,
324
345
  };
325
346
  });
package/config/index.ts CHANGED
@@ -7,34 +7,34 @@ import { KgUtil } from '../util';
7
7
  //----------------------------------------------------------------------------------------------------
8
8
  type IKgConfigParameter = {
9
9
  /**
10
- * 可选择的语言列表. 默认为所有语言.
10
+ * 页面路径--首页. 默认为 'pages/home/index'.
11
11
  */
12
- $i18n$AvailableLocaleList?: Array<IKgLocale>;
12
+ $PagePath$Home?: string;
13
13
 
14
14
  /**
15
- * 默认语言. 默认为简体中文(zh_CN).
15
+ * 页面路径--登录. 默认为 'pages/login/Login'.
16
16
  */
17
- $i18n$DefaultLocale?: IKgLocale;
17
+ $PagePath$Login?: string;
18
18
 
19
19
  /**
20
- * 应用实例.
20
+ * 国际化--可选择的语言列表. 默认为所有语言.
21
21
  */
22
- app: App;
22
+ $i18n$AvailableLocaleList?: Array<IKgLocale>;
23
23
 
24
24
  /**
25
- * 首页路径. 默认为 'pages/home/index'.
25
+ * 国际化--默认语言. 默认为简体中文(zh_CN).
26
26
  */
27
- homePagePath?: string;
27
+ $i18n$DefaultLocale?: IKgLocale;
28
28
 
29
29
  /**
30
- * 是否请求翻译数据. 默认为 true.
30
+ * 国际化--是否启用功能. 默认为 true.
31
31
  */
32
- isRequestDescriptionList?: boolean;
32
+ $i18n$IsOn?: boolean;
33
33
 
34
34
  /**
35
- * 登录页面路径. 默认为 'pages/login/Login'.
35
+ * 应用实例.
36
36
  */
37
- loginPagePath?: string;
37
+ app: App;
38
38
  };
39
39
 
40
40
  /**
@@ -45,18 +45,18 @@ type IKgConfigParameter = {
45
45
  async function kgConfig(param?: IKgConfigParameter): Promise<void> {
46
46
  const kg = useKg();
47
47
 
48
- kg.setDefaultLocale(param?.$i18n$DefaultLocale);
48
+ kg.set$i18n$DefaultLocale(param?.$i18n$DefaultLocale);
49
+ kg.set$i18n$IsOn(param?.$i18n$IsOn);
49
50
  kg.setLocale(kg.locale);
50
- kg.setHomePagePath(param?.homePagePath);
51
- kg.setLoginPagePath(param?.loginPagePath);
51
+ kg.set$PagePath$Home(param?.$PagePath$Home);
52
+ kg.set$PagePath$Login(param?.$PagePath$Login);
52
53
 
53
54
  //region 请求翻译数据,
54
55
  //----------------------------------------------------------------------------------------------------
55
- if (param?.isRequestDescriptionList !== false) {
56
+ if (param?.$i18n$IsOn !== false) {
56
57
  try {
57
58
  await kg.requestVarConfigDescriptionList();
58
- } catch (e) {
59
- }
59
+ } catch (e) {}
60
60
  }
61
61
  //----------------------------------------------------------------------------------------------------
62
62
  //endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kengic/uni",
3
- "version": "0.7.15",
3
+ "version": "0.7.16",
4
4
  "scripts": {
5
5
  "postinstall": "node bin/postinstall.mjs"
6
6
  },
@@ -15,8 +15,15 @@
15
15
  watch(
16
16
  () => kg.isRequestVarConfigDescriptionListDoing,
17
17
  (isRequestVarConfigDescriptionListDoing) => {
18
- if (!isRequestVarConfigDescriptionListDoing) {
19
- uni.reLaunch({ url: `/${kg.homePagePath}` });
18
+ // 启用国际化,
19
+ if (kg.$i18n$IsOn) {
20
+ if (!isRequestVarConfigDescriptionListDoing) {
21
+ uni.reLaunch({ url: `/${kg.$PagePath$Home}` });
22
+ }
23
+ }
24
+ // 禁用国际化,
25
+ else {
26
+ uni.reLaunch({ url: `/${kg.$PagePath$Home}` });
20
27
  }
21
28
  },
22
29
  { immediate: true },
package/page/KgPageMy.vue CHANGED
@@ -1,7 +1,9 @@
1
1
  <template>
2
2
  <view class="my">
3
3
  <UniList class="uni-list--setting">
4
- <UniListItem :right-text="kg.localeText" :title="kg.t('pda.KgPageMy.Language', {}, '语言')" link @click="openKgLocale" />
4
+ <template v-if="kg.$i18n$IsOn">
5
+ <UniListItem :right-text="kg.localeText" :title="kg.t('pda.KgPageMy.Language', {}, '语言')" link @click="openKgLocale" />
6
+ </template>
5
7
  <UniListItem :right-text="warehouseRightText$$" :title="kg.t('pda.KgPageMy.Warehouse', {}, '仓库')" link @click="openKgWarehouse" />
6
8
  <UniListItem :right-text="stationRightText$$" :title="kg.t('pda.KgPageMy.WorkStation', {}, '工作站 - 工作区')" link @click="openKgWorkStation" />
7
9
  <UniListItem :right-text="apiUrl" :title="kg.t('pda.KgPageMy.ApiUrl', {}, '后端地址')" link @click="openKgApiUil" />
@@ -87,6 +89,10 @@
87
89
  * 打开「语言选择」.
88
90
  */
89
91
  function openKgLocale() {
92
+ if (!kg.$i18n$IsOn) {
93
+ return;
94
+ }
95
+
90
96
  kgLocaleRef$.value?.open();
91
97
  }
92
98
 
@@ -206,7 +206,8 @@ const _httpClient: IHttpClient = {
206
206
  header = {};
207
207
  }
208
208
 
209
- // 启用高级查询
209
+ //region 启用高级查询
210
+ //----------------------------------------------------------------------------------------------------
210
211
  if (options?.dynamicQueryOperatorModel) {
211
212
  let params: any = {};
212
213
 
@@ -257,15 +258,20 @@ const _httpClient: IHttpClient = {
257
258
  [KG.HTTP_HEADER__KG_QUERY_WHERE_SQL]: whereSql,
258
259
  };
259
260
  }
261
+ //----------------------------------------------------------------------------------------------------
262
+ //endregion
260
263
 
261
- header[KG.HTTP_HEADER__KG_QUERY_WHERE_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG.HTTP_HEADER__KG_QUERY_WHERE_SQL] ?? '')));
262
- header[KG.HTTP_HEADER__KG_QUERY_ORDER_BY_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG.HTTP_HEADER__KG_QUERY_ORDER_BY_SQL] ?? '')));
263
- header[KG.HTTP_HEADER__KG_QUERY_OFFSET_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG.HTTP_HEADER__KG_QUERY_OFFSET_SQL] ?? '')));
264
- header[KG.HTTP_HEADER__KG_QUERY_SQL] = encodeURIComponent(decodeURIComponent(String(header[KG.HTTP_HEADER__KG_QUERY_SQL] ?? '')));
264
+ // 仓库编号,
265
+ header[KG.HTTP_HEADER__KG_WAREHOUSE] = useKgWarehouse().warehouse.value?.whId ?? '';
265
266
 
266
- header[KG.HTTP_HEADER__KG_WAREHOUSE] = encodeURIComponent(useKgWarehouse().warehouse.value?.whId ?? '');
267
- header[KG.HTTP_HEADER__KG_WORK_STATION] = encodeURIComponent(useKgStation().station.value?.devcod ?? '');
268
- header[KG.HTTP_HEADER__KG_WORK_AREA] = encodeURIComponent(useKgStation().station.value?.hmewrkare ?? '');
267
+ // 工作站工作区,
268
+ header[KG.HTTP_HEADER__KG_WORK_STATION] = useKgStation().station.value?.devcod ?? '';
269
+ header[KG.HTTP_HEADER__KG_WORK_AREA] = useKgStation().station.value?.hmewrkare ?? '';
270
+
271
+ // 编码解码防止乱码,
272
+ Object.keys(header).forEach((key) => {
273
+ header[key] = encodeURIComponent(decodeURIComponent(String(header[key] ?? '')));
274
+ });
269
275
 
270
276
  uni.request({
271
277
  ...(options ?? {}),