@hlw-uni-mp/use 1.1.0 → 1.1.2
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/index.d.mts +2 -23
- package/dist/index.d.ts +2 -23
- package/dist/index.js +6 -49
- package/dist/index.mjs +6 -48
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as pinia from 'pinia';
|
|
2
|
-
import { PiniaPluginContext } from 'pinia';
|
|
3
2
|
import { App, Ref, ComputedRef } from 'vue';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -13,12 +12,10 @@ interface ToastRes {
|
|
|
13
12
|
/** 模态弹窗配置 */
|
|
14
13
|
modalOptions?: UniApp.ShowModalOptions;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
/**
|
|
18
16
|
* 提示回调函数类型 (confirm 为 true 表示确定,false 为取消)
|
|
19
17
|
*/
|
|
20
18
|
type ToastCallback = (confirm: boolean) => void;
|
|
21
|
-
|
|
22
19
|
/**
|
|
23
20
|
* 消息门面体
|
|
24
21
|
*/
|
|
@@ -38,7 +35,6 @@ interface HlwMsg {
|
|
|
38
35
|
/** 标题进度条 */
|
|
39
36
|
setLoadingBar(progress: number): void;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
/**
|
|
43
39
|
* 统一的消息提示与弹窗能力 hook。
|
|
44
40
|
*
|
|
@@ -63,28 +59,13 @@ declare const hlw: {
|
|
|
63
59
|
};
|
|
64
60
|
type HlwInstance = typeof hlw;
|
|
65
61
|
|
|
66
|
-
/**
|
|
67
|
-
* 持久化配置项
|
|
68
|
-
*/
|
|
69
|
-
interface PersistOptions {
|
|
70
|
-
/** 自定义本地存储键名,默认为 store.$id */
|
|
71
|
-
key?: string;
|
|
72
|
-
/** 持久化白名单字段列表,默认持久化全部 state */
|
|
73
|
-
paths?: string[];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
62
|
declare module "pinia" {
|
|
77
63
|
interface DefineStoreOptionsBase<S, Store> {
|
|
78
64
|
/** 本地持久化配置 */
|
|
79
|
-
unistorage?: boolean |
|
|
65
|
+
unistorage?: boolean | object;
|
|
80
66
|
}
|
|
81
67
|
}
|
|
82
68
|
|
|
83
|
-
/**
|
|
84
|
-
* 创建 Pinia 本地持久化存储插件
|
|
85
|
-
*/
|
|
86
|
-
declare function storage(): (context: PiniaPluginContext) => void;
|
|
87
|
-
|
|
88
69
|
/**
|
|
89
70
|
* 外观模式型
|
|
90
71
|
*/
|
|
@@ -222,7 +203,6 @@ interface ShareConfig {
|
|
|
222
203
|
/** 分享卡片封面图 */
|
|
223
204
|
imageUrl?: string;
|
|
224
205
|
}
|
|
225
|
-
|
|
226
206
|
/**
|
|
227
207
|
* 分享操作句柄
|
|
228
208
|
*/
|
|
@@ -230,7 +210,6 @@ interface ShareHandlers {
|
|
|
230
210
|
/** 显式调起分享菜单 */
|
|
231
211
|
showShareMenu: () => void;
|
|
232
212
|
}
|
|
233
|
-
|
|
234
213
|
/**
|
|
235
214
|
* 显式调起分享菜单
|
|
236
215
|
*/
|
|
@@ -272,4 +251,4 @@ interface UseRefsReturn<T = unknown> {
|
|
|
272
251
|
*/
|
|
273
252
|
declare function useRefs<T = unknown>(): UseRefsReturn<T>;
|
|
274
253
|
|
|
275
|
-
export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type HlwInstance, type HlwMsg, type InitThemeOptions, type
|
|
254
|
+
export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type HlwInstance, type HlwMsg, type InitThemeOptions, type ShareConfig, type ShareHandlers, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type ToastCallback, type ToastRes, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, hlw, initTheme, showShareMenu, useMsg, useRefs, useShare, useTheme, useThemeStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as pinia from 'pinia';
|
|
2
|
-
import { PiniaPluginContext } from 'pinia';
|
|
3
2
|
import { App, Ref, ComputedRef } from 'vue';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -13,12 +12,10 @@ interface ToastRes {
|
|
|
13
12
|
/** 模态弹窗配置 */
|
|
14
13
|
modalOptions?: UniApp.ShowModalOptions;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
/**
|
|
18
16
|
* 提示回调函数类型 (confirm 为 true 表示确定,false 为取消)
|
|
19
17
|
*/
|
|
20
18
|
type ToastCallback = (confirm: boolean) => void;
|
|
21
|
-
|
|
22
19
|
/**
|
|
23
20
|
* 消息门面体
|
|
24
21
|
*/
|
|
@@ -38,7 +35,6 @@ interface HlwMsg {
|
|
|
38
35
|
/** 标题进度条 */
|
|
39
36
|
setLoadingBar(progress: number): void;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
38
|
/**
|
|
43
39
|
* 统一的消息提示与弹窗能力 hook。
|
|
44
40
|
*
|
|
@@ -63,28 +59,13 @@ declare const hlw: {
|
|
|
63
59
|
};
|
|
64
60
|
type HlwInstance = typeof hlw;
|
|
65
61
|
|
|
66
|
-
/**
|
|
67
|
-
* 持久化配置项
|
|
68
|
-
*/
|
|
69
|
-
interface PersistOptions {
|
|
70
|
-
/** 自定义本地存储键名,默认为 store.$id */
|
|
71
|
-
key?: string;
|
|
72
|
-
/** 持久化白名单字段列表,默认持久化全部 state */
|
|
73
|
-
paths?: string[];
|
|
74
|
-
}
|
|
75
|
-
|
|
76
62
|
declare module "pinia" {
|
|
77
63
|
interface DefineStoreOptionsBase<S, Store> {
|
|
78
64
|
/** 本地持久化配置 */
|
|
79
|
-
unistorage?: boolean |
|
|
65
|
+
unistorage?: boolean | object;
|
|
80
66
|
}
|
|
81
67
|
}
|
|
82
68
|
|
|
83
|
-
/**
|
|
84
|
-
* 创建 Pinia 本地持久化存储插件
|
|
85
|
-
*/
|
|
86
|
-
declare function storage(): (context: PiniaPluginContext) => void;
|
|
87
|
-
|
|
88
69
|
/**
|
|
89
70
|
* 外观模式型
|
|
90
71
|
*/
|
|
@@ -222,7 +203,6 @@ interface ShareConfig {
|
|
|
222
203
|
/** 分享卡片封面图 */
|
|
223
204
|
imageUrl?: string;
|
|
224
205
|
}
|
|
225
|
-
|
|
226
206
|
/**
|
|
227
207
|
* 分享操作句柄
|
|
228
208
|
*/
|
|
@@ -230,7 +210,6 @@ interface ShareHandlers {
|
|
|
230
210
|
/** 显式调起分享菜单 */
|
|
231
211
|
showShareMenu: () => void;
|
|
232
212
|
}
|
|
233
|
-
|
|
234
213
|
/**
|
|
235
214
|
* 显式调起分享菜单
|
|
236
215
|
*/
|
|
@@ -272,4 +251,4 @@ interface UseRefsReturn<T = unknown> {
|
|
|
272
251
|
*/
|
|
273
252
|
declare function useRefs<T = unknown>(): UseRefsReturn<T>;
|
|
274
253
|
|
|
275
|
-
export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type HlwInstance, type HlwMsg, type InitThemeOptions, type
|
|
254
|
+
export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type HlwInstance, type HlwMsg, type InitThemeOptions, type ShareConfig, type ShareHandlers, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type ToastCallback, type ToastRes, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, hlw, initTheme, showShareMenu, useMsg, useRefs, useShare, useTheme, useThemeStore };
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,6 @@ __export(index_exports, {
|
|
|
29
29
|
hlw: () => hlw,
|
|
30
30
|
initTheme: () => initTheme,
|
|
31
31
|
showShareMenu: () => showShareMenu,
|
|
32
|
-
storage: () => storage,
|
|
33
32
|
useMsg: () => useMsg,
|
|
34
33
|
useRefs: () => useRefs,
|
|
35
34
|
useShare: () => useShare,
|
|
@@ -148,48 +147,9 @@ var import_vue = require("vue");
|
|
|
148
147
|
// src/theme/store.ts
|
|
149
148
|
var import_pinia2 = require("pinia");
|
|
150
149
|
|
|
151
|
-
// src/
|
|
150
|
+
// src/theme/types.d.ts
|
|
152
151
|
var import_pinia = require("pinia");
|
|
153
152
|
|
|
154
|
-
// src/storage/index.ts
|
|
155
|
-
function storage() {
|
|
156
|
-
return (context) => {
|
|
157
|
-
const { store, options } = context;
|
|
158
|
-
const config = options.unistorage;
|
|
159
|
-
if (!config) return;
|
|
160
|
-
const storageKey = typeof config === "object" && config?.key || store.$id;
|
|
161
|
-
const paths = typeof config === "object" ? config?.paths : void 0;
|
|
162
|
-
try {
|
|
163
|
-
const cached = uni.getStorageSync(storageKey);
|
|
164
|
-
if (cached) {
|
|
165
|
-
const data = typeof cached === "string" ? JSON.parse(cached) : cached;
|
|
166
|
-
if (typeof data === "object" && data !== null) {
|
|
167
|
-
store.$patch(data);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
} catch (error) {
|
|
171
|
-
console.error(`[Storage] \u6062\u590D ${store.$id} \u5931\u8D25:`, error);
|
|
172
|
-
}
|
|
173
|
-
store.$subscribe(
|
|
174
|
-
(_, state) => {
|
|
175
|
-
try {
|
|
176
|
-
let toSave = state;
|
|
177
|
-
if (paths && Array.isArray(paths)) {
|
|
178
|
-
toSave = paths.reduce((acc, key) => {
|
|
179
|
-
if (key in state) acc[key] = state[key];
|
|
180
|
-
return acc;
|
|
181
|
-
}, {});
|
|
182
|
-
}
|
|
183
|
-
uni.setStorageSync(storageKey, toSave);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
console.error(`[Storage] \u4FDD\u5B58 ${store.$id} \u5931\u8D25:`, error);
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
{ detached: true }
|
|
189
|
-
);
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
|
|
193
153
|
// src/theme/store.ts
|
|
194
154
|
var fontSizePresets = [
|
|
195
155
|
{
|
|
@@ -358,13 +318,11 @@ function showShareMenu() {
|
|
|
358
318
|
function useShare(config = {}) {
|
|
359
319
|
showShareMenu();
|
|
360
320
|
(0, import_uni_app.onShareAppMessage)(() => ({ ...config }));
|
|
361
|
-
(0, import_uni_app.onShareTimeline)(() => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
};
|
|
367
|
-
});
|
|
321
|
+
(0, import_uni_app.onShareTimeline)(() => ({
|
|
322
|
+
title: config.title,
|
|
323
|
+
query: config.path?.split("?")[1],
|
|
324
|
+
imageUrl: config.imageUrl
|
|
325
|
+
}));
|
|
368
326
|
return {
|
|
369
327
|
showShareMenu
|
|
370
328
|
};
|
|
@@ -396,7 +354,6 @@ function useRefs() {
|
|
|
396
354
|
hlw,
|
|
397
355
|
initTheme,
|
|
398
356
|
showShareMenu,
|
|
399
|
-
storage,
|
|
400
357
|
useMsg,
|
|
401
358
|
useRefs,
|
|
402
359
|
useShare,
|
package/dist/index.mjs
CHANGED
|
@@ -108,48 +108,9 @@ import { computed, toRef } from "vue";
|
|
|
108
108
|
// src/theme/store.ts
|
|
109
109
|
import { defineStore } from "pinia";
|
|
110
110
|
|
|
111
|
-
// src/
|
|
111
|
+
// src/theme/types.d.ts
|
|
112
112
|
import "pinia";
|
|
113
113
|
|
|
114
|
-
// src/storage/index.ts
|
|
115
|
-
function storage() {
|
|
116
|
-
return (context) => {
|
|
117
|
-
const { store, options } = context;
|
|
118
|
-
const config = options.unistorage;
|
|
119
|
-
if (!config) return;
|
|
120
|
-
const storageKey = typeof config === "object" && config?.key || store.$id;
|
|
121
|
-
const paths = typeof config === "object" ? config?.paths : void 0;
|
|
122
|
-
try {
|
|
123
|
-
const cached = uni.getStorageSync(storageKey);
|
|
124
|
-
if (cached) {
|
|
125
|
-
const data = typeof cached === "string" ? JSON.parse(cached) : cached;
|
|
126
|
-
if (typeof data === "object" && data !== null) {
|
|
127
|
-
store.$patch(data);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.error(`[Storage] \u6062\u590D ${store.$id} \u5931\u8D25:`, error);
|
|
132
|
-
}
|
|
133
|
-
store.$subscribe(
|
|
134
|
-
(_, state) => {
|
|
135
|
-
try {
|
|
136
|
-
let toSave = state;
|
|
137
|
-
if (paths && Array.isArray(paths)) {
|
|
138
|
-
toSave = paths.reduce((acc, key) => {
|
|
139
|
-
if (key in state) acc[key] = state[key];
|
|
140
|
-
return acc;
|
|
141
|
-
}, {});
|
|
142
|
-
}
|
|
143
|
-
uni.setStorageSync(storageKey, toSave);
|
|
144
|
-
} catch (error) {
|
|
145
|
-
console.error(`[Storage] \u4FDD\u5B58 ${store.$id} \u5931\u8D25:`, error);
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
{ detached: true }
|
|
149
|
-
);
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
114
|
// src/theme/store.ts
|
|
154
115
|
var fontSizePresets = [
|
|
155
116
|
{
|
|
@@ -318,13 +279,11 @@ function showShareMenu() {
|
|
|
318
279
|
function useShare(config = {}) {
|
|
319
280
|
showShareMenu();
|
|
320
281
|
onShareAppMessage(() => ({ ...config }));
|
|
321
|
-
onShareTimeline(() => {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
};
|
|
327
|
-
});
|
|
282
|
+
onShareTimeline(() => ({
|
|
283
|
+
title: config.title,
|
|
284
|
+
query: config.path?.split("?")[1],
|
|
285
|
+
imageUrl: config.imageUrl
|
|
286
|
+
}));
|
|
328
287
|
return {
|
|
329
288
|
showShareMenu
|
|
330
289
|
};
|
|
@@ -355,7 +314,6 @@ export {
|
|
|
355
314
|
hlw,
|
|
356
315
|
initTheme,
|
|
357
316
|
showShareMenu,
|
|
358
|
-
storage,
|
|
359
317
|
useMsg,
|
|
360
318
|
useRefs,
|
|
361
319
|
useShare,
|