@hlw-uni/mp-vue 2.1.36 → 2.1.37

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.
@@ -25,13 +25,16 @@ export type TapEvent = {
25
25
  currentTarget?: {
26
26
  dataset?: Record<string, any>;
27
27
  };
28
+ target?: {
29
+ dataset?: Record<string, any>;
30
+ };
28
31
  };
29
32
  /**
30
33
  * 剪贴板、下载与相册保存工具集合。
31
34
  */
32
35
  export declare function useUtils(): {
33
- copy: (data: string, showToast?: boolean) => Promise<boolean>;
34
- copyFromEvent: (event: TapEvent) => void;
36
+ copy: (data: string | TapEvent, showToast?: boolean) => Promise<boolean>;
37
+ copyFromEvent: (event: TapEvent) => Promise<boolean>;
35
38
  paste: () => Promise<string>;
36
39
  saveImage: (filePath: string) => Promise<boolean>;
37
40
  downloadFile: (options: DownloadFileOptions) => Promise<DownloadFileResult>;
package/dist/index.js CHANGED
@@ -973,6 +973,14 @@ var __publicField = (obj, key, value) => {
973
973
  }
974
974
  function useUtils() {
975
975
  function copy(data, showToast = true) {
976
+ var _a, _b;
977
+ if (typeof data !== "string") {
978
+ const dataset = ((_a = data == null ? void 0 : data.currentTarget) == null ? void 0 : _a.dataset) || ((_b = data == null ? void 0 : data.target) == null ? void 0 : _b.dataset);
979
+ const text = dataset == null ? void 0 : dataset.copy;
980
+ if (text == null || text === "")
981
+ return Promise.resolve(false);
982
+ return copy(String(text), (dataset == null ? void 0 : dataset.copyToast) !== "false");
983
+ }
976
984
  return new Promise((resolve) => {
977
985
  uni.setClipboardData({
978
986
  data,
@@ -988,13 +996,7 @@ var __publicField = (obj, key, value) => {
988
996
  });
989
997
  }
990
998
  function copyFromEvent(event) {
991
- var _a;
992
- const dataset = (_a = event == null ? void 0 : event.currentTarget) == null ? void 0 : _a.dataset;
993
- const text = dataset == null ? void 0 : dataset.copy;
994
- if (text == null || text === "")
995
- return;
996
- const showToast = (dataset == null ? void 0 : dataset.copyToast) !== "false";
997
- copy(String(text), showToast);
999
+ return copy(event);
998
1000
  }
999
1001
  function paste() {
1000
1002
  return new Promise((resolve) => {
package/dist/index.mjs CHANGED
@@ -972,6 +972,14 @@ function useContact() {
972
972
  }
973
973
  function useUtils() {
974
974
  function copy(data, showToast = true) {
975
+ var _a, _b;
976
+ if (typeof data !== "string") {
977
+ const dataset = ((_a = data == null ? void 0 : data.currentTarget) == null ? void 0 : _a.dataset) || ((_b = data == null ? void 0 : data.target) == null ? void 0 : _b.dataset);
978
+ const text = dataset == null ? void 0 : dataset.copy;
979
+ if (text == null || text === "")
980
+ return Promise.resolve(false);
981
+ return copy(String(text), (dataset == null ? void 0 : dataset.copyToast) !== "false");
982
+ }
975
983
  return new Promise((resolve) => {
976
984
  uni.setClipboardData({
977
985
  data,
@@ -987,13 +995,7 @@ function useUtils() {
987
995
  });
988
996
  }
989
997
  function copyFromEvent(event) {
990
- var _a;
991
- const dataset = (_a = event == null ? void 0 : event.currentTarget) == null ? void 0 : _a.dataset;
992
- const text = dataset == null ? void 0 : dataset.copy;
993
- if (text == null || text === "")
994
- return;
995
- const showToast = (dataset == null ? void 0 : dataset.copyToast) !== "false";
996
- copy(String(text), showToast);
998
+ return copy(event);
997
999
  }
998
1000
  function paste() {
999
1001
  return new Promise((resolve) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hlw-uni/mp-vue",
3
- "version": "2.1.36",
3
+ "version": "2.1.37",
4
4
  "description": "hlw-uni 小程序运行时 — Vue 组件 + composables + theme + http + 工具集(合并自原 mp-core)",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -210,7 +210,7 @@ defineOptions({
210
210
  }
211
211
 
212
212
  .hlw-card-header__title {
213
- font-size: var(--font-base);
213
+ font-size: calc(var(--font-base) * 0.9);
214
214
  font-weight: 500;
215
215
  color: var(--text-primary, #1e293b);
216
216
  letter-spacing: 1rpx;
@@ -24,7 +24,10 @@ export interface DownloadFileResult {
24
24
  errMsg?: string;
25
25
  }
26
26
 
27
- export type TapEvent = { currentTarget?: { dataset?: Record<string, any> } };
27
+ export type TapEvent = {
28
+ currentTarget?: { dataset?: Record<string, any> };
29
+ target?: { dataset?: Record<string, any> };
30
+ };
28
31
 
29
32
  /**
30
33
  * 剪贴板、下载与相册保存工具集合。
@@ -32,8 +35,16 @@ export type TapEvent = { currentTarget?: { dataset?: Record<string, any> } };
32
35
  export function useUtils() {
33
36
  /**
34
37
  * 复制文本到剪贴板,可选显示成功提示。
38
+ * 也可直接作为 tap 事件处理函数,从 data-copy 读取文本。
35
39
  */
36
- function copy(data: string, showToast = true): Promise<boolean> {
40
+ function copy(data: string | TapEvent, showToast = true): Promise<boolean> {
41
+ if (typeof data !== "string") {
42
+ const dataset = data?.currentTarget?.dataset || data?.target?.dataset;
43
+ const text = dataset?.copy;
44
+ if (text == null || text === "") return Promise.resolve(false);
45
+ return copy(String(text), dataset?.copyToast !== "false");
46
+ }
47
+
37
48
  return new Promise((resolve) => {
38
49
  uni.setClipboardData({
39
50
  data,
@@ -53,11 +64,7 @@ export function useUtils() {
53
64
  * 从事件 dataset 的 data-copy 字段读取文本并复制。
54
65
  */
55
66
  function copyFromEvent(event: TapEvent) {
56
- const dataset = event?.currentTarget?.dataset;
57
- const text = dataset?.copy;
58
- if (text == null || text === "") return;
59
- const showToast = dataset?.copyToast !== "false";
60
- copy(String(text), showToast);
67
+ return copy(event);
61
68
  }
62
69
 
63
70
  /**