@gindow/vue 1.0.1 → 1.0.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/README.md +6 -6
- package/dist/resolver.cjs +1 -0
- package/dist/resolver.d.ts +15 -0
- package/dist/resolver.mjs +16 -0
- package/dist/style.css +1 -2
- package/dist/vue.cjs +1 -0
- package/dist/vue.d.ts +74 -258
- package/dist/vue.mjs +286 -0
- package/package.json +11 -52
- package/src/components/VueIcon.vue +43 -2
- package/src/index.ts +17 -9
- package/src/libs/auto-imports.d.ts +79 -0
- package/src/locale/index.ts +1 -1
- package/src/resolver.ts +19 -0
- package/src/style.css +9 -16
- package/src/utils/index.ts +0 -7
- package/dist/index.cjs +0 -2
- package/dist/index.mjs +0 -451
- package/src/hooks/useChat.ts +0 -135
- package/src/hooks/useNanoid.ts +0 -9
- package/src/hooks/useUpload.ts +0 -59
- package/src/types/chat.ts +0 -62
- package/src/utils/datetime.ts +0 -42
- package/src/utils/download.ts +0 -11
- package/src/utils/get.ts +0 -10
- package/src/utils/platform.ts +0 -38
- package/src/utils/request.ts +0 -146
package/dist/vue.mjs
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { computed as e, createBlock as t, defineComponent as n, h as r, inject as i, normalizeStyle as a, onBeforeUnmount as o, onMounted as s, openBlock as c, provide as l, reactive as u, ref as d, unref as f, useCssVars as p } from "vue";
|
|
2
|
+
import { Icon as m } from "@iconify/vue";
|
|
3
|
+
//#region src/locale/zh-CN.ts
|
|
4
|
+
var h = {
|
|
5
|
+
cancel: "取消",
|
|
6
|
+
confirm: "确认",
|
|
7
|
+
empty: { noData: "暂无数据" },
|
|
8
|
+
dialog: {
|
|
9
|
+
tip: "操作提示",
|
|
10
|
+
confirm: "操作确认"
|
|
11
|
+
}
|
|
12
|
+
}, g = {
|
|
13
|
+
cancel: "Cancel",
|
|
14
|
+
confirm: "Confirm",
|
|
15
|
+
empty: { noData: "No data" },
|
|
16
|
+
dialog: {
|
|
17
|
+
tip: "Tip",
|
|
18
|
+
confirm: "Confirm"
|
|
19
|
+
}
|
|
20
|
+
}, _ = () => {
|
|
21
|
+
let e = ["en", "zh-CN"], t = localStorage.getItem("locale"), n = navigator.language;
|
|
22
|
+
return t && e.includes(t) ? t : n && e.includes(n) ? n : n && e.includes(n.split("-")[0]) ? n.split("-")[0] : e[0] ?? "zh-CN";
|
|
23
|
+
}, v = Symbol("vue-locale"), y = d(_()), b = u({
|
|
24
|
+
en: g,
|
|
25
|
+
"zh-CN": h
|
|
26
|
+
}), x = (e) => {
|
|
27
|
+
if (e?.locale && (y.value = e.locale), e?.messages) for (let [t, n] of Object.entries(e.messages)) b[t] = n;
|
|
28
|
+
return l(v, {
|
|
29
|
+
locale: y,
|
|
30
|
+
messages: b
|
|
31
|
+
}), {
|
|
32
|
+
locale: y,
|
|
33
|
+
messages: b
|
|
34
|
+
};
|
|
35
|
+
}, S = () => {
|
|
36
|
+
let e = i(v, void 0), t = e?.locale ?? y, n = e?.messages ?? b;
|
|
37
|
+
return {
|
|
38
|
+
locale: t,
|
|
39
|
+
t: (e, r) => {
|
|
40
|
+
let i = n[t.value], a = e.replace(/\[(\d+)]/g, ".$1").split("."), o = i;
|
|
41
|
+
for (let t of a) if (o = o?.[t], o === void 0) return e;
|
|
42
|
+
let s = o ?? e;
|
|
43
|
+
return r && typeof s == "string" && (s = s.replace(/\{(\w+)\}/g, (e, t) => r[t] === void 0 ? `{${t}}` : String(r[t]))), s;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, C = (e) => y.value = e, w = () => y.value, T = /* @__PURE__ */ ((e, t) => {
|
|
47
|
+
let n = e.__vccOpts || e;
|
|
48
|
+
for (let [e, r] of t) n[e] = r;
|
|
49
|
+
return n;
|
|
50
|
+
})(/* @__PURE__ */ n({
|
|
51
|
+
__name: "VueIcon",
|
|
52
|
+
props: {
|
|
53
|
+
vendor: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: "icon-park-outline"
|
|
56
|
+
},
|
|
57
|
+
icon: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: ""
|
|
60
|
+
},
|
|
61
|
+
type: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: ""
|
|
64
|
+
},
|
|
65
|
+
size: {
|
|
66
|
+
type: Number,
|
|
67
|
+
default: 16
|
|
68
|
+
},
|
|
69
|
+
strokeWidth: {
|
|
70
|
+
type: Number,
|
|
71
|
+
default: 3
|
|
72
|
+
},
|
|
73
|
+
color: { type: String }
|
|
74
|
+
},
|
|
75
|
+
setup(n) {
|
|
76
|
+
p((e) => ({ v519ff46c: d.value }));
|
|
77
|
+
let r = n, i = {
|
|
78
|
+
folder: "folder-close",
|
|
79
|
+
png: "pic-one",
|
|
80
|
+
jpeg: "pic-one",
|
|
81
|
+
jpg: "pic-one",
|
|
82
|
+
gif: "pic-one",
|
|
83
|
+
webp: "pic-one",
|
|
84
|
+
bmp: "pic-one",
|
|
85
|
+
svg: "pic-one",
|
|
86
|
+
mp4: "video",
|
|
87
|
+
avi: "video",
|
|
88
|
+
mov: "video",
|
|
89
|
+
wmv: "video",
|
|
90
|
+
flv: "video",
|
|
91
|
+
mkv: "video",
|
|
92
|
+
webm: "video",
|
|
93
|
+
mp3: "music-one",
|
|
94
|
+
wav: "music-one",
|
|
95
|
+
wma: "music-one",
|
|
96
|
+
aac: "music-one",
|
|
97
|
+
ogg: "music-one",
|
|
98
|
+
flac: "music-one",
|
|
99
|
+
pdf: "file-pdf",
|
|
100
|
+
doc: "file-word",
|
|
101
|
+
docx: "file-word",
|
|
102
|
+
xls: "file-excel",
|
|
103
|
+
xlsx: "file-excel",
|
|
104
|
+
csv: "file-excel",
|
|
105
|
+
ppt: "file-ppt",
|
|
106
|
+
pptx: "file-ppt",
|
|
107
|
+
txt: "file-txt",
|
|
108
|
+
md: "file-txt-one",
|
|
109
|
+
json: "code",
|
|
110
|
+
xml: "code",
|
|
111
|
+
html: "code",
|
|
112
|
+
css: "code",
|
|
113
|
+
js: "code",
|
|
114
|
+
ts: "code",
|
|
115
|
+
jsx: "code",
|
|
116
|
+
tsx: "code",
|
|
117
|
+
py: "code",
|
|
118
|
+
php: "code",
|
|
119
|
+
cpp: "code",
|
|
120
|
+
c: "code",
|
|
121
|
+
java: "code",
|
|
122
|
+
go: "code",
|
|
123
|
+
rs: "code",
|
|
124
|
+
zip: "zip",
|
|
125
|
+
rar: "zip",
|
|
126
|
+
"7z": "zip",
|
|
127
|
+
tar: "zip",
|
|
128
|
+
gz: "zip",
|
|
129
|
+
bz2: "zip"
|
|
130
|
+
}, o = {
|
|
131
|
+
image: "pic-one",
|
|
132
|
+
video: "video",
|
|
133
|
+
audio: "music-one",
|
|
134
|
+
text: "file-txt",
|
|
135
|
+
application: "file-text",
|
|
136
|
+
font: "file-text",
|
|
137
|
+
pdf: "file-pdf",
|
|
138
|
+
doc: "file-word",
|
|
139
|
+
sheet: "file-excel",
|
|
140
|
+
ppt: "file-ppt",
|
|
141
|
+
md: "file-txt-one",
|
|
142
|
+
canvas: "book-open",
|
|
143
|
+
album: "pic-one",
|
|
144
|
+
yearbook: "book-open"
|
|
145
|
+
}, s = e(() => {
|
|
146
|
+
if (r.icon) return r.icon;
|
|
147
|
+
if (!r.type) return "";
|
|
148
|
+
if (r.type === "folder") return "folder-close";
|
|
149
|
+
let [e, t] = r.type.toLowerCase().split("/");
|
|
150
|
+
return t && i[t] ? i[t] : e && o[e] ? o[e] : e && i[e] ? i[e] : "file-text";
|
|
151
|
+
}), l = e(() => {
|
|
152
|
+
let e = s.value;
|
|
153
|
+
return e ? e.includes(":") ? e : `${r.vendor}:${e}` : "";
|
|
154
|
+
}), u = e(() => r.color ? { color: r.color } : void 0), d = e(() => r.strokeWidth);
|
|
155
|
+
return (e, r) => (c(), t(f(m), {
|
|
156
|
+
icon: l.value,
|
|
157
|
+
width: n.size,
|
|
158
|
+
height: n.size,
|
|
159
|
+
style: a(u.value),
|
|
160
|
+
"aria-hidden": null
|
|
161
|
+
}, null, 8, [
|
|
162
|
+
"icon",
|
|
163
|
+
"width",
|
|
164
|
+
"height",
|
|
165
|
+
"style"
|
|
166
|
+
]));
|
|
167
|
+
}
|
|
168
|
+
}), [["__scopeId", "data-v-e336ca96"]]), E = class {
|
|
169
|
+
static {
|
|
170
|
+
this.config = {};
|
|
171
|
+
}
|
|
172
|
+
static {
|
|
173
|
+
this.set = (e) => this.config = e;
|
|
174
|
+
}
|
|
175
|
+
static {
|
|
176
|
+
this.id = (e = "") => e.slice(-12).toUpperCase();
|
|
177
|
+
}
|
|
178
|
+
static {
|
|
179
|
+
this.date = (e = "") => e.substring(0, 10) + " " + e.substring(11, 19);
|
|
180
|
+
}
|
|
181
|
+
static {
|
|
182
|
+
this.idcard = (e = "") => e ? e.substring(0, 6) + "****" + e.substring(14) : "";
|
|
183
|
+
}
|
|
184
|
+
static {
|
|
185
|
+
this.phone = (e = "", t = !1) => t || !e ? e : e.substring(0, 3) + "****" + e.substring(e.length - 4);
|
|
186
|
+
}
|
|
187
|
+
static {
|
|
188
|
+
this.email = (e = "") => {
|
|
189
|
+
let [t, n] = e.split("@");
|
|
190
|
+
return !t || !n ? e : `${t.length > 2 ? t[0] + "****" + t[t.length - 1] : t}@${n}`;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
static {
|
|
194
|
+
this.bankcard = (e = "") => e.substring(0, 4) + "****" + e.substring(e.length - 4);
|
|
195
|
+
}
|
|
196
|
+
static {
|
|
197
|
+
this.url = (e = "") => e.replace(/:\/\//g, ":##").replace(/\/+/g, "/").replace(/:##/g, "://");
|
|
198
|
+
}
|
|
199
|
+
static {
|
|
200
|
+
this.price = (e = 0, t) => {
|
|
201
|
+
let { locale: n, decimals: r, currency: i } = this.config, a = typeof e == "string" ? parseFloat(e) : e;
|
|
202
|
+
return new Intl.NumberFormat(n, {
|
|
203
|
+
style: "currency",
|
|
204
|
+
currency: t ?? i ?? "CNY",
|
|
205
|
+
minimumFractionDigits: r ?? 2,
|
|
206
|
+
maximumFractionDigits: r ?? 2
|
|
207
|
+
}).format(a / 100);
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
static {
|
|
211
|
+
this.currency = (e = 0, t) => this.price(e, t);
|
|
212
|
+
}
|
|
213
|
+
}, D = class e {
|
|
214
|
+
static {
|
|
215
|
+
this.country = "";
|
|
216
|
+
}
|
|
217
|
+
static {
|
|
218
|
+
this.set = (e) => this.country = e;
|
|
219
|
+
}
|
|
220
|
+
static get phone_pattern() {
|
|
221
|
+
return this.country.toUpperCase() === "CN" ? /([1][3,4,5,6,7,8,9][0-9]{9})$/ : /^(?:\+?[1-9]\d{7,14}|\d{6,11})$/;
|
|
222
|
+
}
|
|
223
|
+
static {
|
|
224
|
+
this.email_pattern = /^([a-zA-Z0-9_\.-]+)@([\da-zA-Z\.-]+)\.([a-zA-Z\.]{2,6})$/;
|
|
225
|
+
}
|
|
226
|
+
static {
|
|
227
|
+
this.idcard_pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
|
|
228
|
+
}
|
|
229
|
+
static {
|
|
230
|
+
this.cname_pattern = /^(?:[\u4e00-\u9fa5·]{2,16})$/;
|
|
231
|
+
}
|
|
232
|
+
static {
|
|
233
|
+
this.password_pattern = /^(?![A-Za-z]+$)(?![0-9]+$)(?![^A-Za-z0-9]+$).{8,20}$/;
|
|
234
|
+
}
|
|
235
|
+
static {
|
|
236
|
+
this.phone = (t) => e.phone_pattern.test(t);
|
|
237
|
+
}
|
|
238
|
+
static {
|
|
239
|
+
this.email = (t) => e.email_pattern.test(t);
|
|
240
|
+
}
|
|
241
|
+
static {
|
|
242
|
+
this.idcard = (t) => e.idcard_pattern.test(t);
|
|
243
|
+
}
|
|
244
|
+
static {
|
|
245
|
+
this.cname = (t) => e.cname_pattern.test(t);
|
|
246
|
+
}
|
|
247
|
+
}, O = 768, k = () => {
|
|
248
|
+
let t = d(typeof window < "u" ? window.matchMedia(`(min-width: ${O}px)`).matches : !0), n, r = (e) => t.value = e.matches;
|
|
249
|
+
s(() => {
|
|
250
|
+
typeof window > "u" || (n = window.matchMedia(`(min-width: ${O}px)`), t.value = n.matches, n.addEventListener("change", r));
|
|
251
|
+
}), o(() => n?.removeEventListener("change", r));
|
|
252
|
+
let i = e(() => t.value);
|
|
253
|
+
return {
|
|
254
|
+
isMobile: e(() => !t.value),
|
|
255
|
+
isDesktop: i
|
|
256
|
+
};
|
|
257
|
+
}, A = (e) => {
|
|
258
|
+
let t = d(0), n = d(!1), r = (t = {}) => new Promise((r, a) => {
|
|
259
|
+
n.value || (n.value = !0, e(t).then(() => {
|
|
260
|
+
i(), r(!0);
|
|
261
|
+
}).catch((e) => a(e)).finally(() => n.value = !1));
|
|
262
|
+
}), i = () => {
|
|
263
|
+
t.value = 60;
|
|
264
|
+
let e = setInterval(() => {
|
|
265
|
+
t.value--, t.value || clearTimeout(e);
|
|
266
|
+
}, 1e3);
|
|
267
|
+
};
|
|
268
|
+
return {
|
|
269
|
+
waiting: t,
|
|
270
|
+
send: r
|
|
271
|
+
};
|
|
272
|
+
}, j = () => ({ i: (e, t = {}) => e ? r(T, {
|
|
273
|
+
icon: e,
|
|
274
|
+
...t
|
|
275
|
+
}) : void 0 }), M = [T];
|
|
276
|
+
M.forEach((e) => {
|
|
277
|
+
e.install = (t) => {
|
|
278
|
+
let n = e.name ?? e.__name;
|
|
279
|
+
n && t.component(n, e);
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
var N = { install(e, t) {
|
|
283
|
+
x(t), M.forEach((t) => e.use(t));
|
|
284
|
+
} };
|
|
285
|
+
//#endregion
|
|
286
|
+
export { E as Formatter, D as Validate, T as VueIcon, N as default, w as getLocale, C as setLocale, k as useBreak, A as useCaptcha, j as useIcon, S as useLocale };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gindow/vue",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Vue3 通用基础包,包含工具函数、Hooks、类型定义、国际化、基础样式",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
"import": "./dist/vue.mjs",
|
|
13
13
|
"require": "./dist/vue.cjs"
|
|
14
14
|
},
|
|
15
|
+
"./resolver": {
|
|
16
|
+
"types": "./dist/resolver.d.ts",
|
|
17
|
+
"import": "./dist/resolver.mjs",
|
|
18
|
+
"require": "./dist/resolver.cjs"
|
|
19
|
+
},
|
|
15
20
|
"./style.css": "./dist/style.css",
|
|
16
21
|
"./src/*": "./src/*",
|
|
17
22
|
"./package.json": "./package.json"
|
|
@@ -28,72 +33,26 @@
|
|
|
28
33
|
"build": "vue-tsc --noEmit && vite build"
|
|
29
34
|
},
|
|
30
35
|
"peerDependencies": {
|
|
31
|
-
"@icon-park/vue-next": "^1.4.0",
|
|
32
36
|
"@iconify/vue": "^5.0.0",
|
|
33
|
-
"@vueuse/core": "^12.0.0",
|
|
34
|
-
"axios": "^1.6.0",
|
|
35
|
-
"compressorjs": "^1.2.0",
|
|
36
|
-
"dayjs": "^1.11.0",
|
|
37
|
-
"file-type-checker": "^1.0.0",
|
|
38
|
-
"heic2any": "^0.0.4",
|
|
39
|
-
"js-cookie": "^3.0.0",
|
|
40
|
-
"nanoid": "^5.0.0",
|
|
41
37
|
"vue": "^3.5.0"
|
|
42
38
|
},
|
|
43
39
|
"peerDependenciesMeta": {
|
|
44
|
-
"@icon-park/vue-next": {
|
|
45
|
-
"optional": true
|
|
46
|
-
},
|
|
47
40
|
"@iconify/vue": {
|
|
48
41
|
"optional": true
|
|
49
|
-
},
|
|
50
|
-
"@vueuse/core": {
|
|
51
|
-
"optional": true
|
|
52
|
-
},
|
|
53
|
-
"axios": {
|
|
54
|
-
"optional": true
|
|
55
|
-
},
|
|
56
|
-
"compressorjs": {
|
|
57
|
-
"optional": true
|
|
58
|
-
},
|
|
59
|
-
"dayjs": {
|
|
60
|
-
"optional": true
|
|
61
|
-
},
|
|
62
|
-
"file-type-checker": {
|
|
63
|
-
"optional": true
|
|
64
|
-
},
|
|
65
|
-
"heic2any": {
|
|
66
|
-
"optional": true
|
|
67
|
-
},
|
|
68
|
-
"js-cookie": {
|
|
69
|
-
"optional": true
|
|
70
|
-
},
|
|
71
|
-
"nanoid": {
|
|
72
|
-
"optional": true
|
|
73
42
|
}
|
|
74
43
|
},
|
|
75
44
|
"devDependencies": {
|
|
76
|
-
"@icon-park/vue-next": "^1.4.2",
|
|
77
45
|
"@iconify/vue": "^5.0.1",
|
|
78
46
|
"@tailwindcss/vite": "^4.3.0",
|
|
79
|
-
"@types/
|
|
80
|
-
"@
|
|
81
|
-
"@types/node": "^22.19.18",
|
|
82
|
-
"@vitejs/plugin-vue": "^6.0.6",
|
|
47
|
+
"@types/node": "^22.19.20",
|
|
48
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
83
49
|
"@vue/tsconfig": "^0.5.1",
|
|
84
|
-
"@vueuse/core": "^14.3.0",
|
|
85
|
-
"axios": "^1.16.1",
|
|
86
|
-
"compressorjs": "^1.3.0",
|
|
87
|
-
"dayjs": "^1.11.20",
|
|
88
|
-
"file-type-checker": "^1.1.6",
|
|
89
|
-
"heic2any": "^0.0.4",
|
|
90
|
-
"js-cookie": "^3.0.7",
|
|
91
|
-
"nanoid": "^5.1.11",
|
|
92
50
|
"tailwindcss": "^4.3.0",
|
|
93
51
|
"typescript": "^5.9.3",
|
|
94
|
-
"
|
|
52
|
+
"unplugin-auto-import": "^21.0.0",
|
|
53
|
+
"vite": "^8.0.16",
|
|
95
54
|
"vite-plugin-dts": "^4.5.4",
|
|
96
|
-
"vue": "^3.5.
|
|
55
|
+
"vue": "^3.5.35",
|
|
97
56
|
"vue-tsc": "^2.2.12"
|
|
98
57
|
}
|
|
99
58
|
}
|
|
@@ -9,12 +9,53 @@ import { Icon } from '@iconify/vue'
|
|
|
9
9
|
const props = defineProps({
|
|
10
10
|
vendor: { type: String, default: 'icon-park-outline' },
|
|
11
11
|
icon: { type: String, default: '' },
|
|
12
|
+
type: { type: String, default: '' },
|
|
12
13
|
size: { type: Number, default: 16 },
|
|
13
|
-
strokeWidth: { type: Number, default:
|
|
14
|
+
strokeWidth: { type: Number, default: 3 },
|
|
14
15
|
color: { type: String },
|
|
15
16
|
})
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
// 扩展名称
|
|
19
|
+
const icons: Record<string, string> = {
|
|
20
|
+
folder: 'folder-close',
|
|
21
|
+
png: 'pic-one', jpeg: 'pic-one', jpg: 'pic-one', gif: 'pic-one', webp: 'pic-one', bmp: 'pic-one', svg: 'pic-one',
|
|
22
|
+
mp4: 'video', avi: 'video', mov: 'video', wmv: 'video', flv: 'video', mkv: 'video', webm: 'video',
|
|
23
|
+
mp3: 'music-one', wav: 'music-one', wma: 'music-one', aac: 'music-one', ogg: 'music-one', flac: 'music-one',
|
|
24
|
+
pdf: 'file-pdf',
|
|
25
|
+
doc: 'file-word', docx: 'file-word',
|
|
26
|
+
xls: 'file-excel', xlsx: 'file-excel', csv: 'file-excel',
|
|
27
|
+
ppt: 'file-ppt', pptx: 'file-ppt',
|
|
28
|
+
txt: 'file-txt', md: 'file-txt-one',
|
|
29
|
+
json: 'code', xml: 'code', html: 'code', css: 'code', js: 'code', ts: 'code', jsx: 'code', tsx: 'code',
|
|
30
|
+
py: 'code', php: 'code', cpp: 'code', c: 'code', java: 'code', go: 'code', rs: 'code',
|
|
31
|
+
zip: 'zip', rar: 'zip', '7z': 'zip', tar: 'zip', gz: 'zip', bz2: 'zip',
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 业务类型
|
|
35
|
+
const typeIcon: Record<string, string> = {
|
|
36
|
+
image: 'pic-one', video: 'video', audio: 'music-one', text: 'file-txt', application: 'file-text', font: 'file-text',
|
|
37
|
+
pdf: 'file-pdf', doc: 'file-word', sheet: 'file-excel', ppt: 'file-ppt', md: 'file-txt-one', canvas: 'book-open',
|
|
38
|
+
album: 'pic-one', yearbook: 'book-open',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const resolved = computed(() => {
|
|
42
|
+
if (props.icon) return props.icon // 显式图标名优先
|
|
43
|
+
if (!props.type) return ''
|
|
44
|
+
if (props.type === 'folder') return 'folder-close'
|
|
45
|
+
|
|
46
|
+
const t = props.type.toLowerCase()
|
|
47
|
+
const [mimeType, mimeSub] = t.split('/')
|
|
48
|
+
if (mimeSub && icons[mimeSub]) return icons[mimeSub]
|
|
49
|
+
else if (mimeType && typeIcon[mimeType]) return typeIcon[mimeType]
|
|
50
|
+
else if (mimeType && icons[mimeType]) return icons[mimeType]
|
|
51
|
+
else return 'file-text'
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const name = computed(() => {
|
|
55
|
+
const r = resolved.value
|
|
56
|
+
return r ? (r.includes(':') ? r : `${props.vendor}:${r}`) : ''
|
|
57
|
+
})
|
|
58
|
+
|
|
18
59
|
const iconStyle = computed(() => props.color ? { color: props.color } : undefined)
|
|
19
60
|
const strokeWidth = computed(() => props.strokeWidth)
|
|
20
61
|
</script>
|
package/src/index.ts
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
import type { App, Plugin } from 'vue'
|
|
2
2
|
import { provider, setLocale, getLocale, useLocale } from './locale'
|
|
3
|
+
import VueIcon from './components/VueIcon.vue'
|
|
3
4
|
import './style.css'
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
const components = [
|
|
7
|
+
VueIcon,
|
|
8
|
+
]
|
|
9
|
+
|
|
10
|
+
components.forEach((c) => {
|
|
11
|
+
;(c as unknown as Plugin).install = (app: App) => {
|
|
12
|
+
const name =
|
|
13
|
+
(c as { name?: string }).name ?? (c as { __name?: string }).__name
|
|
14
|
+
if (name) app.component(name, c)
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const Vue: Plugin = {
|
|
6
19
|
install(app, options?: { locale?: string; messages?: Record<string, any> }) {
|
|
7
20
|
provider(options)
|
|
8
|
-
app.
|
|
9
|
-
app.config.globalProperties.$getLocale = getLocale
|
|
21
|
+
components.forEach((c) => app.use(c as unknown as Plugin))
|
|
10
22
|
},
|
|
11
23
|
}
|
|
12
24
|
|
|
13
25
|
export * from './types'
|
|
14
|
-
export * from './types/chat'
|
|
15
26
|
export * from './utils'
|
|
16
27
|
export { useBreak } from './hooks/useBreak'
|
|
17
28
|
export { useCaptcha } from './hooks/useCaptcha'
|
|
18
|
-
export { useChat } from './hooks/useChat'
|
|
19
29
|
export { useIcon } from './hooks/useIcon'
|
|
20
|
-
export { useNanoid } from './hooks/useNanoid'
|
|
21
|
-
export { useUpload } from './hooks/useUpload'
|
|
22
|
-
export type { IChatMessage, IMessageEvent, IUsageEvent, IErrorEvent, ISendMessageParams } from './hooks/useChat'
|
|
23
30
|
|
|
24
|
-
export default
|
|
31
|
+
export default Vue
|
|
25
32
|
|
|
26
33
|
export {
|
|
34
|
+
VueIcon,
|
|
27
35
|
setLocale,
|
|
28
36
|
getLocale,
|
|
29
37
|
useLocale,
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* prettier-ignore */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
// noinspection JSUnusedGlobalSymbols
|
|
5
|
+
// Generated by unplugin-auto-import
|
|
6
|
+
// biome-ignore lint: disable
|
|
7
|
+
export {}
|
|
8
|
+
declare global {
|
|
9
|
+
const EffectScope: typeof import('vue').EffectScope
|
|
10
|
+
const computed: typeof import('vue').computed
|
|
11
|
+
const createApp: typeof import('vue').createApp
|
|
12
|
+
const customRef: typeof import('vue').customRef
|
|
13
|
+
const defineAsyncComponent: typeof import('vue').defineAsyncComponent
|
|
14
|
+
const defineComponent: typeof import('vue').defineComponent
|
|
15
|
+
const effectScope: typeof import('vue').effectScope
|
|
16
|
+
const getCurrentInstance: typeof import('vue').getCurrentInstance
|
|
17
|
+
const getCurrentScope: typeof import('vue').getCurrentScope
|
|
18
|
+
const getCurrentWatcher: typeof import('vue').getCurrentWatcher
|
|
19
|
+
const h: typeof import('vue').h
|
|
20
|
+
const inject: typeof import('vue').inject
|
|
21
|
+
const isProxy: typeof import('vue').isProxy
|
|
22
|
+
const isReactive: typeof import('vue').isReactive
|
|
23
|
+
const isReadonly: typeof import('vue').isReadonly
|
|
24
|
+
const isRef: typeof import('vue').isRef
|
|
25
|
+
const isShallow: typeof import('vue').isShallow
|
|
26
|
+
const markRaw: typeof import('vue').markRaw
|
|
27
|
+
const nextTick: typeof import('vue').nextTick
|
|
28
|
+
const onActivated: typeof import('vue').onActivated
|
|
29
|
+
const onBeforeMount: typeof import('vue').onBeforeMount
|
|
30
|
+
const onBeforeUnmount: typeof import('vue').onBeforeUnmount
|
|
31
|
+
const onBeforeUpdate: typeof import('vue').onBeforeUpdate
|
|
32
|
+
const onDeactivated: typeof import('vue').onDeactivated
|
|
33
|
+
const onErrorCaptured: typeof import('vue').onErrorCaptured
|
|
34
|
+
const onMounted: typeof import('vue').onMounted
|
|
35
|
+
const onRenderTracked: typeof import('vue').onRenderTracked
|
|
36
|
+
const onRenderTriggered: typeof import('vue').onRenderTriggered
|
|
37
|
+
const onScopeDispose: typeof import('vue').onScopeDispose
|
|
38
|
+
const onServerPrefetch: typeof import('vue').onServerPrefetch
|
|
39
|
+
const onUnmounted: typeof import('vue').onUnmounted
|
|
40
|
+
const onUpdated: typeof import('vue').onUpdated
|
|
41
|
+
const onWatcherCleanup: typeof import('vue').onWatcherCleanup
|
|
42
|
+
const provide: typeof import('vue').provide
|
|
43
|
+
const reactive: typeof import('vue').reactive
|
|
44
|
+
const readonly: typeof import('vue').readonly
|
|
45
|
+
const ref: typeof import('vue').ref
|
|
46
|
+
const resolveComponent: typeof import('vue').resolveComponent
|
|
47
|
+
const shallowReactive: typeof import('vue').shallowReactive
|
|
48
|
+
const shallowReadonly: typeof import('vue').shallowReadonly
|
|
49
|
+
const shallowRef: typeof import('vue').shallowRef
|
|
50
|
+
const toRaw: typeof import('vue').toRaw
|
|
51
|
+
const toRef: typeof import('vue').toRef
|
|
52
|
+
const toRefs: typeof import('vue').toRefs
|
|
53
|
+
const toValue: typeof import('vue').toValue
|
|
54
|
+
const triggerRef: typeof import('vue').triggerRef
|
|
55
|
+
const unref: typeof import('vue').unref
|
|
56
|
+
const useAttrs: typeof import('vue').useAttrs
|
|
57
|
+
const useBreak: typeof import('../hooks/useBreak').useBreak
|
|
58
|
+
const useCaptcha: typeof import('../hooks/useCaptcha').useCaptcha
|
|
59
|
+
const useChat: typeof import('../hooks/useChat').useChat
|
|
60
|
+
const useCssModule: typeof import('vue').useCssModule
|
|
61
|
+
const useCssVars: typeof import('vue').useCssVars
|
|
62
|
+
const useIcon: typeof import('../hooks/useIcon').useIcon
|
|
63
|
+
const useId: typeof import('vue').useId
|
|
64
|
+
const useModel: typeof import('vue').useModel
|
|
65
|
+
const useNanoid: typeof import('../hooks/useNanoid').useNanoid
|
|
66
|
+
const useSlots: typeof import('vue').useSlots
|
|
67
|
+
const useTemplateRef: typeof import('vue').useTemplateRef
|
|
68
|
+
const useUpload: typeof import('../hooks/useUpload').useUpload
|
|
69
|
+
const watch: typeof import('vue').watch
|
|
70
|
+
const watchEffect: typeof import('vue').watchEffect
|
|
71
|
+
const watchPostEffect: typeof import('vue').watchPostEffect
|
|
72
|
+
const watchSyncEffect: typeof import('vue').watchSyncEffect
|
|
73
|
+
}
|
|
74
|
+
// for type re-export
|
|
75
|
+
declare global {
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
export type { Component, Slot, Slots, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, ShallowRef, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
|
|
78
|
+
import('vue')
|
|
79
|
+
}
|
package/src/locale/index.ts
CHANGED
|
@@ -14,7 +14,7 @@ const getStoredLocale = (): string => {
|
|
|
14
14
|
else return availableCodes[0] ?? 'zh-CN'
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const LOCALE_INJECTION_KEY = Symbol('vue-
|
|
17
|
+
const LOCALE_INJECTION_KEY = Symbol('vue-locale')
|
|
18
18
|
const locale = ref<string>(getStoredLocale())
|
|
19
19
|
const messages: Messages = reactive({ 'en': enUS, 'zh-CN': zhCN })
|
|
20
20
|
|
package/src/resolver.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface VueResolverOptions {
|
|
2
|
+
importStyle?: boolean
|
|
3
|
+
prefix?: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function VueResolver(options: VueResolverOptions = {}) {
|
|
7
|
+
const { importStyle = true, prefix = 'Vue' } = options
|
|
8
|
+
return {
|
|
9
|
+
type: 'component' as const,
|
|
10
|
+
resolve(name: string) {
|
|
11
|
+
if (!name.startsWith(prefix)) return
|
|
12
|
+
return {
|
|
13
|
+
name,
|
|
14
|
+
from: '@gindow/vue',
|
|
15
|
+
sideEffects: importStyle ? '@gindow/vue/style.css' : undefined,
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/style.css
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* vue-go 样式占位文件。
|
|
3
|
-
*
|
|
4
|
-
* vue-go 本身不包含 UI 组件,只提供基础样式工具类:
|
|
5
|
-
* - TailwindCSS 基础配置
|
|
6
|
-
* - 通用 flex 布局工具类
|
|
7
|
-
* - 通用文本颜色工具类(含暗黑模式)
|
|
8
|
-
*
|
|
9
|
-
* 实际组件样式以 SFC <style> 块的形式写在各 .vue 文件中:
|
|
10
|
-
* - npm 包模式:构建时由 Vite 提取并聚合到 dist/style.css
|
|
11
|
-
* - submodule 源码模式:消费者 import .vue 时由 vue 插件自动注入
|
|
12
|
-
*/
|
|
13
1
|
@import "tailwindcss";
|
|
14
2
|
|
|
15
3
|
@source ".";
|
|
16
4
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.flex-center-between { display: flex !important; align-items: center; justify-content: space-between; }
|
|
20
|
-
.flex-center-items { display: flex !important; align-items: center; }
|
|
5
|
+
@media screen and (min-width: 768px) { .mob { display: none !important; } } /* 手机端 */
|
|
6
|
+
@media screen and (max-width: 768px) { .web { display: none !important } } /* 电脑端 */
|
|
21
7
|
|
|
8
|
+
.bg-light { background-color: #ccc; }
|
|
22
9
|
.text-light { color: #ccc; }
|
|
23
10
|
|
|
11
|
+
.dark .bg-light { background-color: #333; }
|
|
24
12
|
.dark .text-light { color: #333; }
|
|
13
|
+
|
|
14
|
+
.flex-center { display: flex !important; align-items: center; justify-content: center; }
|
|
15
|
+
.flex-center-end { display: flex !important; align-items: center; justify-content: end; }
|
|
16
|
+
.flex-center-between { display: flex !important; align-items: center; justify-content: space-between; }
|
|
17
|
+
.flex-center-items { display: flex !important; align-items: center; }
|
package/src/utils/index.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
export { request } from './request'
|
|
2
|
-
export { resource } from './request'
|
|
3
|
-
export { $params } from './request'
|
|
4
|
-
export { get } from './get'
|
|
5
|
-
export { download } from './download'
|
|
6
1
|
export { Formatter } from './formatter'
|
|
7
2
|
export { Validate } from './validate'
|
|
8
|
-
export { DateTime } from './datetime'
|
|
9
|
-
export { Platform } from './platform'
|
package/dist/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("vue"),l=require("js-cookie");l=s(l,1);let u=require("axios");u=s(u,1);let d=require("dayjs");d=s(d,1);let f=require("@iconify/vue"),p=require("nanoid"),m=require("nanoid/non-secure"),h=require("file-type-checker");h=s(h,1);let g=require("heic2any");g=s(g,1);let _=require("compressorjs");_=s(_,1);var v={cancel:`取消`,confirm:`确认`,empty:{noData:`暂无数据`},dialog:{tip:`操作提示`,confirm:`操作确认`}},y={cancel:`Cancel`,confirm:`Confirm`,empty:{noData:`No data`},dialog:{tip:`Tip`,confirm:`Confirm`}},b=()=>{let e=[`en`,`zh-CN`],t=localStorage.getItem(`locale`),n=navigator.language;return t&&e.includes(t)?t:n&&e.includes(n)?n:n&&e.includes(n.split(`-`)[0])?n.split(`-`)[0]:e[0]??`zh-CN`},x=Symbol(`vue-go-locale`),S=(0,c.ref)(b()),C=(0,c.reactive)({en:y,"zh-CN":v}),w=e=>{if(e?.locale&&(S.value=e.locale),e?.messages)for(let[t,n]of Object.entries(e.messages))C[t]=n;return(0,c.provide)(x,{locale:S,messages:C}),{locale:S,messages:C}},T=()=>{let e=(0,c.inject)(x,void 0),t=e?.locale??S,n=e?.messages??C;return{locale:t,t:(e,r)=>{let i=n[t.value],a=e.replace(/\[(\d+)]/g,`.$1`).split(`.`),o=i;for(let t of a)if(o=o?.[t],o===void 0)return e;let s=o??e;return r&&typeof s==`string`&&(s=s.replace(/\{(\w+)\}/g,(e,t)=>r[t]===void 0?`{${t}}`:String(r[t]))),s}}},E=e=>S.value=e,D=()=>S.value,O=class e{static get userAgent(){return window.navigator.userAgent.toLowerCase()}static get isFlutter(){return e.userAgent.match(/flutter/i)!==null}static get isFlutterIOS(){return e.isFlutter&&e.isIOS}static get isWeb(){return window.matchMedia(`(min-width: 992px)`).matches}static get isMobile(){return e.userAgent.match(/(phone|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)!==null}static get isIOS(){return e.userAgent.match(/iphone|ipad|ipod|ios/i)!==null}static get isWechat(){return e.userAgent.match(/MicroMessenger/i)!==null}static get isWxwork(){return e.userAgent.match(/MicroMessenger/i)!==null&&e.userAgent.match(/wxwork/i)!==null}static get isMiniprogram(){return e.userAgent.match(/MicroMessenger/i)!==null&&e.userAgent.match(/miniprogram/i)!==null}},k=e=>{let t={...e};return typeof t?.search==`string`?t:(t?.search&&(t.search=Object.keys(t.search).filter(e=>t.search[e]!==null&&t.search[e]!==``).map(e=>e+`:`+t.search[e]).join(`;`)),t?.searchFields&&(t.searchFields=Object.keys(t.searchFields).filter(e=>t.searchFields[e]).map(e=>e+`:`+t.searchFields[e]).join(`;`)),t)},A={baseURL:``,publicKey:``,headers:{Accept:`application/json`},instance:null,accessToken:`accessToken`,init(e={}){this.baseURL=e.baseURL??``,this.publicKey=e.publicKey??``;let t=()=>{this.delToken(),location.reload()};this.instance=u.default.create({baseURL:this.baseURL}),this.instance.interceptors.request.use(e=>{let t=localStorage.getItem(`locale`);return t&&(e.headers[`Accept-Language`]=t),e}),this.instance.interceptors.response.use(e=>e.config.responseType===`blob`?e:e.data.code===401?t():e.data.code===200?e.data:Promise.reject(e.data),({response:e})=>Promise.reject(e.data))},setToken(e,t={}){t={...t,domain:`.`+location.hostname},l.default.set(this.accessToken,e,t)},getToken(){return l.default.get(this.accessToken)||``},delToken(){l.default.remove(this.accessToken,{domain:`.`+location.hostname})},get(e,t,n=!1){return this.request({method:`GET`,url:e,params:t},n)},put(e,t,n=!1){return this.request({method:`PUT`,url:e,data:t},n)},patch(e,t,n=!1){return this.request({method:`PATCH`,url:e,data:t},n)},delete(e,t,n=!1){return this.request({method:`DELETE`,url:e,params:t},n)},post(e,t,n=!1){return this.request({method:`POST`,url:e,data:t},n)},blob(e,t,n=!1){return this.request({method:`GET`,url:e,params:t,responseType:`blob`},n)},request(e,t=!1){let n=e.headers??this.headers;return t&&(n.Authorization=`Bearer `+this.getToken()),e.params&&=k(e.params),this.instance({...e,headers:n})},async download(e,t,n,r=!1){let i=await this.blob(e,t,r);if(O.isFlutter)return i;let a=()=>{let e=i.headers[`content-disposition`].split(`filename*=`)[1].split(`;`)[0].trim();return decodeURIComponent(e.replace(/^UTF-8''/i,``))},o=document.createElement(`a`);return o.href=window.URL.createObjectURL(i.data),o.download=n??a(),o.click(),i},async upload(e,t={}){let n={...this.headers,"Content-Type":`multipart/form-data`};return this.instance.post(e,t,{headers:n})},sse(e,t){let n=t?Object.keys(t).map(e=>e+`=`+t[e]).join(`&`):``;return new EventSource(this.baseURL+`/`+e+`?`+n)},setHeader(e,t){this.headers[e]=t},delHeader(e){delete this.headers[e]}},j=class{url;auth;constructor(e,t=!1){this.url=e,this.auth=t}select=e=>A.get(this.url,e,this.auth);create=e=>A.post(this.url,e,this.auth);find=(e,t)=>A.get(this.url+`/`+e,t,this.auth);update=(e,t)=>A.patch(this.url+`/`+e,t,this.auth);delete=(e,t)=>A.delete(this.url+`/`+e,t,this.auth);async get(e){e.size=1;let t=await this.select(e);return t.data=t.data[0]||{},t}},M=(e,t,n)=>{if(e==null)return n;let r=Array.isArray(t)?t:t.replace(/\[(\d+)]/g,`.$1`).split(`.`).filter(Boolean),i=e;for(let e of r)if(i=i?.[e],i===void 0)return n;return i},N=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.style.display=`none`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},P=class{static config={};static set=e=>this.config=e;static id=(e=``)=>e.slice(-12).toUpperCase();static date=(e=``)=>e.substring(0,10)+` `+e.substring(11,19);static idcard=(e=``)=>e?e.substring(0,6)+`****`+e.substring(14):``;static phone=(e=``,t=!1)=>t||!e?e:e.substring(0,3)+`****`+e.substring(e.length-4);static email=(e=``)=>{let[t,n]=e.split(`@`);return!t||!n?e:`${t.length>2?t[0]+`****`+t[t.length-1]:t}@${n}`};static bankcard=(e=``)=>e.substring(0,4)+`****`+e.substring(e.length-4);static url=(e=``)=>e.replace(/:\/\//g,`:##`).replace(/\/+/g,`/`).replace(/:##/g,`://`);static price=(e=0,t)=>{let{locale:n,decimals:r,currency:i}=this.config,a=typeof e==`string`?parseFloat(e):e;return new Intl.NumberFormat(n,{style:`currency`,currency:t??i??`CNY`,minimumFractionDigits:r??2,maximumFractionDigits:r??2}).format(a/100)};static currency=(e=0,t)=>this.price(e,t)},F=class e{static country=``;static set=e=>this.country=e;static get phone_pattern(){return this.country.toUpperCase()===`CN`?/([1][3,4,5,6,7,8,9][0-9]{9})$/:/^(?:\+?[1-9]\d{7,14}|\d{6,11})$/}static email_pattern=/^([a-zA-Z0-9_\.-]+)@([\da-zA-Z\.-]+)\.([a-zA-Z\.]{2,6})$/;static idcard_pattern=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;static cname_pattern=/^(?:[\u4e00-\u9fa5·]{2,16})$/;static password_pattern=/^(?![A-Za-z]+$)(?![0-9]+$)(?![^A-Za-z0-9]+$).{8,20}$/;static phone=t=>e.phone_pattern.test(t);static email=t=>e.email_pattern.test(t);static idcard=t=>e.idcard_pattern.test(t);static cname=t=>e.cname_pattern.test(t)},I=class e{static dayjs=d.default;static s(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH:mm:ss`.replace(/\//g,n))}static m(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH:mm`.replace(/\//g,n))}static h(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH`.replace(/\//g,n))}static d(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD`.replace(/\//g,n))}static M(t,n=`/`){return e.dayjs(t).format(`YYYY/MM`.replace(/\//g,n))}static y(t){return e.dayjs(t).format(`YYYY`)}static date(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD`.replace(/\//g,n))}static time(t){return e.dayjs(t).format(`HH:mm`)}static format(t,n=`YYYY/MM/DD HH:mm:ss`){return e.dayjs(t).format(n)}},L=768,R=()=>{let e=(0,c.ref)(typeof window<`u`?window.matchMedia(`(min-width: ${L}px)`).matches:!0),t,n=t=>e.value=t.matches;(0,c.onMounted)(()=>{typeof window>`u`||(t=window.matchMedia(`(min-width: ${L}px)`),e.value=t.matches,t.addEventListener(`change`,n))}),(0,c.onBeforeUnmount)(()=>t?.removeEventListener(`change`,n));let r=(0,c.computed)(()=>e.value);return{isMobile:(0,c.computed)(()=>!e.value),isDesktop:r}},z=e=>{let t=(0,c.ref)(0),n=(0,c.ref)(!1),r=(t={})=>new Promise((r,a)=>{n.value||(n.value=!0,e(t).then(()=>{i(),r(!0)}).catch(e=>a(e)).finally(()=>n.value=!1))}),i=()=>{t.value=60;let e=setInterval(()=>{t.value--,t.value||clearTimeout(e)},1e3)};return{waiting:t,send:r}},B=(e,t)=>({sendMessage:async(n,r)=>{let{onMessage:i,onEnd:a,onError:o,onFinish:s}=r;try{let{ok:r,status:c,statusText:l,body:u}=await fetch(`${e}/chat-messages`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({...n,response_mode:`streaming`})});if(!r)return o?.({code:String(c),message:l});let d=u?.getReader();if(!d)return o?.({code:`reader_error`,message:`Failed to get response reader`});let f=new TextDecoder,p=``;for(;;){let{done:e,value:t}=await d.read();if(e)break;p+=f.decode(t,{stream:!0});let n=p.split(`
|
|
2
|
-
`);p=n.pop()||``;for(let e of n)if(e.startsWith(`data:`))try{let t=e.slice(5).trim();if(!t)continue;let n=JSON.parse(t);if(n.event===`agent_message`)i?.(n.answer||``);else if(n.event===`message_end`)a?.(n.conversation_id,n.message_id);else if(n.event===`error`){let{code:e,message:t}=n;o?.({code:e,message:t})}s?.()}catch{}}}catch(e){o?.({code:`network_error`,message:String(e)})}}}),V=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,c.defineComponent)({__name:`VueIcon`,props:{vendor:{type:String,default:`icon-park-outline`},icon:{type:String,default:``},size:{type:Number,default:16},strokeWidth:{type:Number,default:4},color:{type:String}},setup(e){(0,c.useCssVars)(e=>({v1903d129:i.value}));let t=e,n=(0,c.computed)(()=>t.icon.indexOf(`:`)===-1?`${t.vendor}:${t.icon}`:t.icon),r=(0,c.computed)(()=>t.color?{color:t.color}:void 0),i=(0,c.computed)(()=>t.strokeWidth);return(t,i)=>((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(f.Icon),{icon:n.value,width:e.size,height:e.size,style:(0,c.normalizeStyle)(r.value),"aria-hidden":null},null,8,[`icon`,`width`,`height`,`style`]))}}),[[`__scopeId`,`data-v-2533db5c`]]),H=()=>({i:(e,t={})=>e?(0,c.h)(V,{icon:e,...t}):void 0}),U=()=>({nanoid:p.nanoid,numeric:(e=10)=>(0,m.customAlphabet)(`1234567890`,e)()}),W=()=>{let e=e=>new Promise(async t=>{let n=await(0,g.default)({blob:e,toType:`image/jpeg`,quality:.9});return t(new File([n],e.name,{type:n.type,lastModified:Date.now()}))}),t=e=>new Promise(t=>{new _.default(e,{quality:.9,success:e=>t(e)})});return{handler:(n,r={compressor:!0})=>new Promise(i=>{let a=new FileReader;a.readAsArrayBuffer(n),a.onload=()=>{let o=h.default.validateFileType(a.result,[`heic`]),s=h.default.validateFileType(a.result,[`jpeg`,`png`,`gif`,`bmp`]);o?i(e(n)):s&&r.compressor?i(t(n)):i(n)}}),getDimension:async e=>new Promise((t,n)=>{let r=new Image;r.src=URL.createObjectURL(e),r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=e=>n(e)}),getFileType:e=>new Promise(t=>{let n=new FileReader;n.readAsArrayBuffer(e),n.onload=()=>{t({mimeType:h.default.detectFile(n.result)?.mimeType})}})}},G={install(e,t){w(t),e.config.globalProperties.$setLocale=E,e.config.globalProperties.$getLocale=D}};exports.$params=k,exports.DateTime=I,exports.Formatter=P,exports.Platform=O,exports.Validate=F,exports.default=G,exports.download=N,exports.get=M,exports.getLocale=D,exports.request=A,exports.resource=j,exports.setLocale=E,exports.useBreak=R,exports.useCaptcha=z,exports.useChat=B,exports.useIcon=H,exports.useLocale=T,exports.useNanoid=U,exports.useUpload=W;
|