@kengic/uni 0.3.4 → 0.3.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.
@@ -0,0 +1,81 @@
1
+ <template>
2
+ <view :id="id" ref="ref01" class="kg-tab-bar">
3
+ <view :class="{ active: page?.route === 'pages/home/index' }" class="item" @tap.stop="goto('pages/home/index')">
4
+ <UniIcons :type="'home'" size="24"></UniIcons>
5
+ <text class="text">首页</text>
6
+ </view>
7
+
8
+ <view :class="{ active: page?.route === 'pages/my/index' }" class="item" @tap.stop="goto('pages/my/index')">
9
+ <UniIcons :type="'person'" size="24"></UniIcons>
10
+ <text class="text">我的</text>
11
+ </view>
12
+ </view>
13
+ </template>
14
+
15
+ <script lang="ts" name="KgTabBar" setup>
16
+ import { onMounted, ref } from 'vue';
17
+ import { UniIcons } from '../../uni';
18
+ import { Kg } from '../../util';
19
+ import { v4 as uuid } from 'uuid';
20
+
21
+ const id = uuid();
22
+
23
+ const ref01 = ref(null);
24
+
25
+ onMounted(() => {
26
+ /* #ifdef H5 */
27
+ ref01.value?.$el?.previousElementSibling?.classList?.add('kg-tab-bar-container');
28
+ /* #endif */
29
+
30
+ /* #ifdef APP-PLUS */
31
+ Kg.eval(`document.querySelector('#${id}').previousElementSibling.classList.add('kg-tab-bar-container');`);
32
+ /* #endif */
33
+ });
34
+
35
+ const page = Kg.getCurrentPage();
36
+
37
+ function goto(path: string) {
38
+ if (path != 'pages/my/index') {
39
+ uni.redirectTo({ url: '/' + path });
40
+ } else {
41
+ uni.navigateTo({ url: '/' + path });
42
+ }
43
+ }
44
+ </script>
45
+
46
+ <style lang="scss" scoped>
47
+ .kg-tab-bar {
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: space-around;
51
+ height: 50px;
52
+ background: #fff;
53
+ border-top: 1px solid #e5e5e5;
54
+ position: fixed;
55
+ bottom: 0px;
56
+ left: 0px;
57
+ right: 0px;
58
+ box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
59
+ }
60
+
61
+ .kg-tab-bar .item {
62
+ height: 100%;
63
+ display: flex;
64
+ flex-direction: column;
65
+ align-items: center;
66
+ justify-content: center;
67
+ flex: 1;
68
+ }
69
+
70
+ .kg-tab-bar .item.active {
71
+ color: #2979ff;
72
+ }
73
+
74
+ .kg-tab-bar .item.active .uni-icons {
75
+ color: #2979ff !important;
76
+ }
77
+
78
+ .kg-tab-bar .item .text {
79
+ font-size: 12px;
80
+ }
81
+ </style>
@@ -0,0 +1 @@
1
+ export { default as KgTabBar } from './KgTabBar.vue';
@@ -1 +1,2 @@
1
+ export * from './KgTabBar';
1
2
  export * from './KgWarehouse';
package/dist/index.css CHANGED
@@ -1 +1 @@
1
- uni-button{border-radius:3px!important}
1
+ uni-button{border-radius:3px!important}.kg-tab-bar-container{padding-bottom:50px!important}
@@ -1,5 +1,5 @@
1
1
  import { useAppStore } from '../store/app.store';
2
- import { KgUtil } from '../util';
2
+ import { Kg } from '../util';
3
3
 
4
4
  /*
5
5
  * 对请求做统一的拦截.
@@ -23,7 +23,7 @@ uni.addInterceptor('request', {
23
23
  args.data = keys.map((i) => args.data[i]);
24
24
  }
25
25
 
26
- args.data = KgUtil.parseParams(args.data);
26
+ args.data = Kg.parseParams(args.data);
27
27
  },
28
28
  success(args) {
29
29
  uni.hideLoading();
@@ -1,81 +1 @@
1
- import { ref, Ref } from 'vue';
2
- import { v4 as uuid } from 'uuid';
3
-
4
1
  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 };
@@ -1 +1 @@
1
- export * from './kg.util';
1
+ export * from './kg';
@@ -5,7 +5,7 @@ import { useKgWarehouse } from '../component';
5
5
  /**
6
6
  * 通用工具.
7
7
  */
8
- export class KgUtil {
8
+ export class Kg {
9
9
  /**
10
10
  * 处理请求参数.
11
11
  * 1. 填充通用参数的值
@@ -43,6 +43,34 @@ export class KgUtil {
43
43
  return resultParams;
44
44
  }
45
45
 
46
+ /**
47
+ * 获取当前页面.
48
+ * @see https://uniapp.dcloud.net.cn/api/window/window.html#getcurrentpages
49
+ */
50
+ public static getCurrentPage(): Page.PageInstance<AnyObject, AnyObject> | null {
51
+ const pages = getCurrentPages();
52
+ const page = pages[pages.length - 1];
53
+ return page ?? null;
54
+ }
55
+
56
+ /**
57
+ * 获取当前视图.
58
+ * @see https://uniapp.dcloud.net.cn/api/window/window.html#getappwebview
59
+ */
60
+ public static getCurrentWebview(): PlusWebviewWebviewObject | null {
61
+ const page = Kg.getCurrentPage();
62
+ return page?.$getAppWebview?.() ?? null;
63
+ }
64
+
65
+ /**
66
+ * 执行 javascript 代码.
67
+ * @see https://www.html5plus.org/doc/zh_cn/webview.html#plus.webview.WebviewObject.evalJS
68
+ * @param js 要执行的代码.
69
+ */
70
+ public static eval(js: string): void {
71
+ Kg.getCurrentWebview()?.evalJS(js);
72
+ }
73
+
46
74
  /**
47
75
  * 处理请求参数: 解析字符串类型的参数值.
48
76
  * @param value 参数的原始值.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kengic/uni",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "scripts": {
5
5
  "build": "rimraf dist && vue-tsc && vite build",
6
6
  "build:dev": "rimraf dist && vue-tsc && vite build --mode development",
@@ -8,19 +8,18 @@
8
8
  "publish:all:patch": "npm run bump-version:patch && npm run publish:all",
9
9
  "publish:all:minor": "npm run bump-version:minor && npm run publish:all",
10
10
  "publish:all:major": "npm run bump-version:major && npm run publish:all",
11
- "-------------------- C": "",
12
- "bump-to:luotao.c.wms-pda": "tsx scripts/bump-to.luotao.c.wms-pda.ts",
13
- "copy-to:luotao.c.wms-pda": "npm run build:dev && tsx scripts/copy-to.luotao.c.wms-pda.ts",
14
- "-------------------- D": "",
15
- "bump-to:luotao.wms-pda": "tsx scripts/bump-to.luotao.wms-pda.ts",
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",
18
- "--------------------": "",
11
+ "------------------------------": "",
19
12
  "gen:apis:WMS": "kengic-pont generate-apis --config kg.config.ts --origin WMS",
20
- "bump-version:beta": "tsx scripts/bump.ts beta",
21
- "bump-version:major": "tsx scripts/bump.ts major",
22
- "bump-version:minor": "tsx scripts/bump.ts minor",
23
- "bump-version:patch": "tsx scripts/bump.ts patch",
13
+ "- ----------------------------": "",
14
+ "bump-to:luotao.wms-pda--dev-1.0": "node scripts/bump-to.luotao.wms-pda--dev-1.0.mjs --experimental-default-type=module",
15
+ "copy-to:luotao.wms-pda--dev-1.0": "npm run build:dev && node scripts/copy-to.luotao.wms-pda--dev-1.0.mjs --experimental-default-type=module",
16
+ "copy-to:luotao.wms-pda--focus": "npm run build:dev && node scripts/copy-to.luotao.wms-pda--focus.mjs --experimental-default-type=module",
17
+ "-- ---------------------------": "",
18
+ "cnpm:sync": "cnpm sync @kengic/uni",
19
+ "bump-version:beta": "tsx scripts/bump.mjs beta",
20
+ "bump-version:major": "tsx scripts/bump.mjs major",
21
+ "bump-version:minor": "tsx scripts/bump.mjs minor",
22
+ "bump-version:patch": "tsx scripts/bump.mjs patch",
24
23
  "publish:all": "tsx scripts/publish.ts",
25
24
  "publish:npm": "npmrc kengic && npm publish ./ --registry https://registry.npmjs.org/ --access public"
26
25
  },
@@ -37,7 +36,7 @@
37
36
  },
38
37
  "devDependencies": {
39
38
  "@dcloudio/types": "~3.3.3",
40
- "@kengic/pont": "~1.2.10-beta.44",
39
+ "@kengic/pont": "~1.2.11",
41
40
  "@types/lodash-es": "~4.17.7",
42
41
  "@types/node": "~18.14.6",
43
42
  "@types/semver": "~7.3.13",