@hlw-uni-mp/use 1.1.2 → 1.1.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/index.d.mts CHANGED
@@ -1,64 +1,6 @@
1
1
  import * as pinia from 'pinia';
2
2
  import { App, Ref, ComputedRef } from 'vue';
3
3
 
4
- /**
5
- * 具有消息提示属性的响应体对象
6
- */
7
- interface ToastRes {
8
- /** 提示文案 */
9
- msg?: string;
10
- /** 是否为模态弹窗 */
11
- modal?: boolean;
12
- /** 模态弹窗配置 */
13
- modalOptions?: UniApp.ShowModalOptions;
14
- }
15
- /**
16
- * 提示回调函数类型 (confirm 为 true 表示确定,false 为取消)
17
- */
18
- type ToastCallback = (confirm: boolean) => void;
19
- /**
20
- * 消息门面体
21
- */
22
- interface HlwMsg {
23
- /** 显示轻提示或模态确认框 (支持回调与 Promise) */
24
- toast(opts: UniApp.ShowToastOptions | ToastRes | string, callback?: ToastCallback): Promise<boolean>;
25
- /** 成功提示框 */
26
- success(msg: string): void;
27
- /** 失败提示框 */
28
- error(msg: string): void;
29
- /** 显全局加载 */
30
- showLoading(msg?: string): void;
31
- /** 隐全局加载 */
32
- hideLoading(): void;
33
- /** 弹出确认框 */
34
- modal(opts?: UniApp.ShowModalOptions): Promise<boolean>;
35
- /** 标题进度条 */
36
- setLoadingBar(progress: number): void;
37
- }
38
- /**
39
- * 统一的消息提示与弹窗能力 hook。
40
- *
41
- * @example
42
- * ```ts
43
- * const msg = useMsg();
44
- * msg.toast('操作成功');
45
- * msg.toast(res, (confirm) => {
46
- * if (confirm) console.log('点击确定');
47
- * else console.log('点击取消');
48
- * });
49
- * const ok = await msg.modal({ content: '确定删除吗?' });
50
- * ```
51
- */
52
- declare function useMsg(): HlwMsg;
53
- /**
54
- * 全局提示单例门面
55
- */
56
- declare const hlw: {
57
- /** 统一提示门面 */
58
- readonly $msg: HlwMsg;
59
- };
60
- type HlwInstance = typeof hlw;
61
-
62
4
  declare module "pinia" {
63
5
  interface DefineStoreOptionsBase<S, Store> {
64
6
  /** 本地持久化配置 */
@@ -203,13 +145,6 @@ interface ShareConfig {
203
145
  /** 分享卡片封面图 */
204
146
  imageUrl?: string;
205
147
  }
206
- /**
207
- * 分享操作句柄
208
- */
209
- interface ShareHandlers {
210
- /** 显式调起分享菜单 */
211
- showShareMenu: () => void;
212
- }
213
148
  /**
214
149
  * 显式调起分享菜单
215
150
  */
@@ -217,7 +152,7 @@ declare function showShareMenu(): void;
217
152
  /**
218
153
  * 分享组合式函数
219
154
  */
220
- declare function useShare(config?: ShareConfig): ShareHandlers;
155
+ declare function useShare(config?: ShareConfig): void;
221
156
 
222
157
  /**
223
158
  * useRefs - 模板 Ref 批量管理
@@ -251,4 +186,4 @@ interface UseRefsReturn<T = unknown> {
251
186
  */
252
187
  declare function useRefs<T = unknown>(): UseRefsReturn<T>;
253
188
 
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 };
189
+ export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type InitThemeOptions, type ShareConfig, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, initTheme, showShareMenu, useRefs, useShare, useTheme, useThemeStore };
package/dist/index.d.ts CHANGED
@@ -1,64 +1,6 @@
1
1
  import * as pinia from 'pinia';
2
2
  import { App, Ref, ComputedRef } from 'vue';
3
3
 
4
- /**
5
- * 具有消息提示属性的响应体对象
6
- */
7
- interface ToastRes {
8
- /** 提示文案 */
9
- msg?: string;
10
- /** 是否为模态弹窗 */
11
- modal?: boolean;
12
- /** 模态弹窗配置 */
13
- modalOptions?: UniApp.ShowModalOptions;
14
- }
15
- /**
16
- * 提示回调函数类型 (confirm 为 true 表示确定,false 为取消)
17
- */
18
- type ToastCallback = (confirm: boolean) => void;
19
- /**
20
- * 消息门面体
21
- */
22
- interface HlwMsg {
23
- /** 显示轻提示或模态确认框 (支持回调与 Promise) */
24
- toast(opts: UniApp.ShowToastOptions | ToastRes | string, callback?: ToastCallback): Promise<boolean>;
25
- /** 成功提示框 */
26
- success(msg: string): void;
27
- /** 失败提示框 */
28
- error(msg: string): void;
29
- /** 显全局加载 */
30
- showLoading(msg?: string): void;
31
- /** 隐全局加载 */
32
- hideLoading(): void;
33
- /** 弹出确认框 */
34
- modal(opts?: UniApp.ShowModalOptions): Promise<boolean>;
35
- /** 标题进度条 */
36
- setLoadingBar(progress: number): void;
37
- }
38
- /**
39
- * 统一的消息提示与弹窗能力 hook。
40
- *
41
- * @example
42
- * ```ts
43
- * const msg = useMsg();
44
- * msg.toast('操作成功');
45
- * msg.toast(res, (confirm) => {
46
- * if (confirm) console.log('点击确定');
47
- * else console.log('点击取消');
48
- * });
49
- * const ok = await msg.modal({ content: '确定删除吗?' });
50
- * ```
51
- */
52
- declare function useMsg(): HlwMsg;
53
- /**
54
- * 全局提示单例门面
55
- */
56
- declare const hlw: {
57
- /** 统一提示门面 */
58
- readonly $msg: HlwMsg;
59
- };
60
- type HlwInstance = typeof hlw;
61
-
62
4
  declare module "pinia" {
63
5
  interface DefineStoreOptionsBase<S, Store> {
64
6
  /** 本地持久化配置 */
@@ -203,13 +145,6 @@ interface ShareConfig {
203
145
  /** 分享卡片封面图 */
204
146
  imageUrl?: string;
205
147
  }
206
- /**
207
- * 分享操作句柄
208
- */
209
- interface ShareHandlers {
210
- /** 显式调起分享菜单 */
211
- showShareMenu: () => void;
212
- }
213
148
  /**
214
149
  * 显式调起分享菜单
215
150
  */
@@ -217,7 +152,7 @@ declare function showShareMenu(): void;
217
152
  /**
218
153
  * 分享组合式函数
219
154
  */
220
- declare function useShare(config?: ShareConfig): ShareHandlers;
155
+ declare function useShare(config?: ShareConfig): void;
221
156
 
222
157
  /**
223
158
  * useRefs - 模板 Ref 批量管理
@@ -251,4 +186,4 @@ interface UseRefsReturn<T = unknown> {
251
186
  */
252
187
  declare function useRefs<T = unknown>(): UseRefsReturn<T>;
253
188
 
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 };
189
+ export { DEFAULT_THEME, type FontFamily, type FontFamilyPreset, type FontSize, type FontSizePreset, type InitThemeOptions, type ShareConfig, THEME_COLORS, type ThemeColor, type ThemeMode, type ThemeState, type UseRefsReturn, applyTheme, fontFamilyPresets, fontSizePresets, getTheme, initTheme, showShareMenu, useRefs, useShare, useTheme, useThemeStore };
package/dist/index.js CHANGED
@@ -26,10 +26,8 @@ __export(index_exports, {
26
26
  fontFamilyPresets: () => fontFamilyPresets,
27
27
  fontSizePresets: () => fontSizePresets,
28
28
  getTheme: () => getTheme,
29
- hlw: () => hlw,
30
29
  initTheme: () => initTheme,
31
30
  showShareMenu: () => showShareMenu,
32
- useMsg: () => useMsg,
33
31
  useRefs: () => useRefs,
34
32
  useShare: () => useShare,
35
33
  useTheme: () => useTheme,
@@ -37,110 +35,6 @@ __export(index_exports, {
37
35
  });
38
36
  module.exports = __toCommonJS(index_exports);
39
37
 
40
- // src/msg/index.ts
41
- function useMsg() {
42
- function toast(opts, callback) {
43
- let msg = "";
44
- let isModal = false;
45
- let modalOptions;
46
- let toastOptions;
47
- if (typeof opts === "string") {
48
- msg = opts;
49
- } else if ("msg" in opts) {
50
- msg = opts.msg || "";
51
- isModal = !!opts.modal;
52
- modalOptions = opts.modalOptions;
53
- } else if ("title" in opts) {
54
- msg = opts.title || "";
55
- toastOptions = opts;
56
- }
57
- if (!msg) {
58
- callback?.(true);
59
- return Promise.resolve(true);
60
- }
61
- if (isModal) {
62
- return modal({
63
- ...modalOptions,
64
- content: msg
65
- }).then((confirm) => {
66
- callback?.(confirm);
67
- return confirm;
68
- });
69
- }
70
- uni.showToast({
71
- title: msg,
72
- icon: toastOptions?.icon || "none",
73
- image: toastOptions?.image,
74
- duration: toastOptions?.duration || 2e3,
75
- mask: toastOptions?.mask || false,
76
- position: toastOptions?.position || "center"
77
- });
78
- callback?.(true);
79
- return Promise.resolve(true);
80
- }
81
- function success(msg) {
82
- if (!msg) return;
83
- uni.showToast({ title: msg, icon: "success", duration: 2e3 });
84
- }
85
- function error(msg) {
86
- if (!msg) return;
87
- uni.showToast({ title: msg, icon: "error", duration: 2e3 });
88
- }
89
- function showLoading(msg = "\u52A0\u8F7D\u4E2D...") {
90
- uni.showLoading({ title: msg, mask: true });
91
- }
92
- function hideLoading() {
93
- uni.hideLoading();
94
- }
95
- function modal(opts = {}) {
96
- return new Promise((resolve) => {
97
- const {
98
- title = "\u63D0\u793A",
99
- content,
100
- confirmText = "\u786E\u5B9A",
101
- cancelText = "\u53D6\u6D88",
102
- confirmColor = "#3b82f6",
103
- cancelColor = "#999999",
104
- showCancel = true
105
- } = opts || {};
106
- uni.showModal({
107
- title,
108
- content,
109
- confirmText,
110
- cancelText,
111
- confirmColor,
112
- cancelColor,
113
- showCancel,
114
- success: (res) => resolve(res.confirm),
115
- fail: () => resolve(false)
116
- });
117
- });
118
- }
119
- function setLoadingBar(progress) {
120
- const clamped = Math.max(0, Math.min(100, progress));
121
- const filled = Math.round(clamped / 2);
122
- uni.setNavigationBarTitle({
123
- title: `${"\u25A0".repeat(filled)}${"\u25A1".repeat(50 - filled)} ${clamped}%`
124
- });
125
- }
126
- return {
127
- toast,
128
- success,
129
- error,
130
- showLoading,
131
- hideLoading,
132
- modal,
133
- setLoadingBar
134
- };
135
- }
136
- var _msg = null;
137
- var hlw = {
138
- /** 统一提示门面 */
139
- get $msg() {
140
- return _msg ?? (_msg = useMsg());
141
- }
142
- };
143
-
144
38
  // src/theme/index.ts
145
39
  var import_vue = require("vue");
146
40
 
@@ -323,9 +217,6 @@ function useShare(config = {}) {
323
217
  query: config.path?.split("?")[1],
324
218
  imageUrl: config.imageUrl
325
219
  }));
326
- return {
327
- showShareMenu
328
- };
329
220
  }
330
221
 
331
222
  // src/refs/index.ts
@@ -351,10 +242,8 @@ function useRefs() {
351
242
  fontFamilyPresets,
352
243
  fontSizePresets,
353
244
  getTheme,
354
- hlw,
355
245
  initTheme,
356
246
  showShareMenu,
357
- useMsg,
358
247
  useRefs,
359
248
  useShare,
360
249
  useTheme,
package/dist/index.mjs CHANGED
@@ -1,107 +1,3 @@
1
- // src/msg/index.ts
2
- function useMsg() {
3
- function toast(opts, callback) {
4
- let msg = "";
5
- let isModal = false;
6
- let modalOptions;
7
- let toastOptions;
8
- if (typeof opts === "string") {
9
- msg = opts;
10
- } else if ("msg" in opts) {
11
- msg = opts.msg || "";
12
- isModal = !!opts.modal;
13
- modalOptions = opts.modalOptions;
14
- } else if ("title" in opts) {
15
- msg = opts.title || "";
16
- toastOptions = opts;
17
- }
18
- if (!msg) {
19
- callback?.(true);
20
- return Promise.resolve(true);
21
- }
22
- if (isModal) {
23
- return modal({
24
- ...modalOptions,
25
- content: msg
26
- }).then((confirm) => {
27
- callback?.(confirm);
28
- return confirm;
29
- });
30
- }
31
- uni.showToast({
32
- title: msg,
33
- icon: toastOptions?.icon || "none",
34
- image: toastOptions?.image,
35
- duration: toastOptions?.duration || 2e3,
36
- mask: toastOptions?.mask || false,
37
- position: toastOptions?.position || "center"
38
- });
39
- callback?.(true);
40
- return Promise.resolve(true);
41
- }
42
- function success(msg) {
43
- if (!msg) return;
44
- uni.showToast({ title: msg, icon: "success", duration: 2e3 });
45
- }
46
- function error(msg) {
47
- if (!msg) return;
48
- uni.showToast({ title: msg, icon: "error", duration: 2e3 });
49
- }
50
- function showLoading(msg = "\u52A0\u8F7D\u4E2D...") {
51
- uni.showLoading({ title: msg, mask: true });
52
- }
53
- function hideLoading() {
54
- uni.hideLoading();
55
- }
56
- function modal(opts = {}) {
57
- return new Promise((resolve) => {
58
- const {
59
- title = "\u63D0\u793A",
60
- content,
61
- confirmText = "\u786E\u5B9A",
62
- cancelText = "\u53D6\u6D88",
63
- confirmColor = "#3b82f6",
64
- cancelColor = "#999999",
65
- showCancel = true
66
- } = opts || {};
67
- uni.showModal({
68
- title,
69
- content,
70
- confirmText,
71
- cancelText,
72
- confirmColor,
73
- cancelColor,
74
- showCancel,
75
- success: (res) => resolve(res.confirm),
76
- fail: () => resolve(false)
77
- });
78
- });
79
- }
80
- function setLoadingBar(progress) {
81
- const clamped = Math.max(0, Math.min(100, progress));
82
- const filled = Math.round(clamped / 2);
83
- uni.setNavigationBarTitle({
84
- title: `${"\u25A0".repeat(filled)}${"\u25A1".repeat(50 - filled)} ${clamped}%`
85
- });
86
- }
87
- return {
88
- toast,
89
- success,
90
- error,
91
- showLoading,
92
- hideLoading,
93
- modal,
94
- setLoadingBar
95
- };
96
- }
97
- var _msg = null;
98
- var hlw = {
99
- /** 统一提示门面 */
100
- get $msg() {
101
- return _msg ?? (_msg = useMsg());
102
- }
103
- };
104
-
105
1
  // src/theme/index.ts
106
2
  import { computed, toRef } from "vue";
107
3
 
@@ -284,9 +180,6 @@ function useShare(config = {}) {
284
180
  query: config.path?.split("?")[1],
285
181
  imageUrl: config.imageUrl
286
182
  }));
287
- return {
288
- showShareMenu
289
- };
290
183
  }
291
184
 
292
185
  // src/refs/index.ts
@@ -311,10 +204,8 @@ export {
311
204
  fontFamilyPresets,
312
205
  fontSizePresets,
313
206
  getTheme,
314
- hlw,
315
207
  initTheme,
316
208
  showShareMenu,
317
- useMsg,
318
209
  useRefs,
319
210
  useShare,
320
211
  useTheme,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni-mp/use",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Universal Uni-App Vue 3 stateful composables library",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",