@xfe-repo/mini-utils 0.0.5 → 0.0.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/dist/appJSBridge.d.mts +30 -0
- package/dist/appJSBridge.js +0 -28
- package/dist/appJSBridge.mjs +100 -0
- package/dist/chunk-52AS66K5.mjs +19 -0
- package/dist/chunk-6BTIQCMF.mjs +18 -0
- package/dist/chunk-7KLLRNFF.mjs +36 -0
- package/dist/chunk-L74XPUIL.mjs +24 -0
- package/dist/chunk-SGFGNEI2.mjs +40 -0
- package/dist/env.d.mts +15 -0
- package/dist/env.js +0 -28
- package/dist/env.mjs +32 -0
- package/dist/storage.d.mts +9 -0
- package/dist/storage.d.ts +0 -1
- package/dist/storage.h5.d.mts +9 -0
- package/dist/storage.h5.mjs +11 -0
- package/dist/storage.js +1 -4
- package/dist/storage.mjs +15 -0
- package/dist/storage.weapp.d.mts +9 -0
- package/dist/storage.weapp.mjs +11 -0
- package/dist/tools.d.mts +7 -0
- package/dist/tools.d.ts +1 -1
- package/dist/tools.mjs +25 -0
- package/package.json +3 -4
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare function appLogin(params: {
|
|
2
|
+
redirect: string;
|
|
3
|
+
}): Promise<{
|
|
4
|
+
userToken: string;
|
|
5
|
+
}>;
|
|
6
|
+
declare function appChooseImage(params: {
|
|
7
|
+
count?: number;
|
|
8
|
+
sourceType?: 'album' | 'camera';
|
|
9
|
+
}): Promise<{
|
|
10
|
+
list: string[];
|
|
11
|
+
}>;
|
|
12
|
+
declare function appWechatShareImg(params: {
|
|
13
|
+
shareImg: string;
|
|
14
|
+
imageWidth: string;
|
|
15
|
+
imageHeight: string;
|
|
16
|
+
wmsOrderNo: string;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
declare function appSaveImage(params: {
|
|
19
|
+
imageList?: string[];
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
declare function appH5RouterChange(params: {
|
|
22
|
+
path?: string;
|
|
23
|
+
}): Promise<Number>;
|
|
24
|
+
declare function appScanCode(params: {
|
|
25
|
+
type: 'general' | 'business';
|
|
26
|
+
}): Promise<{
|
|
27
|
+
code: string;
|
|
28
|
+
}>;
|
|
29
|
+
|
|
30
|
+
export { appChooseImage, appH5RouterChange, appLogin, appSaveImage, appScanCode, appWechatShareImg };
|
package/dist/appJSBridge.js
CHANGED
|
@@ -17,7 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -63,49 +62,22 @@ module.exports = __toCommonJS(appJSBridge_exports);
|
|
|
63
62
|
// src/env.ts
|
|
64
63
|
var import_taro2 = __toESM(require("@tarojs/taro"));
|
|
65
64
|
|
|
66
|
-
// src/storage.ts
|
|
67
|
-
var storage_exports = {};
|
|
68
|
-
__export(storage_exports, {
|
|
69
|
-
getLocalData: () => getLocalData3,
|
|
70
|
-
platform: () => platform,
|
|
71
|
-
removeLocalData: () => removeLocalData3,
|
|
72
|
-
setLocalData: () => setLocalData3
|
|
73
|
-
});
|
|
74
|
-
|
|
75
65
|
// src/storage.h5.ts
|
|
76
66
|
var import_js_cookie = __toESM(require("js-cookie"));
|
|
77
67
|
function getLocalData(name) {
|
|
78
68
|
return import_js_cookie.default.get(name) || "";
|
|
79
69
|
}
|
|
80
|
-
function setLocalData(params) {
|
|
81
|
-
const { key, data, expireDays = 365 } = params;
|
|
82
|
-
const expires = new Date(Date.now() + expireDays * 24 * 60 * 60 * 1e3);
|
|
83
|
-
import_js_cookie.default.set(key, data, { expires });
|
|
84
|
-
}
|
|
85
|
-
function removeLocalData(key) {
|
|
86
|
-
setLocalData({ key, data: "", expireDays: -1 });
|
|
87
|
-
}
|
|
88
70
|
|
|
89
71
|
// src/storage.weapp.ts
|
|
90
72
|
var import_taro = __toESM(require("@tarojs/taro"));
|
|
91
73
|
function getLocalData2(name) {
|
|
92
74
|
return import_taro.default.getStorageSync(name);
|
|
93
75
|
}
|
|
94
|
-
function setLocalData2(params) {
|
|
95
|
-
const { key, data } = params;
|
|
96
|
-
import_taro.default.setStorageSync(key, data);
|
|
97
|
-
}
|
|
98
|
-
function removeLocalData2(key) {
|
|
99
|
-
import_taro.default.removeStorageSync(key);
|
|
100
|
-
}
|
|
101
76
|
|
|
102
77
|
// src/storage.ts
|
|
103
|
-
__reExport(storage_exports, require("query-string"));
|
|
104
78
|
var platform = process.env.TARO_ENV || "weapp";
|
|
105
79
|
var isWeapp = platform === "weapp";
|
|
106
80
|
var getLocalData3 = isWeapp ? getLocalData2 : getLocalData;
|
|
107
|
-
var setLocalData3 = isWeapp ? setLocalData2 : setLocalData;
|
|
108
|
-
var removeLocalData3 = isWeapp ? removeLocalData2 : removeLocalData;
|
|
109
81
|
|
|
110
82
|
// src/env.ts
|
|
111
83
|
var ENV = import_taro2.default.getEnv().toLocaleLowerCase();
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appVersion,
|
|
3
|
+
isApp,
|
|
4
|
+
isSaasAndroidApp,
|
|
5
|
+
isSaasIOSApp
|
|
6
|
+
} from "./chunk-7KLLRNFF.mjs";
|
|
7
|
+
import "./chunk-L74XPUIL.mjs";
|
|
8
|
+
import "./chunk-52AS66K5.mjs";
|
|
9
|
+
import "./chunk-6BTIQCMF.mjs";
|
|
10
|
+
import {
|
|
11
|
+
__async
|
|
12
|
+
} from "./chunk-SGFGNEI2.mjs";
|
|
13
|
+
|
|
14
|
+
// src/appJSBridge.ts
|
|
15
|
+
import { compare } from "compare-versions";
|
|
16
|
+
var AppJSBridge = class {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.callbackDict = {};
|
|
19
|
+
// 触发app调用
|
|
20
|
+
this.sendMessage = (methodKey, params = {}) => {
|
|
21
|
+
if (!isApp) throw new Error("\u975Eapp\u73AF\u5883");
|
|
22
|
+
if (isSaasIOSApp) {
|
|
23
|
+
window.flutter_inappwebview.callHandler(methodKey, params);
|
|
24
|
+
} else if (isSaasAndroidApp) {
|
|
25
|
+
window.jsObj[methodKey](JSON.stringify(params));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
// 监听app调用
|
|
29
|
+
this.listen = (methodKey, callback) => {
|
|
30
|
+
if (!isApp) return Promise.reject("\u975Eapp\u73AF\u5883");
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
this.callbackDict[methodKey] = (result) => {
|
|
33
|
+
const jsonResult = JSON.parse(result || "{}");
|
|
34
|
+
if (!jsonResult.code || jsonResult.code !== 200) throw new Error(jsonResult.msg);
|
|
35
|
+
if (!jsonResult.data) throw new Error("\u8FD4\u56DE\u6570\u636E\u4E3A\u7A7A");
|
|
36
|
+
resolve(jsonResult.data);
|
|
37
|
+
callback == null ? void 0 : callback(jsonResult.data);
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
// 触发app调用并监听
|
|
42
|
+
this.call = (methodKey, params, minimumVersion) => {
|
|
43
|
+
if (minimumVersion && compare(appVersion, minimumVersion, "<")) throw new Error("\u8BF7\u5347\u7EA7\u81F3\u6700\u65B0\u7248\u672CAPP\u540E\u4F7F\u7528");
|
|
44
|
+
const callback = this.listen(methodKey);
|
|
45
|
+
this.sendMessage(methodKey, params);
|
|
46
|
+
return callback;
|
|
47
|
+
};
|
|
48
|
+
// 触发app调用并监听 通用版本 此方法在APP中优化了版本控制逻辑 当方法不存在时会返回404
|
|
49
|
+
this.callCommon = (methodKey, params, minimumVersion) => {
|
|
50
|
+
if (minimumVersion && compare(appVersion, minimumVersion, "<")) throw new Error("\u8BF7\u5347\u7EA7\u81F3\u6700\u65B0\u7248\u672CAPP\u540E\u4F7F\u7528");
|
|
51
|
+
const callback = this.listen(methodKey);
|
|
52
|
+
this.sendMessage("JSBridge" /* JS_BRIDGE */, { method: methodKey, params });
|
|
53
|
+
return callback;
|
|
54
|
+
};
|
|
55
|
+
if (!isApp) return;
|
|
56
|
+
window.ejsBridgeCallback = (type, jsonString) => {
|
|
57
|
+
var _a, _b;
|
|
58
|
+
return (_b = (_a = this.callbackDict)[type]) == null ? void 0 : _b.call(_a, jsonString);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var appJSBridge = new AppJSBridge();
|
|
63
|
+
function appLogin(params) {
|
|
64
|
+
return __async(this, null, function* () {
|
|
65
|
+
return appJSBridge.call("login" /* LOGIN */, params);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function appChooseImage(params) {
|
|
69
|
+
return __async(this, null, function* () {
|
|
70
|
+
return appJSBridge.call("chooseImage" /* CHOOSE_IMAGE */, params);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function appWechatShareImg(params) {
|
|
74
|
+
return __async(this, null, function* () {
|
|
75
|
+
return appJSBridge.call("wechatShareImg" /* WECHAT_SHARE_IMG */, params);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function appSaveImage(params) {
|
|
79
|
+
return __async(this, null, function* () {
|
|
80
|
+
return appJSBridge.call("saveImage" /* SAVE_IMAGE */, params);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function appH5RouterChange(params) {
|
|
84
|
+
return __async(this, null, function* () {
|
|
85
|
+
return appJSBridge.call("h5RouterChange" /* H5_ROUTER_CHANGE */, params);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function appScanCode(params) {
|
|
89
|
+
return __async(this, null, function* () {
|
|
90
|
+
return appJSBridge.callCommon("scanCode" /* SCAN_CODE */, params, "3.21.0");
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
appChooseImage,
|
|
95
|
+
appH5RouterChange,
|
|
96
|
+
appLogin,
|
|
97
|
+
appSaveImage,
|
|
98
|
+
appScanCode,
|
|
99
|
+
appWechatShareImg
|
|
100
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/storage.h5.ts
|
|
2
|
+
import cookies from "js-cookie";
|
|
3
|
+
function getLocalData(name) {
|
|
4
|
+
return cookies.get(name) || "";
|
|
5
|
+
}
|
|
6
|
+
function setLocalData(params) {
|
|
7
|
+
const { key, data, expireDays = 365 } = params;
|
|
8
|
+
const expires = new Date(Date.now() + expireDays * 24 * 60 * 60 * 1e3);
|
|
9
|
+
cookies.set(key, data, { expires });
|
|
10
|
+
}
|
|
11
|
+
function removeLocalData(key) {
|
|
12
|
+
setLocalData({ key, data: "", expireDays: -1 });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
getLocalData,
|
|
17
|
+
setLocalData,
|
|
18
|
+
removeLocalData
|
|
19
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// src/storage.weapp.ts
|
|
2
|
+
import Taro from "@tarojs/taro";
|
|
3
|
+
function getLocalData(name) {
|
|
4
|
+
return Taro.getStorageSync(name);
|
|
5
|
+
}
|
|
6
|
+
function setLocalData(params) {
|
|
7
|
+
const { key, data } = params;
|
|
8
|
+
Taro.setStorageSync(key, data);
|
|
9
|
+
}
|
|
10
|
+
function removeLocalData(key) {
|
|
11
|
+
Taro.removeStorageSync(key);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
getLocalData,
|
|
16
|
+
setLocalData,
|
|
17
|
+
removeLocalData
|
|
18
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLocalData
|
|
3
|
+
} from "./chunk-L74XPUIL.mjs";
|
|
4
|
+
|
|
5
|
+
// src/env.ts
|
|
6
|
+
import Taro from "@tarojs/taro";
|
|
7
|
+
var ENV = Taro.getEnv().toLocaleLowerCase();
|
|
8
|
+
var version = "0.0.1";
|
|
9
|
+
var platform = process.env.TARO_ENV || "weapp";
|
|
10
|
+
var isH5 = platform === "h5";
|
|
11
|
+
var isWeapp = platform === "weapp";
|
|
12
|
+
var isProduction = process.env.NODE_ENV === "production";
|
|
13
|
+
var _a;
|
|
14
|
+
var isSaasAndroidApp = isH5 && /SAAS_ANDROID/i.test((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent);
|
|
15
|
+
var _a2;
|
|
16
|
+
var isSaasIOSApp = isH5 && /SAAS_IOS/i.test((_a2 = window == null ? void 0 : window.navigator) == null ? void 0 : _a2.userAgent);
|
|
17
|
+
var isSaasAPP = isSaasAndroidApp || isSaasIOSApp;
|
|
18
|
+
var isApp = isSaasAPP;
|
|
19
|
+
var _a3, _b, _c;
|
|
20
|
+
var appVersion = isApp ? ((_c = (_b = (_a3 = window == null ? void 0 : window.navigator) == null ? void 0 : _a3.userAgent) == null ? void 0 : _b.match(/version:(\d+\.\d+\.\d+);/)) == null ? void 0 : _c[1]) || "" : "";
|
|
21
|
+
var apiEnv = process.env.API_ENV || getLocalData("apiEnv");
|
|
22
|
+
|
|
23
|
+
export {
|
|
24
|
+
ENV,
|
|
25
|
+
version,
|
|
26
|
+
platform,
|
|
27
|
+
isH5,
|
|
28
|
+
isWeapp,
|
|
29
|
+
isProduction,
|
|
30
|
+
isSaasAndroidApp,
|
|
31
|
+
isSaasIOSApp,
|
|
32
|
+
isSaasAPP,
|
|
33
|
+
isApp,
|
|
34
|
+
appVersion,
|
|
35
|
+
apiEnv
|
|
36
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLocalData,
|
|
3
|
+
removeLocalData,
|
|
4
|
+
setLocalData
|
|
5
|
+
} from "./chunk-52AS66K5.mjs";
|
|
6
|
+
import {
|
|
7
|
+
getLocalData as getLocalData2,
|
|
8
|
+
removeLocalData as removeLocalData2,
|
|
9
|
+
setLocalData as setLocalData2
|
|
10
|
+
} from "./chunk-6BTIQCMF.mjs";
|
|
11
|
+
|
|
12
|
+
// src/storage.ts
|
|
13
|
+
var platform = process.env.TARO_ENV || "weapp";
|
|
14
|
+
var isWeapp = platform === "weapp";
|
|
15
|
+
var getLocalData3 = isWeapp ? getLocalData2 : getLocalData;
|
|
16
|
+
var setLocalData3 = isWeapp ? setLocalData2 : setLocalData;
|
|
17
|
+
var removeLocalData3 = isWeapp ? removeLocalData2 : removeLocalData;
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
platform,
|
|
21
|
+
getLocalData3 as getLocalData,
|
|
22
|
+
setLocalData3 as setLocalData,
|
|
23
|
+
removeLocalData3 as removeLocalData
|
|
24
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
4
|
+
var __objRest = (source, exclude) => {
|
|
5
|
+
var target = {};
|
|
6
|
+
for (var prop in source)
|
|
7
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
8
|
+
target[prop] = source[prop];
|
|
9
|
+
if (source != null && __getOwnPropSymbols)
|
|
10
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
11
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
12
|
+
target[prop] = source[prop];
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
var __async = (__this, __arguments, generator) => {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
var fulfilled = (value) => {
|
|
19
|
+
try {
|
|
20
|
+
step(generator.next(value));
|
|
21
|
+
} catch (e) {
|
|
22
|
+
reject(e);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var rejected = (value) => {
|
|
26
|
+
try {
|
|
27
|
+
step(generator.throw(value));
|
|
28
|
+
} catch (e) {
|
|
29
|
+
reject(e);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
33
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
__objRest,
|
|
39
|
+
__async
|
|
40
|
+
};
|
package/dist/env.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type ApiEnv = 'dev' | 'stage' | 'beta' | 'prod' | `test${number | ''}`;
|
|
2
|
+
declare const ENV: string;
|
|
3
|
+
declare const version = "0.0.1";
|
|
4
|
+
declare const platform: string;
|
|
5
|
+
declare const isH5: boolean;
|
|
6
|
+
declare const isWeapp: boolean;
|
|
7
|
+
declare const isProduction: boolean;
|
|
8
|
+
declare const isSaasAndroidApp: boolean;
|
|
9
|
+
declare const isSaasIOSApp: boolean;
|
|
10
|
+
declare const isSaasAPP: boolean;
|
|
11
|
+
declare const isApp: boolean;
|
|
12
|
+
declare const appVersion: string;
|
|
13
|
+
declare const apiEnv: ApiEnv;
|
|
14
|
+
|
|
15
|
+
export { type ApiEnv, ENV, apiEnv, appVersion, isApp, isH5, isProduction, isSaasAPP, isSaasAndroidApp, isSaasIOSApp, isWeapp, platform, version };
|
package/dist/env.js
CHANGED
|
@@ -17,7 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -47,49 +46,22 @@ __export(env_exports, {
|
|
|
47
46
|
module.exports = __toCommonJS(env_exports);
|
|
48
47
|
var import_taro2 = __toESM(require("@tarojs/taro"));
|
|
49
48
|
|
|
50
|
-
// src/storage.ts
|
|
51
|
-
var storage_exports = {};
|
|
52
|
-
__export(storage_exports, {
|
|
53
|
-
getLocalData: () => getLocalData3,
|
|
54
|
-
platform: () => platform,
|
|
55
|
-
removeLocalData: () => removeLocalData3,
|
|
56
|
-
setLocalData: () => setLocalData3
|
|
57
|
-
});
|
|
58
|
-
|
|
59
49
|
// src/storage.h5.ts
|
|
60
50
|
var import_js_cookie = __toESM(require("js-cookie"));
|
|
61
51
|
function getLocalData(name) {
|
|
62
52
|
return import_js_cookie.default.get(name) || "";
|
|
63
53
|
}
|
|
64
|
-
function setLocalData(params) {
|
|
65
|
-
const { key, data, expireDays = 365 } = params;
|
|
66
|
-
const expires = new Date(Date.now() + expireDays * 24 * 60 * 60 * 1e3);
|
|
67
|
-
import_js_cookie.default.set(key, data, { expires });
|
|
68
|
-
}
|
|
69
|
-
function removeLocalData(key) {
|
|
70
|
-
setLocalData({ key, data: "", expireDays: -1 });
|
|
71
|
-
}
|
|
72
54
|
|
|
73
55
|
// src/storage.weapp.ts
|
|
74
56
|
var import_taro = __toESM(require("@tarojs/taro"));
|
|
75
57
|
function getLocalData2(name) {
|
|
76
58
|
return import_taro.default.getStorageSync(name);
|
|
77
59
|
}
|
|
78
|
-
function setLocalData2(params) {
|
|
79
|
-
const { key, data } = params;
|
|
80
|
-
import_taro.default.setStorageSync(key, data);
|
|
81
|
-
}
|
|
82
|
-
function removeLocalData2(key) {
|
|
83
|
-
import_taro.default.removeStorageSync(key);
|
|
84
|
-
}
|
|
85
60
|
|
|
86
61
|
// src/storage.ts
|
|
87
|
-
__reExport(storage_exports, require("query-string"));
|
|
88
62
|
var platform = process.env.TARO_ENV || "weapp";
|
|
89
63
|
var isWeapp = platform === "weapp";
|
|
90
64
|
var getLocalData3 = isWeapp ? getLocalData2 : getLocalData;
|
|
91
|
-
var setLocalData3 = isWeapp ? setLocalData2 : setLocalData;
|
|
92
|
-
var removeLocalData3 = isWeapp ? removeLocalData2 : removeLocalData;
|
|
93
65
|
|
|
94
66
|
// src/env.ts
|
|
95
67
|
var ENV = import_taro2.default.getEnv().toLocaleLowerCase();
|
package/dist/env.mjs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ENV,
|
|
3
|
+
apiEnv,
|
|
4
|
+
appVersion,
|
|
5
|
+
isApp,
|
|
6
|
+
isH5,
|
|
7
|
+
isProduction,
|
|
8
|
+
isSaasAPP,
|
|
9
|
+
isSaasAndroidApp,
|
|
10
|
+
isSaasIOSApp,
|
|
11
|
+
isWeapp,
|
|
12
|
+
platform,
|
|
13
|
+
version
|
|
14
|
+
} from "./chunk-7KLLRNFF.mjs";
|
|
15
|
+
import "./chunk-L74XPUIL.mjs";
|
|
16
|
+
import "./chunk-52AS66K5.mjs";
|
|
17
|
+
import "./chunk-6BTIQCMF.mjs";
|
|
18
|
+
import "./chunk-SGFGNEI2.mjs";
|
|
19
|
+
export {
|
|
20
|
+
ENV,
|
|
21
|
+
apiEnv,
|
|
22
|
+
appVersion,
|
|
23
|
+
isApp,
|
|
24
|
+
isH5,
|
|
25
|
+
isProduction,
|
|
26
|
+
isSaasAPP,
|
|
27
|
+
isSaasAndroidApp,
|
|
28
|
+
isSaasIOSApp,
|
|
29
|
+
isWeapp,
|
|
30
|
+
platform,
|
|
31
|
+
version
|
|
32
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { setLocalData as setLocalData$1 } from './storage.h5.mjs';
|
|
2
|
+
import { getLocalData as getLocalData$1, removeLocalData as removeLocalData$1 } from './storage.weapp.mjs';
|
|
3
|
+
|
|
4
|
+
declare const platform: string;
|
|
5
|
+
declare const getLocalData: typeof getLocalData$1;
|
|
6
|
+
declare const setLocalData: typeof setLocalData$1;
|
|
7
|
+
declare const removeLocalData: typeof removeLocalData$1;
|
|
8
|
+
|
|
9
|
+
export { getLocalData, platform, removeLocalData, setLocalData };
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { setLocalData as setLocalData$1 } from './storage.h5.js';
|
|
2
2
|
import { getLocalData as getLocalData$1, removeLocalData as removeLocalData$1 } from './storage.weapp.js';
|
|
3
|
-
export * from 'query-string';
|
|
4
3
|
|
|
5
4
|
declare const platform: string;
|
|
6
5
|
declare const getLocalData: typeof getLocalData$1;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare function getLocalData(name: string): string;
|
|
2
|
+
declare function setLocalData(params: {
|
|
3
|
+
key: string;
|
|
4
|
+
data: any;
|
|
5
|
+
expireDays?: number;
|
|
6
|
+
}): void;
|
|
7
|
+
declare function removeLocalData(key: string): void;
|
|
8
|
+
|
|
9
|
+
export { getLocalData, removeLocalData, setLocalData };
|
package/dist/storage.js
CHANGED
|
@@ -17,7 +17,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -66,7 +65,6 @@ function removeLocalData2(key) {
|
|
|
66
65
|
}
|
|
67
66
|
|
|
68
67
|
// src/storage.ts
|
|
69
|
-
__reExport(storage_exports, require("query-string"), module.exports);
|
|
70
68
|
var platform = process.env.TARO_ENV || "weapp";
|
|
71
69
|
var isWeapp = platform === "weapp";
|
|
72
70
|
var getLocalData3 = isWeapp ? getLocalData2 : getLocalData;
|
|
@@ -77,6 +75,5 @@ var removeLocalData3 = isWeapp ? removeLocalData2 : removeLocalData;
|
|
|
77
75
|
getLocalData,
|
|
78
76
|
platform,
|
|
79
77
|
removeLocalData,
|
|
80
|
-
setLocalData
|
|
81
|
-
...require("query-string")
|
|
78
|
+
setLocalData
|
|
82
79
|
});
|
package/dist/storage.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getLocalData,
|
|
3
|
+
platform,
|
|
4
|
+
removeLocalData,
|
|
5
|
+
setLocalData
|
|
6
|
+
} from "./chunk-L74XPUIL.mjs";
|
|
7
|
+
import "./chunk-52AS66K5.mjs";
|
|
8
|
+
import "./chunk-6BTIQCMF.mjs";
|
|
9
|
+
import "./chunk-SGFGNEI2.mjs";
|
|
10
|
+
export {
|
|
11
|
+
getLocalData,
|
|
12
|
+
platform,
|
|
13
|
+
removeLocalData,
|
|
14
|
+
setLocalData
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare function getLocalData(name: string): any;
|
|
2
|
+
declare function setLocalData(params: {
|
|
3
|
+
key: string;
|
|
4
|
+
data: any;
|
|
5
|
+
expireDays?: number;
|
|
6
|
+
}): void;
|
|
7
|
+
declare function removeLocalData(key: string): void;
|
|
8
|
+
|
|
9
|
+
export { getLocalData, removeLocalData, setLocalData };
|
package/dist/tools.d.mts
ADDED
package/dist/tools.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ type InGetQuery = {
|
|
|
2
2
|
decode?: boolean;
|
|
3
3
|
parse?: boolean;
|
|
4
4
|
};
|
|
5
|
-
declare const getQuery: <P extends Partial<Record<string, string
|
|
5
|
+
declare const getQuery: <P extends Partial<Record<string, string>>>(params?: InGetQuery) => P;
|
|
6
6
|
|
|
7
7
|
export { type InGetQuery, getQuery };
|
package/dist/tools.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__objRest
|
|
3
|
+
} from "./chunk-SGFGNEI2.mjs";
|
|
4
|
+
|
|
5
|
+
// src/tools.ts
|
|
6
|
+
import Taro from "@tarojs/taro";
|
|
7
|
+
var getQuery = (params) => {
|
|
8
|
+
var _a;
|
|
9
|
+
const { decode = false, parse = false } = params || {};
|
|
10
|
+
const _b = ((_a = Taro.getCurrentInstance().router) == null ? void 0 : _a.params) || {}, { stamp, $taroTimestamp } = _b, query = __objRest(_b, ["stamp", "$taroTimestamp"]);
|
|
11
|
+
if (!decode && !parse) return query;
|
|
12
|
+
const decodedQuery = {};
|
|
13
|
+
Object.keys(query).forEach((key) => {
|
|
14
|
+
const value = query[key] || "";
|
|
15
|
+
try {
|
|
16
|
+
decodedQuery[key] = parse ? JSON.parse(decodeURIComponent(value)) : decodeURIComponent(value);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
decodedQuery[key] = decodeURIComponent(value);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return decodedQuery;
|
|
22
|
+
};
|
|
23
|
+
export {
|
|
24
|
+
getQuery
|
|
25
|
+
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/mini-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"module": "dist/*.js",
|
|
6
6
|
"types": "types/*.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
"./*": {
|
|
9
9
|
"import": {
|
|
10
|
-
"types": "./dist/*.d.
|
|
11
|
-
"default": "./dist/*.
|
|
10
|
+
"types": "./dist/*.d.mts",
|
|
11
|
+
"default": "./dist/*.mjs"
|
|
12
12
|
},
|
|
13
13
|
"require": {
|
|
14
14
|
"types": "./dist/*.d.ts",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"query-string": "^7.1.3",
|
|
24
23
|
"js-cookie": "^3.0.5",
|
|
25
24
|
"@tarojs/taro": "4.0.8",
|
|
26
25
|
"compare-versions": "^6.1.1"
|