@kengic/uni 0.3.4-beta.0 → 0.3.4
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/service/index.ts +80 -0
- package/package.json +22 -19
package/dist/service/index.ts
CHANGED
|
@@ -1 +1,81 @@
|
|
|
1
|
+
import { ref, Ref } from 'vue';
|
|
2
|
+
import { v4 as uuid } from 'uuid';
|
|
3
|
+
|
|
1
4
|
export * from './http-client';
|
|
5
|
+
|
|
6
|
+
type IUseKgAutoFocusInput = {
|
|
7
|
+
/** 文本框的内容. */
|
|
8
|
+
kgAutoFocusInputText: Ref<string>;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 失去焦点事件.
|
|
12
|
+
* @param fn 回调函数.
|
|
13
|
+
*/
|
|
14
|
+
onKgAutoFocusInputBlur(fn: () => void): void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 自动聚焦的文本框.
|
|
19
|
+
*/
|
|
20
|
+
function useKgAutoFocusInput(): IUseKgAutoFocusInput {
|
|
21
|
+
// 文本框的内容
|
|
22
|
+
const kgAutoFocusInputText = ref('');
|
|
23
|
+
// 失去焦点时的回调函数, 外部传入
|
|
24
|
+
let onBlur: (() => void) | null = null;
|
|
25
|
+
|
|
26
|
+
/** 监听失去焦点事件. */
|
|
27
|
+
function onKgAutoFocusInputBlur(_fn: () => void) {
|
|
28
|
+
onBlur = _fn;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* #ifdef APP-PLUS */
|
|
32
|
+
const inputID = uuid();
|
|
33
|
+
const view = new plus.nativeObj.View!(uuid(), {
|
|
34
|
+
opacity: 0,
|
|
35
|
+
top: '0px',
|
|
36
|
+
left: '0px',
|
|
37
|
+
height: '1px',
|
|
38
|
+
width: '1px',
|
|
39
|
+
});
|
|
40
|
+
view.drawInput(
|
|
41
|
+
{
|
|
42
|
+
top: '0px',
|
|
43
|
+
left: '0px',
|
|
44
|
+
width: '1px',
|
|
45
|
+
height: '1px',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
fontSize: '0px',
|
|
49
|
+
borderWidth: '0px',
|
|
50
|
+
onBlur() {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
clearInterval(interval);
|
|
53
|
+
view.close();
|
|
54
|
+
if (onBlur) {
|
|
55
|
+
onBlur();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
inputID,
|
|
60
|
+
);
|
|
61
|
+
view.show();
|
|
62
|
+
|
|
63
|
+
uni.onKeyboardHeightChange((result) => {
|
|
64
|
+
if (result.height > 0) {
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
view.setInputFocusById(inputID, true);
|
|
68
|
+
}, 100);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
const interval = setInterval(() => {
|
|
74
|
+
kgAutoFocusInputText.value = view.getInputValueById(inputID) ?? '';
|
|
75
|
+
}, 10);
|
|
76
|
+
/* #endif */
|
|
77
|
+
|
|
78
|
+
return { kgAutoFocusInputText: kgAutoFocusInputText, onKgAutoFocusInputBlur: onKgAutoFocusInputBlur };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { type IUseKgAutoFocusInput, useKgAutoFocusInput };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kengic/uni",
|
|
3
|
-
"version": "0.3.4
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rimraf dist && vue-tsc && vite build",
|
|
6
6
|
"build:dev": "rimraf dist && vue-tsc && vite build --mode development",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"-------------------- D": "",
|
|
15
15
|
"bump-to:luotao.wms-pda": "tsx scripts/bump-to.luotao.wms-pda.ts",
|
|
16
16
|
"copy-to:luotao.wms-pda": "npm run build:dev && tsx scripts/copy-to.luotao.wms-pda.ts",
|
|
17
|
+
"copy-to:luotao.wms-pda--focus": "npm run build:dev && tsx scripts/copy-to.luotao.wms-pda--focus.ts",
|
|
17
18
|
"--------------------": "",
|
|
18
19
|
"gen:apis:WMS": "kengic-pont generate-apis --config kg.config.ts --origin WMS",
|
|
19
20
|
"bump-version:beta": "tsx scripts/bump.ts beta",
|
|
@@ -24,35 +25,37 @@
|
|
|
24
25
|
"publish:npm": "npmrc kengic && npm publish ./ --registry https://registry.npmjs.org/ --access public"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@ant-design/icons-vue": "6.1.0",
|
|
28
|
-
"@iconify-icons/ant-design": "1.2.5",
|
|
29
|
-
"@iconify/vue": "4.1.1",
|
|
30
|
-
"@vueuse/core": "8.9.4",
|
|
31
|
-
"@vueuse/shared": "8.9.4",
|
|
32
|
-
"lodash-es": "4.17.21",
|
|
33
|
-
"pinia": "2.0.35",
|
|
34
|
-
"
|
|
28
|
+
"@ant-design/icons-vue": "~6.1.0",
|
|
29
|
+
"@iconify-icons/ant-design": "~1.2.5",
|
|
30
|
+
"@iconify/vue": "~4.1.1",
|
|
31
|
+
"@vueuse/core": "~8.9.4",
|
|
32
|
+
"@vueuse/shared": "~8.9.4",
|
|
33
|
+
"lodash-es": "~4.17.21",
|
|
34
|
+
"pinia": "~2.0.35",
|
|
35
|
+
"uuid": "~9.0.1",
|
|
36
|
+
"vue": "~3.2.47"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@dcloudio/types": "3.3.3",
|
|
38
|
-
"@kengic/pont": "1.2.10-beta.44",
|
|
39
|
+
"@dcloudio/types": "~3.3.3",
|
|
40
|
+
"@kengic/pont": "~1.2.10-beta.44",
|
|
39
41
|
"@types/lodash-es": "~4.17.7",
|
|
40
42
|
"@types/node": "~18.14.6",
|
|
41
43
|
"@types/semver": "~7.3.13",
|
|
42
|
-
"@
|
|
44
|
+
"@types/uuid": "~9.0.7",
|
|
45
|
+
"@vitejs/plugin-vue": "~4.2.1",
|
|
43
46
|
"chalk": "~4.1.2",
|
|
44
47
|
"less": "~4.1.3",
|
|
45
48
|
"prettier": "~2.8.4",
|
|
46
49
|
"rimraf": "~3.0.2",
|
|
47
50
|
"rollup": "~2.79.1",
|
|
48
|
-
"sass": "1.62.1",
|
|
49
|
-
"sass-loader": "10.4.1",
|
|
51
|
+
"sass": "~1.62.1",
|
|
52
|
+
"sass-loader": "~10.4.1",
|
|
50
53
|
"semver": "~7.3.8",
|
|
51
|
-
"tsx": "3.12.7",
|
|
52
|
-
"typescript": "4.9.5",
|
|
53
|
-
"vite": "4.3.4",
|
|
54
|
-
"vue": "3.2.47",
|
|
55
|
-
"vue-tsc": "1.6.4"
|
|
54
|
+
"tsx": "~3.12.7",
|
|
55
|
+
"typescript": "~4.9.5",
|
|
56
|
+
"vite": "~4.3.4",
|
|
57
|
+
"vue": "~3.2.47",
|
|
58
|
+
"vue-tsc": "~1.6.4"
|
|
56
59
|
},
|
|
57
60
|
"main": "./dist/kengic-uni.js",
|
|
58
61
|
"module": "./dist/kengic-uni.js",
|