@kengic/uni 0.7.14-beta.6 → 0.7.14-beta.7
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/component/KgLocaleSelector/KgLocaleSelector.vue +4 -2
- package/component/KgNavBar/KgNavBar.vue +3 -6
- package/component/KgTabBar/KgTabBar.vue +8 -10
- package/component/KgUpdateNotice/KgUpdateNotice.vue +3 -3
- package/config/app.store.ts +1 -13
- package/config/config.store.ts +26 -6
- package/config/index.ts +1 -0
- package/index.css +13 -1
- package/package.json +2 -1
- package/page/KgPageMy.vue +5 -8
- package/service/http-client.ts +3 -1
- package/util/kg.util.ts +5 -5
|
@@ -44,14 +44,14 @@
|
|
|
44
44
|
//region FUNCTION
|
|
45
45
|
//----------------------------------------------------------------------------------------------------
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* 取消.
|
|
48
48
|
*/
|
|
49
49
|
function onCancel() {
|
|
50
50
|
popupRef$.value?.close();
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
54
|
+
* 确定.
|
|
55
55
|
*/
|
|
56
56
|
function onOk() {
|
|
57
57
|
kg.setLocale(currentLocale$.value);
|
|
@@ -62,6 +62,8 @@
|
|
|
62
62
|
* 打开弹窗.
|
|
63
63
|
*/
|
|
64
64
|
function open() {
|
|
65
|
+
// 每次打开弹窗之前, 将当前选中语言重置为应用当前语言,
|
|
66
|
+
currentLocale$.value = kg.locale;
|
|
65
67
|
popupRef$.value?.open();
|
|
66
68
|
}
|
|
67
69
|
//----------------------------------------------------------------------------------------------------
|
|
@@ -9,19 +9,16 @@
|
|
|
9
9
|
</UniNavBar>
|
|
10
10
|
|
|
11
11
|
<!--#ifdef APP-PLUS-->
|
|
12
|
-
<
|
|
12
|
+
<KgUpdateNotice v-if="isCustomNavigationBar" />
|
|
13
13
|
<!--#endif-->
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
|
+
<!--页面顶部标题-->
|
|
16
17
|
<script lang="ts" name="KgNavBar" setup>
|
|
17
18
|
import { computed, ref } from 'vue';
|
|
18
19
|
import { UniIcons, UniNavBar } from '../../uni-ui';
|
|
19
20
|
import { KgUtil } from '../../util';
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 顶部标题栏.
|
|
24
|
-
*/
|
|
21
|
+
import { KgUpdateNotice } from '../KgUpdateNotice';
|
|
25
22
|
|
|
26
23
|
//region DATA
|
|
27
24
|
// ----------------------------------------------------------------------------------------------------
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view :id="
|
|
2
|
+
<view :id="ID" ref="ref01" class="kg-tab-bar">
|
|
3
3
|
<view :class="{ active: page?.route === 'pages/home/index' }" class="item" @tap.stop="goto('pages/home/index')">
|
|
4
4
|
<UniIcons :type="'home'" size="24"></UniIcons>
|
|
5
5
|
<text class="text">首页</text>
|
|
@@ -12,27 +12,24 @@
|
|
|
12
12
|
</view>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
+
<!--页面底部标签导航-->
|
|
15
16
|
<script lang="ts" name="KgTabBar" setup>
|
|
16
17
|
import { onMounted, ref } from 'vue';
|
|
17
18
|
import { UniIcons } from '../../uni-ui';
|
|
18
19
|
import { KgUtil } from '../../util';
|
|
19
20
|
import { v4 as uuid } from 'uuid';
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
* 底部标签栏.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const id = `kgtabbar${uuid().replace(/-/g, '')}`;
|
|
22
|
+
const ID = `KgTabBar${uuid().replace(/-/g, '')}`;
|
|
26
23
|
|
|
27
24
|
const ref01 = ref<any>(null);
|
|
28
25
|
|
|
29
26
|
onMounted(() => {
|
|
30
27
|
/* #ifdef H5 */
|
|
31
|
-
ref01.value?.$el?.previousElementSibling?.classList?.add('kg-tab-bar
|
|
28
|
+
ref01.value?.$el?.previousElementSibling?.classList?.add('kg-tab-bar--sibling');
|
|
32
29
|
/* #endif */
|
|
33
30
|
|
|
34
31
|
/* #ifdef APP-PLUS */
|
|
35
|
-
KgUtil.eval(`document.querySelector('#${
|
|
32
|
+
KgUtil.eval(`document.querySelector('#${ID}').previousElementSibling.classList.add('kg-tab-bar--sibling');`);
|
|
36
33
|
/* #endif */
|
|
37
34
|
});
|
|
38
35
|
|
|
@@ -47,7 +44,7 @@
|
|
|
47
44
|
}
|
|
48
45
|
</script>
|
|
49
46
|
|
|
50
|
-
<style
|
|
47
|
+
<style>
|
|
51
48
|
.kg-tab-bar {
|
|
52
49
|
display: flex;
|
|
53
50
|
align-items: center;
|
|
@@ -59,7 +56,6 @@
|
|
|
59
56
|
bottom: 0px;
|
|
60
57
|
left: 0px;
|
|
61
58
|
right: 0px;
|
|
62
|
-
box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
.kg-tab-bar .item {
|
|
@@ -81,5 +77,7 @@
|
|
|
81
77
|
|
|
82
78
|
.kg-tab-bar .item .text {
|
|
83
79
|
font-size: 12px;
|
|
80
|
+
line-height: 1;
|
|
84
81
|
}
|
|
82
|
+
|
|
85
83
|
</style>
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<!--升级提示-->
|
|
22
|
-
<script lang="ts" name="
|
|
22
|
+
<script lang="ts" name="KgUpdateNotice" setup>
|
|
23
23
|
import { computed, onMounted, onUnmounted, PropType, ref } from 'vue';
|
|
24
24
|
import { UniPopup, UniPopupDialog } from '../../uni-ui';
|
|
25
|
-
import { useAppStore } from '../../config
|
|
25
|
+
import { useAppStore } from '../../config';
|
|
26
26
|
import { KgUtil } from '../../util';
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
|
|
141
141
|
unsubscribe.value = appStore.$onAction(async ({ name, args }) => {
|
|
142
142
|
switch (name) {
|
|
143
|
-
case '
|
|
143
|
+
case 'openKgUpdateNotice':
|
|
144
144
|
version.value = args[0];
|
|
145
145
|
popupRef$.value?.open();
|
|
146
146
|
break;
|
package/config/app.store.ts
CHANGED
|
@@ -10,9 +10,6 @@ interface IAppState {
|
|
|
10
10
|
/** 是否取消本次升级. 取消之后, 使用应用期间不会再提示升级, 直到下次重新打开应用才会提示升级. */
|
|
11
11
|
isUpdateCancel: boolean;
|
|
12
12
|
|
|
13
|
-
/** 当前语言. */
|
|
14
|
-
locale: string;
|
|
15
|
-
|
|
16
13
|
/** 登录令牌. */
|
|
17
14
|
token: string;
|
|
18
15
|
|
|
@@ -58,7 +55,7 @@ export const useAppStore = defineStore('app', {
|
|
|
58
55
|
* 打开更新弹窗.
|
|
59
56
|
* @param version 最新版本.
|
|
60
57
|
*/
|
|
61
|
-
|
|
58
|
+
openKgUpdateNotice(version: string) {},
|
|
62
59
|
|
|
63
60
|
/**
|
|
64
61
|
* 查询用户仓库.
|
|
@@ -77,10 +74,6 @@ export const useAppStore = defineStore('app', {
|
|
|
77
74
|
this.isUpdateCancel = value;
|
|
78
75
|
},
|
|
79
76
|
|
|
80
|
-
setLocale(value: string) {
|
|
81
|
-
this.locale = value;
|
|
82
|
-
},
|
|
83
|
-
|
|
84
77
|
setToken(token: string) {
|
|
85
78
|
uni.setStorageSync(KG.STORAGE_KEY__TOKEN, token);
|
|
86
79
|
this.token = token;
|
|
@@ -102,10 +95,6 @@ export const useAppStore = defineStore('app', {
|
|
|
102
95
|
return state.isUpdateCancel;
|
|
103
96
|
},
|
|
104
97
|
|
|
105
|
-
getLocale(state) {
|
|
106
|
-
return state.locale ?? 'zh_CN';
|
|
107
|
-
},
|
|
108
|
-
|
|
109
98
|
/** 登录令牌. */
|
|
110
99
|
getToken(state) {
|
|
111
100
|
return state.token;
|
|
@@ -123,7 +112,6 @@ export const useAppStore = defineStore('app', {
|
|
|
123
112
|
state: (): IAppState => ({
|
|
124
113
|
apiUrl: uni.getStorageSync(KG.STORAGE_KEY__API_URL) ?? '',
|
|
125
114
|
isUpdateCancel: false,
|
|
126
|
-
locale: 'zh_CN',
|
|
127
115
|
token: uni.getStorageSync(KG.STORAGE_KEY__TOKEN) ?? '',
|
|
128
116
|
user: uni.getStorageSync(KG.STORAGE_KEY__USER) ?? {},
|
|
129
117
|
userWarehouses: undefined,
|
package/config/config.store.ts
CHANGED
|
@@ -22,6 +22,11 @@ export interface IUseKgStoreGetters {
|
|
|
22
22
|
* 当前语言.
|
|
23
23
|
*/
|
|
24
24
|
locale: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 当前语言名称.
|
|
28
|
+
*/
|
|
29
|
+
localeText: string;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
//----------------------------------------------------------------------------------------------------
|
|
@@ -109,18 +114,22 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
|
|
|
109
114
|
// 如果本地存储有值, 表示用户上次已通过语言选择弹窗选择了某个语言, 但是又重新启动了应用,
|
|
110
115
|
const storeLocale = uni.getStorageSync(KG.STORAGE_KEY__LOCALE);
|
|
111
116
|
if (storeLocale) {
|
|
112
|
-
|
|
113
|
-
return locale$.value;
|
|
117
|
+
return storeLocale;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
if (defaultLocale$.value) {
|
|
117
|
-
|
|
118
|
-
return locale$.value;
|
|
121
|
+
return defaultLocale$.value;
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
return KG.LOCALE.ZH_CN;
|
|
122
125
|
});
|
|
123
126
|
|
|
127
|
+
const localeText$$ = computed<string>(() => {
|
|
128
|
+
// TODO LT
|
|
129
|
+
return '|' + uni.getLocale() + '|' + locale$.value + '|' + uni.getStorageSync(KG.STORAGE_KEY__LOCALE) + '|';
|
|
130
|
+
// return KG.LOCALE_DATA_LIST.find((i) => i.code === locale$$.value)?.text ?? '';
|
|
131
|
+
});
|
|
132
|
+
|
|
124
133
|
//----------------------------------------------------------------------------------------------------
|
|
125
134
|
//endregion
|
|
126
135
|
|
|
@@ -150,7 +159,7 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
|
|
|
150
159
|
}
|
|
151
160
|
|
|
152
161
|
function setDefaultLocale(value?: string | null): void {
|
|
153
|
-
|
|
162
|
+
defaultLocale$.value = value ?? KG.LOCALE.ZH_CN;
|
|
154
163
|
}
|
|
155
164
|
|
|
156
165
|
function setDescriptionList(param: { codeName: string | null | undefined; descriptions: Array<DescriptionDTO> }): void {
|
|
@@ -180,7 +189,17 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
|
|
|
180
189
|
|
|
181
190
|
locale$.value = value;
|
|
182
191
|
uni.setStorageSync(KG.STORAGE_KEY__LOCALE, value);
|
|
183
|
-
uni.setLocale(
|
|
192
|
+
uni.setLocale(
|
|
193
|
+
(() => {
|
|
194
|
+
switch (value) {
|
|
195
|
+
case 'zh_CN': {
|
|
196
|
+
return 'zh-Hans';
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return value.replace('_', '-');
|
|
201
|
+
})(),
|
|
202
|
+
);
|
|
184
203
|
}
|
|
185
204
|
|
|
186
205
|
function t(key: string | null | undefined, param?: Record<string, any> | null | undefined, defaultValue?: string | null | undefined): string {
|
|
@@ -225,6 +244,7 @@ export const useKgStore: KgStoreDefinition<IUseKgStoreGetters, IUseKgStoreAction
|
|
|
225
244
|
getDescription: getDescription$$,
|
|
226
245
|
locale: locale$$,
|
|
227
246
|
locale$: locale$,
|
|
247
|
+
localeText: localeText$$,
|
|
228
248
|
requestVarConfigDescriptionList: requestVarConfigDescriptionList,
|
|
229
249
|
setDefaultLocale: setDefaultLocale,
|
|
230
250
|
setDescriptionList: setDescriptionList,
|
package/config/index.ts
CHANGED
package/index.css
CHANGED
|
@@ -6,7 +6,7 @@ uni-button:after {
|
|
|
6
6
|
border-radius: 6px !important;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.kg-tab-bar
|
|
9
|
+
.kg-tab-bar--sibling {
|
|
10
10
|
padding-bottom: 50px !important;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -30,7 +30,16 @@ uni-button:after {
|
|
|
30
30
|
background-color: rgba(17, 17, 17, 0.9);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
:deep(.uni-datetime-picker--btn) {
|
|
34
|
+
letter-spacing: 0px !important;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
:deep(.uni-calendar__button-text) {
|
|
38
|
+
letter-spacing: 0px !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
/* region H5 */
|
|
42
|
+
/* ---------------------------------------------------------------------------------------------------- */
|
|
34
43
|
/* #ifdef H5 */
|
|
35
44
|
|
|
36
45
|
.uni-nav-bar-text {
|
|
@@ -50,8 +59,10 @@ uni-button:after {
|
|
|
50
59
|
|
|
51
60
|
/* #endif */
|
|
52
61
|
/* endregion */
|
|
62
|
+
/* ---------------------------------------------------------------------------------------------------- */
|
|
53
63
|
|
|
54
64
|
/* region APP-PLUS */
|
|
65
|
+
/* ---------------------------------------------------------------------------------------------------- */
|
|
55
66
|
/* #ifdef APP-PLUS */
|
|
56
67
|
|
|
57
68
|
.uni-nav-bar-text {
|
|
@@ -71,3 +82,4 @@ uni-button:after {
|
|
|
71
82
|
|
|
72
83
|
/* #endif */
|
|
73
84
|
/* endregion */
|
|
85
|
+
/* ---------------------------------------------------------------------------------------------------- */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kengic/uni",
|
|
3
|
-
"version": "0.7.14-beta.
|
|
3
|
+
"version": "0.7.14-beta.7",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"postinstall": "node bin/postinstall.mjs"
|
|
6
6
|
},
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"uuid": "13.0.0",
|
|
44
44
|
"vite": "4.3.9",
|
|
45
45
|
"vue": "3.2.47",
|
|
46
|
+
"vue-i18n": "9.1.9",
|
|
46
47
|
"vue-tsc": "1.8.27"
|
|
47
48
|
},
|
|
48
49
|
"main": "./index.ts",
|
package/page/KgPageMy.vue
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="my">
|
|
3
3
|
<UniList class="uni-list--setting">
|
|
4
|
-
<UniListItem link title="语言" :right-text="
|
|
4
|
+
<UniListItem link title="语言" :right-text="kg.localeText" @click="openKgLocaleSelector" />
|
|
5
5
|
<UniListItem link title="仓库" :right-text="warehouseRightText$$" @click="openKgWarehouse" />
|
|
6
6
|
<UniListItem link title="工作站 - 工作区" :right-text="stationRightText$$" @click="openKgStation" />
|
|
7
|
-
<UniListItem link title="
|
|
7
|
+
<UniListItem link title="后端地址" :right-text="apiUrl" />
|
|
8
8
|
|
|
9
9
|
<!--#ifdef APP-PLUS-->
|
|
10
10
|
<UniListItem link title="当前版本" :right-text="currentVersion" @click="checkForUpdate" />
|
|
@@ -26,11 +26,13 @@
|
|
|
26
26
|
|
|
27
27
|
<script setup lang="ts">
|
|
28
28
|
import { computed, ref } from 'vue';
|
|
29
|
-
import { useAppStore } from '../config';
|
|
29
|
+
import { useAppStore, useKg } from '../config';
|
|
30
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
|
|
|
34
|
+
const kg = useKg();
|
|
35
|
+
|
|
34
36
|
const appStore = useAppStore();
|
|
35
37
|
const kgWarehouse = useKgWarehouse();
|
|
36
38
|
const kgStation = useKgStation();
|
|
@@ -41,11 +43,6 @@
|
|
|
41
43
|
const kgStationRef$ = ref<any>(null);
|
|
42
44
|
const kgLocaleSelectorRef$ = ref<any>(null);
|
|
43
45
|
|
|
44
|
-
/**
|
|
45
|
-
* 语言的右侧文本.
|
|
46
|
-
*/
|
|
47
|
-
const localeRightText$$ = computed<string>(() => 'TODO');
|
|
48
|
-
|
|
49
46
|
/**
|
|
50
47
|
* 仓库的右侧文本.
|
|
51
48
|
*/
|
package/service/http-client.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { useKgStation } from '../component/KgWorkStationSelector';
|
|
|
5
5
|
import { isNil } from 'lodash-es';
|
|
6
6
|
import dayjs from 'dayjs';
|
|
7
7
|
import { KG } from '../model';
|
|
8
|
+
import { useKg } from '../config';
|
|
8
9
|
|
|
9
10
|
/*
|
|
10
11
|
* 对请求做统一的拦截.
|
|
@@ -15,12 +16,13 @@ uni.addInterceptor('request', {
|
|
|
15
16
|
uni.showLoading({ mask: true });
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
const kg = useKg();
|
|
18
20
|
const appStore = useAppStore();
|
|
19
21
|
|
|
20
22
|
args.header['Authorization'] = appStore.getToken;
|
|
21
23
|
// TODO LT 支持其他语言
|
|
22
24
|
if (!args.header['Accept-Language']) {
|
|
23
|
-
args.header['Accept-Language'] =
|
|
25
|
+
args.header['Accept-Language'] = kg.locale?.replace('_', '-');
|
|
24
26
|
}
|
|
25
27
|
args.header['X-Access-Token'] = appStore.getToken;
|
|
26
28
|
|
package/util/kg.util.ts
CHANGED
|
@@ -145,13 +145,13 @@ class KgUtil {
|
|
|
145
145
|
|
|
146
146
|
// 有新版本
|
|
147
147
|
if (_major > major || (_major == major && _minor > minor) || (_major == major && _minor == minor && _patch > patch)) {
|
|
148
|
-
appStore.
|
|
148
|
+
appStore.openKgUpdateNotice(newVersion);
|
|
149
149
|
return true;
|
|
150
150
|
}
|
|
151
151
|
// 无新版本
|
|
152
152
|
else {
|
|
153
153
|
if (isShowToast) {
|
|
154
|
-
uni.showToast({ title: '
|
|
154
|
+
uni.showToast({ title: '已是最新版本', icon: 'none' });
|
|
155
155
|
}
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
@@ -298,7 +298,7 @@ class KgUtil {
|
|
|
298
298
|
|
|
299
299
|
// object
|
|
300
300
|
case isObjectLike(value): {
|
|
301
|
-
throw new Error('
|
|
301
|
+
throw new Error('不支持的参数类型');
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
// string
|
|
@@ -464,12 +464,12 @@ class KgUtil {
|
|
|
464
464
|
if (!isNil(_params.pageNo)) {
|
|
465
465
|
const pageIndex = Number.parseInt(_params.pageNo);
|
|
466
466
|
if (Number.isNaN(pageIndex) || pageIndex <= 0) {
|
|
467
|
-
throw new Error('参数 pageNo
|
|
467
|
+
throw new Error('参数 pageNo 非法');
|
|
468
468
|
}
|
|
469
469
|
|
|
470
470
|
const pageSize = Number.parseInt(_params.pageSize);
|
|
471
471
|
if (Number.isNaN(pageSize) || pageSize <= 0) {
|
|
472
|
-
throw new Error('参数 pageSize
|
|
472
|
+
throw new Error('参数 pageSize 非法');
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
offsetSql = ` OFFSET ${(pageIndex - 1) * pageSize} ROWS FETCH NEXT ${pageSize} ROWS ONLY`;
|