@hlw-uni/mp-vue 2.1.11 → 2.1.12
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/composables/algo/index.d.ts +7 -0
- package/dist/composables/algo/uuid.d.ts +17 -0
- package/dist/composables/index.d.ts +1 -0
- package/dist/index.js +13 -0
- package/dist/index.mjs +13 -0
- package/package.json +1 -1
- package/src/composables/algo/index.ts +7 -0
- package/src/composables/algo/uuid.ts +27 -0
- package/src/composables/index.ts +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID v4 生成器(RFC 4122 v4 算法),返回 32 字符 hex(无连字符)。
|
|
3
|
+
*
|
|
4
|
+
* 用途:当 nonce、idempotency key、临时唯一标识用。
|
|
5
|
+
*
|
|
6
|
+
* 算法:
|
|
7
|
+
* 1. 生成 16 字节随机源
|
|
8
|
+
* 2. byte 6 高 4 位置成 0100 标版本号 v4
|
|
9
|
+
* 3. byte 8 高 2 位置成 10 标变体(RFC 4122)
|
|
10
|
+
* 4. 16 字节转 hex 拼成 32 字符串
|
|
11
|
+
*
|
|
12
|
+
* 注意:随机源用 Math.random(小程序兼容兜底),加密强度有限,
|
|
13
|
+
* 不能用于密钥派生 / token 签发,只能挡重放。
|
|
14
|
+
*/
|
|
15
|
+
export declare function useUuid(): {
|
|
16
|
+
v4: () => string;
|
|
17
|
+
};
|
|
@@ -16,6 +16,7 @@ export { useContact, setConfigContact, type ContactConfig, type ContactAdapter,
|
|
|
16
16
|
export { useUtils, type DownloadFileOptions, type DownloadFileResult, type TapEvent } from './utils';
|
|
17
17
|
export { useColor } from './color';
|
|
18
18
|
export { useRouter, type NavigateType, type NavigateOptions } from './navigator';
|
|
19
|
+
export { useUuid } from './algo';
|
|
19
20
|
export type { FontScale, FontPreset } from './theme';
|
|
20
21
|
export { FONT_SCALE_KEY, FONT_PRESETS, getCurrentFontScale, getCurrentFontVars, THEME_CHANGE_EVENT, buildThemeStyle, useThemePageStyle, } from './theme';
|
|
21
22
|
export type { ThemeColor } from './theme';
|
package/dist/index.js
CHANGED
|
@@ -1138,6 +1138,18 @@ var __publicField = (obj, key, value) => {
|
|
|
1138
1138
|
navigate: doNavigate
|
|
1139
1139
|
};
|
|
1140
1140
|
}
|
|
1141
|
+
function useUuid() {
|
|
1142
|
+
function v4() {
|
|
1143
|
+
const bytes = [];
|
|
1144
|
+
for (let i = 0; i < 16; i++) {
|
|
1145
|
+
bytes.push(Math.floor(Math.random() * 256));
|
|
1146
|
+
}
|
|
1147
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
1148
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
1149
|
+
return bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1150
|
+
}
|
|
1151
|
+
return { v4 };
|
|
1152
|
+
}
|
|
1141
1153
|
const useThemeStore = pinia.defineStore(
|
|
1142
1154
|
"theme",
|
|
1143
1155
|
() => {
|
|
@@ -1940,6 +1952,7 @@ var __publicField = (obj, key, value) => {
|
|
|
1940
1952
|
exports2.useThemeStore = useThemeStore;
|
|
1941
1953
|
exports2.useUpload = useUpload;
|
|
1942
1954
|
exports2.useUtils = useUtils;
|
|
1955
|
+
exports2.useUuid = useUuid;
|
|
1943
1956
|
exports2.useValidate = useValidate;
|
|
1944
1957
|
exports2.vCopy = vCopy;
|
|
1945
1958
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
package/dist/index.mjs
CHANGED
|
@@ -1137,6 +1137,18 @@ function useRouter() {
|
|
|
1137
1137
|
navigate: doNavigate
|
|
1138
1138
|
};
|
|
1139
1139
|
}
|
|
1140
|
+
function useUuid() {
|
|
1141
|
+
function v4() {
|
|
1142
|
+
const bytes = [];
|
|
1143
|
+
for (let i = 0; i < 16; i++) {
|
|
1144
|
+
bytes.push(Math.floor(Math.random() * 256));
|
|
1145
|
+
}
|
|
1146
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
1147
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
1148
|
+
return bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1149
|
+
}
|
|
1150
|
+
return { v4 };
|
|
1151
|
+
}
|
|
1140
1152
|
const useThemeStore = defineStore(
|
|
1141
1153
|
"theme",
|
|
1142
1154
|
() => {
|
|
@@ -1940,6 +1952,7 @@ export {
|
|
|
1940
1952
|
useThemeStore,
|
|
1941
1953
|
useUpload,
|
|
1942
1954
|
useUtils,
|
|
1955
|
+
useUuid,
|
|
1943
1956
|
useValidate,
|
|
1944
1957
|
vCopy
|
|
1945
1958
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID v4 生成器(RFC 4122 v4 算法),返回 32 字符 hex(无连字符)。
|
|
3
|
+
*
|
|
4
|
+
* 用途:当 nonce、idempotency key、临时唯一标识用。
|
|
5
|
+
*
|
|
6
|
+
* 算法:
|
|
7
|
+
* 1. 生成 16 字节随机源
|
|
8
|
+
* 2. byte 6 高 4 位置成 0100 标版本号 v4
|
|
9
|
+
* 3. byte 8 高 2 位置成 10 标变体(RFC 4122)
|
|
10
|
+
* 4. 16 字节转 hex 拼成 32 字符串
|
|
11
|
+
*
|
|
12
|
+
* 注意:随机源用 Math.random(小程序兼容兜底),加密强度有限,
|
|
13
|
+
* 不能用于密钥派生 / token 签发,只能挡重放。
|
|
14
|
+
*/
|
|
15
|
+
export function useUuid() {
|
|
16
|
+
function v4(): string {
|
|
17
|
+
const bytes: number[] = [];
|
|
18
|
+
for (let i = 0; i < 16; i++) {
|
|
19
|
+
bytes.push(Math.floor(Math.random() * 256));
|
|
20
|
+
}
|
|
21
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
22
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
23
|
+
return bytes.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return { v4 };
|
|
27
|
+
}
|
package/src/composables/index.ts
CHANGED
|
@@ -45,6 +45,7 @@ export {
|
|
|
45
45
|
export { useUtils, type DownloadFileOptions, type DownloadFileResult, type TapEvent } from "./utils";
|
|
46
46
|
export { useColor } from "./color";
|
|
47
47
|
export { useRouter, type NavigateType, type NavigateOptions } from "./navigator";
|
|
48
|
+
export { useUuid } from "./algo";
|
|
48
49
|
|
|
49
50
|
// Theme(mp-vue 自带)
|
|
50
51
|
export type { FontScale, FontPreset } from "./theme";
|