hy-dispatch-ui-v3 0.2.80 → 0.2.82
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/tailwind.css +71 -13
- package/es/api/file.mjs +19 -0
- package/es/bussiness/hyDisplayQueryAddress/displayQueryAddress2.vue.mjs +1 -1
- package/es/components/hyKindEditor/index.mjs +7 -0
- package/es/components/hyKindEditor/kindEditor.vue.mjs +285 -0
- package/es/components/hyKindEditor/style/kindEditor.scss +18 -0
- package/es/components/hyUserAvatar/style/userAvatar.scss +18 -15
- package/es/components/hyUserAvatar/userAvatar.vue.mjs +157 -53
- package/es/components/index.mjs +1 -0
- package/es/index.mjs +2 -1
- package/es/static/hy-svg-icons/hy-icon-dispatch-share1-user-high.js +16 -0
- package/es/static/hy-svg-icons/hy-icon-dispatch-share1-user-off.js +20 -0
- package/es/utils/file.mjs +7 -1
- package/es/utils/index.mjs +1 -1
- package/es/version.mjs +1 -1
- package/lib/api/file.js +21 -0
- package/lib/bussiness/hyDisplayQueryAddress/displayQueryAddress2.vue.js +1 -1
- package/lib/components/hyKindEditor/index.js +12 -0
- package/lib/components/hyKindEditor/kindEditor.vue.js +289 -0
- package/lib/components/hyKindEditor/style/kindEditor.scss +18 -0
- package/lib/components/hyUserAvatar/style/userAvatar.scss +18 -15
- package/lib/components/hyUserAvatar/userAvatar.vue.js +156 -52
- package/lib/components/index.js +32 -30
- package/lib/index.js +51 -48
- package/lib/static/hy-svg-icons/hy-icon-dispatch-share1-user-high.js +16 -0
- package/lib/static/hy-svg-icons/hy-icon-dispatch-share1-user-off.js +20 -0
- package/lib/utils/file.js +7 -0
- package/lib/utils/index.js +1 -0
- package/lib/version.js +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
var elementPlus = require('element-plus');
|
|
7
|
+
var editorForVue = require('@wangeditor/editor-for-vue');
|
|
8
|
+
var editor = require('@wangeditor/editor');
|
|
9
|
+
require('../../utils/index.js');
|
|
10
|
+
var file = require('../../utils/file.js');
|
|
11
|
+
|
|
12
|
+
import "@wangeditor/editor/dist/css/style.css";
|
|
13
|
+
|
|
14
|
+
import "./style/kindEditor.scss";
|
|
15
|
+
|
|
16
|
+
const __default__ = vue.defineComponent({
|
|
17
|
+
name: "HyKindEditor"
|
|
18
|
+
});
|
|
19
|
+
const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
20
|
+
props: /* @__PURE__ */ vue.mergeModels({
|
|
21
|
+
mode: { type: String, default: "default" },
|
|
22
|
+
// 'default' | 'simple'
|
|
23
|
+
height: { type: [String, Number], default: 300 },
|
|
24
|
+
// 编辑区高度
|
|
25
|
+
placeholder: { type: String, default: "\u8BF7\u8F93\u5165\u5185\u5BB9..." },
|
|
26
|
+
disabled: { type: Boolean, default: false },
|
|
27
|
+
// 只读
|
|
28
|
+
showToolbar: { type: Boolean, default: true },
|
|
29
|
+
toolbarConfig: { type: Object, default: () => ({}) },
|
|
30
|
+
// 透传 wangEditor toolbarConfig
|
|
31
|
+
editorConfig: { type: Object, default: () => ({}) },
|
|
32
|
+
// 透传 wangEditor editorConfig
|
|
33
|
+
maxImageSize: { type: Number, default: 10 },
|
|
34
|
+
// 图片大小限制,单位 MB
|
|
35
|
+
maxVideoSize: { type: Number, default: 100 },
|
|
36
|
+
// 视频大小限制,单位 MB
|
|
37
|
+
pasteImageFilter: { type: Function }
|
|
38
|
+
// (src: string) => boolean,返回 false 的图片不转存(如自家 OSS 域名)
|
|
39
|
+
}, {
|
|
40
|
+
"modelValue": { type: String, default: "" },
|
|
41
|
+
"modelModifiers": {}
|
|
42
|
+
}),
|
|
43
|
+
emits: /* @__PURE__ */ vue.mergeModels(["created", "change", "focus", "blur"], ["update:modelValue"]),
|
|
44
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
45
|
+
const props = __props;
|
|
46
|
+
const emits = __emit;
|
|
47
|
+
const modelValue = vue.useModel(__props, "modelValue");
|
|
48
|
+
const editorRef = vue.shallowRef();
|
|
49
|
+
const editorHeight = vue.computed(() => typeof props.height === "number" ? `${props.height}px` : props.height);
|
|
50
|
+
const fileURLList = [];
|
|
51
|
+
const rememberFile = ({ key, url }) => {
|
|
52
|
+
if (!key || !url) return;
|
|
53
|
+
if (fileURLList.some((item) => item.url === url)) return;
|
|
54
|
+
fileURLList.push({ key, url });
|
|
55
|
+
};
|
|
56
|
+
const isKnownUrl = (url) => fileURLList.some((item) => item.url === url);
|
|
57
|
+
const getMediaSrcList = (html) => {
|
|
58
|
+
const list = [];
|
|
59
|
+
const tags = html.match(/<(img|video|source)\b[^>]*>/gi) || [];
|
|
60
|
+
tags.forEach((tag) => {
|
|
61
|
+
for (const [, value] of tag.matchAll(/\s(?:src|poster)="([^"]*)"/gi)) {
|
|
62
|
+
value && list.push(value);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return [...new Set(list)];
|
|
66
|
+
};
|
|
67
|
+
const isUrl = (value) => /^(https?:|blob:|data:)/i.test(value);
|
|
68
|
+
const replaceSrc = (html, from, to) => html.replaceAll(`"${from}"`, `"${to}"`);
|
|
69
|
+
const keyToUrl = async (html) => {
|
|
70
|
+
if (!html) return "";
|
|
71
|
+
const keyList = getMediaSrcList(html).filter((value) => !isUrl(value));
|
|
72
|
+
if (!keyList.length) return html;
|
|
73
|
+
try {
|
|
74
|
+
const res = await file.preSignedUrlGetApi(keyList);
|
|
75
|
+
const data = res?.data || [];
|
|
76
|
+
data.forEach(({ key, url }) => {
|
|
77
|
+
if (!key || !url) return;
|
|
78
|
+
html = replaceSrc(html, key, url);
|
|
79
|
+
rememberFile({ key, url });
|
|
80
|
+
});
|
|
81
|
+
const failCount = keyList.filter((key) => !data.some((item) => item.key === key && item.url)).length;
|
|
82
|
+
if (failCount) {
|
|
83
|
+
elementPlus.ElMessage.warning(`\u5185\u5BB9\u4E2D\u6709 ${failCount} \u4E2A\u56FE\u7247/\u89C6\u9891\u52A0\u8F7D\u5931\u8D25`);
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.warn("[HyKindEditor] key \u6362 url \u5931\u8D25\uFF0C\u4FDD\u7559\u539F\u5185\u5BB9", e);
|
|
87
|
+
elementPlus.ElMessage.error(e?.msg || e?.message || "\u5185\u5BB9\u4E2D\u7684\u56FE\u7247/\u89C6\u9891\u52A0\u8F7D\u5931\u8D25");
|
|
88
|
+
}
|
|
89
|
+
return html;
|
|
90
|
+
};
|
|
91
|
+
const urlToKey = (html) => {
|
|
92
|
+
if (!html) return "";
|
|
93
|
+
fileURLList.forEach(({ key, url }) => {
|
|
94
|
+
html = replaceSrc(html, url, key);
|
|
95
|
+
});
|
|
96
|
+
return html;
|
|
97
|
+
};
|
|
98
|
+
const FILE_TYPES = {
|
|
99
|
+
image: {
|
|
100
|
+
name: "\u56FE\u7247",
|
|
101
|
+
types: ["image/jpeg", "image/png", "image/gif", "image/bmp", "image/webp"],
|
|
102
|
+
typesText: "jpg\u3001png\u3001gif\u3001bmp\u3001webp",
|
|
103
|
+
getMaxSize: () => props.maxImageSize
|
|
104
|
+
},
|
|
105
|
+
video: {
|
|
106
|
+
name: "\u89C6\u9891",
|
|
107
|
+
types: ["video/*"],
|
|
108
|
+
getMaxSize: () => props.maxVideoSize
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const isAllowedType = (file, types) => types.some((type) => type.endsWith("/*") ? file.type.startsWith(type.slice(0, -1)) : file.type === type);
|
|
112
|
+
const checkFile = (file, fileType) => {
|
|
113
|
+
const { name, types, typesText, getMaxSize } = FILE_TYPES[fileType];
|
|
114
|
+
if (!isAllowedType(file, types)) {
|
|
115
|
+
throw new Error(typesText ? `${name}\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4EC5\u652F\u6301 ${typesText}` : `\u8BF7\u9009\u62E9${name}\u6587\u4EF6`);
|
|
116
|
+
}
|
|
117
|
+
if (file.size === 0) {
|
|
118
|
+
throw new Error("\u65E0\u6CD5\u53D1\u9001\u7A7A\u6587\u4EF6(0KB)\uFF0C\u8BF7\u9009\u62E9\u5305\u542B\u5185\u5BB9\u7684\u6587\u4EF6");
|
|
119
|
+
}
|
|
120
|
+
const maxSize = getMaxSize();
|
|
121
|
+
if (file.size / 1024 / 1024 > maxSize) {
|
|
122
|
+
throw new Error(`\u4E0A\u4F20\u7684\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236(${maxSize}MB)`);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const uploadFile = async (file$1, fileType) => {
|
|
126
|
+
checkFile(file$1, fileType);
|
|
127
|
+
const fileUploadRes = await file.fileUpload(file$1);
|
|
128
|
+
if (fileUploadRes?.code !== 200) throw fileUploadRes;
|
|
129
|
+
const preSignedUrlGetApiRes = await file.preSignedUrlGetApi([fileUploadRes.data.key]);
|
|
130
|
+
const item = preSignedUrlGetApiRes?.data?.[0];
|
|
131
|
+
if (!item?.url) throw new Error("\u83B7\u53D6\u6587\u4EF6\u5730\u5740\u5931\u8D25");
|
|
132
|
+
rememberFile(item);
|
|
133
|
+
return item.url;
|
|
134
|
+
};
|
|
135
|
+
const createUploader = (fileType) => ({
|
|
136
|
+
allowedFileTypes: FILE_TYPES[fileType].types,
|
|
137
|
+
async customUpload(file, insertFn) {
|
|
138
|
+
try {
|
|
139
|
+
insertFn(await uploadFile(file, fileType));
|
|
140
|
+
} catch (e) {
|
|
141
|
+
elementPlus.ElMessage.error(e?.msg || e?.message || `${FILE_TYPES[fileType].name}\u4E0A\u4F20\u5931\u8D25`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const DEFAULT_EXCLUDE_KEYS = ["emotion", "insertLink", "insertImage", "insertVideo", "fullScreen"];
|
|
146
|
+
const toolbarOptions = vue.computed(() => {
|
|
147
|
+
const { excludeKeys = [], ...rest } = props.toolbarConfig;
|
|
148
|
+
return {
|
|
149
|
+
...rest,
|
|
150
|
+
excludeKeys: [.../* @__PURE__ */ new Set([...DEFAULT_EXCLUDE_KEYS, ...excludeKeys])]
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
const getPasteImageSrcs = (html) => {
|
|
154
|
+
if (!html || !/<img/i.test(html)) return [];
|
|
155
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
156
|
+
const srcs = [...doc.querySelectorAll("img")].map((img) => img.getAttribute("src") || "");
|
|
157
|
+
return [...new Set(srcs)].filter(
|
|
158
|
+
(src) => /^(https?:|data:image\/)/i.test(src) && !isKnownUrl(src) && (!props.pasteImageFilter || props.pasteImageFilter(src) !== false)
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
const srcToFile = async (src) => {
|
|
162
|
+
const res = await fetch(src, { mode: "cors", credentials: "omit" }).catch(() => {
|
|
163
|
+
throw new Error("\u6765\u6E90\u7F51\u7AD9\u4E0D\u5141\u8BB8\u4E0B\u8F7D\u8BE5\u56FE\u7247");
|
|
164
|
+
});
|
|
165
|
+
if (!res.ok) throw new Error(`\u4E0B\u8F7D\u5931\u8D25\uFF1A${res.status}`);
|
|
166
|
+
const blob = await res.blob();
|
|
167
|
+
const ext = blob.type.split("/")[1]?.split("+")[0] || "png";
|
|
168
|
+
return new File([blob], `paste-${Date.now()}.${ext}`, { type: blob.type });
|
|
169
|
+
};
|
|
170
|
+
const updateImage = (oldSrc, attrs) => {
|
|
171
|
+
const editor$1 = editorRef.value;
|
|
172
|
+
if (!editor$1 || editor$1.isDestroyed) return;
|
|
173
|
+
editor.SlateTransforms.setNodes(editor$1, attrs, {
|
|
174
|
+
at: [],
|
|
175
|
+
voids: true,
|
|
176
|
+
match: (node) => node.type === "image" && node.src === oldSrc
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
const hasImageInEditor = (src) => !!editorRef.value?.getElemsByType("image").some((node) => node.src === src);
|
|
180
|
+
const transferPasteImages = async (pasteSrcs) => {
|
|
181
|
+
const srcs = pasteSrcs.filter(hasImageInEditor);
|
|
182
|
+
const reasons = [];
|
|
183
|
+
await Promise.all(
|
|
184
|
+
srcs.map(async (src) => {
|
|
185
|
+
try {
|
|
186
|
+
const url = await uploadFile(await srcToFile(src), "image");
|
|
187
|
+
updateImage(src, { src: url });
|
|
188
|
+
} catch (e) {
|
|
189
|
+
reasons.push(e?.msg || e?.message || "\u672A\u77E5\u539F\u56E0");
|
|
190
|
+
updateImage(src, { src: "", alt: "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25" });
|
|
191
|
+
console.warn("[HyKindEditor] \u7C98\u8D34\u56FE\u7247\u8F6C\u5B58\u5931\u8D25\uFF0C\u5DF2\u6E05\u7A7A\u5730\u5740\uFF1A", src, e);
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
if (reasons.length) {
|
|
196
|
+
elementPlus.ElMessage.error(`${reasons.length} \u5F20\u7C98\u8D34\u7684\u56FE\u7247\u8F6C\u5B58\u5931\u8D25\uFF08${reasons[0]}\uFF09\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20`);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const handleCustomPaste = (editor, event, callback) => {
|
|
200
|
+
if (props.editorConfig.customPaste?.(editor, event) === false) {
|
|
201
|
+
callback(false);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const srcs = getPasteImageSrcs(event.clipboardData?.getData("text/html"));
|
|
205
|
+
srcs.length && setTimeout(() => transferPasteImages(srcs));
|
|
206
|
+
callback(true);
|
|
207
|
+
};
|
|
208
|
+
const DEFAULT_HOVERBAR_KEYS = {
|
|
209
|
+
image: { menuKeys: ["imageWidth30", "imageWidth50", "imageWidth100", "deleteImage"] }
|
|
210
|
+
};
|
|
211
|
+
const editorOptions = vue.computed(() => {
|
|
212
|
+
const { MENU_CONF = {}, customPaste, hoverbarKeys = {}, ...rest } = props.editorConfig;
|
|
213
|
+
return {
|
|
214
|
+
placeholder: props.placeholder,
|
|
215
|
+
readOnly: props.disabled,
|
|
216
|
+
...rest,
|
|
217
|
+
hoverbarKeys: { ...DEFAULT_HOVERBAR_KEYS, ...hoverbarKeys },
|
|
218
|
+
MENU_CONF: {
|
|
219
|
+
uploadImage: createUploader("image"),
|
|
220
|
+
uploadVideo: createUploader("video"),
|
|
221
|
+
...MENU_CONF
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
const handleCreated = (editor) => {
|
|
226
|
+
editorRef.value = editor;
|
|
227
|
+
emits("created", editor);
|
|
228
|
+
};
|
|
229
|
+
vue.watch(
|
|
230
|
+
() => props.disabled,
|
|
231
|
+
(val) => {
|
|
232
|
+
const editor = editorRef.value;
|
|
233
|
+
if (!editor) return;
|
|
234
|
+
val ? editor.disable() : editor.enable();
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
vue.onBeforeUnmount(() => {
|
|
238
|
+
editorRef.value?.destroy();
|
|
239
|
+
editorRef.value = null;
|
|
240
|
+
});
|
|
241
|
+
__expose({
|
|
242
|
+
getEditor: () => editorRef.value,
|
|
243
|
+
getHtml: () => editorRef.value?.getHtml() ?? "",
|
|
244
|
+
getText: () => editorRef.value?.getText() ?? "",
|
|
245
|
+
isEmpty: () => editorRef.value?.isEmpty() ?? true,
|
|
246
|
+
clear: () => editorRef.value?.clear(),
|
|
247
|
+
focus: () => editorRef.value?.focus(),
|
|
248
|
+
insertHtml: (html) => editorRef.value?.dangerouslyInsertHtml(html),
|
|
249
|
+
// 回显:把内容中图片 / 视频的 key 换成 url,返回新内容
|
|
250
|
+
keyToUrl,
|
|
251
|
+
// 保存:把内容中图片 / 视频的 url 换回 key,返回新内容
|
|
252
|
+
urlToKey
|
|
253
|
+
});
|
|
254
|
+
return (_ctx, _cache) => {
|
|
255
|
+
return vue.openBlock(), vue.createElementBlock(
|
|
256
|
+
"div",
|
|
257
|
+
{
|
|
258
|
+
class: vue.normalizeClass(["hy-kind-editor z-[10000]", { "is-disabled": __props.disabled }])
|
|
259
|
+
},
|
|
260
|
+
[
|
|
261
|
+
__props.showToolbar ? (vue.openBlock(), vue.createBlock(vue.unref(editorForVue.Toolbar), {
|
|
262
|
+
key: 0,
|
|
263
|
+
class: "hy-kind-editor__toolbar",
|
|
264
|
+
editor: editorRef.value,
|
|
265
|
+
"default-config": toolbarOptions.value,
|
|
266
|
+
mode: __props.mode
|
|
267
|
+
}, null, 8, ["editor", "default-config", "mode"])) : vue.createCommentVNode("v-if", true),
|
|
268
|
+
vue.createVNode(vue.unref(editorForVue.Editor), {
|
|
269
|
+
modelValue: modelValue.value,
|
|
270
|
+
"onUpdate:modelValue": ($event) => modelValue.value = $event,
|
|
271
|
+
class: "hy-kind-editor__content",
|
|
272
|
+
style: vue.normalizeStyle({ height: editorHeight.value }),
|
|
273
|
+
"default-config": editorOptions.value,
|
|
274
|
+
mode: __props.mode,
|
|
275
|
+
onOnCreated: handleCreated,
|
|
276
|
+
onCustomPaste: handleCustomPaste,
|
|
277
|
+
onOnChange: (editor) => emits("change", editor),
|
|
278
|
+
onOnFocus: (editor) => emits("focus", editor),
|
|
279
|
+
onOnBlur: (editor) => emits("blur", editor)
|
|
280
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "style", "default-config", "mode", "onOnChange", "onOnFocus", "onOnBlur"])
|
|
281
|
+
],
|
|
282
|
+
2
|
|
283
|
+
/* CLASS */
|
|
284
|
+
);
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.hy-kind-editor {
|
|
2
|
+
width: 100%;
|
|
3
|
+
border: 1px solid var(--el-border-color);
|
|
4
|
+
border-radius: var(--el-border-radius-base);
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
|
|
7
|
+
&__toolbar {
|
|
8
|
+
border-bottom: 1px solid var(--el-border-color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&__content {
|
|
12
|
+
overflow-y: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.is-disabled {
|
|
16
|
+
background-color: var(--el-disabled-bg-color);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,32 +1,35 @@
|
|
|
1
|
-
.
|
|
2
|
-
|
|
1
|
+
.hyUserAvatar {
|
|
2
|
+
container-type: inline-size;
|
|
3
|
+
background: rgba(var(--hy-background-2),1);
|
|
3
4
|
position: relative;
|
|
4
|
-
|
|
5
|
+
box-sizing: border-box;
|
|
5
6
|
flex-shrink: 0;
|
|
6
|
-
border-radius:
|
|
7
|
-
.
|
|
7
|
+
border-radius: 10%;
|
|
8
|
+
.headPortrait {
|
|
8
9
|
width: 100%;
|
|
9
10
|
height: 100%;
|
|
10
|
-
border-radius:
|
|
11
|
+
border-radius: 4%;
|
|
11
12
|
overflow: hidden;
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
justify-content: center;
|
|
15
13
|
img {
|
|
16
14
|
height: 100%;
|
|
17
15
|
}
|
|
18
16
|
.svgBox {
|
|
19
|
-
width:
|
|
20
|
-
height:
|
|
21
|
-
color: rgb(var(--hy-main));
|
|
17
|
+
width: 60%;
|
|
18
|
+
height: 60%;
|
|
22
19
|
}
|
|
23
20
|
}
|
|
24
|
-
|
|
21
|
+
.iconTypeBox {
|
|
25
22
|
width: 32%;
|
|
26
23
|
height: 32%;
|
|
27
24
|
border-radius: 50%;
|
|
28
25
|
position: absolute;
|
|
29
|
-
bottom: -
|
|
30
|
-
right: -
|
|
26
|
+
bottom: -10%;
|
|
27
|
+
right: -10%;
|
|
28
|
+
}
|
|
29
|
+
.nameText {
|
|
30
|
+
font-size: 100cqw;
|
|
31
|
+
transform: scale(0.4);
|
|
32
|
+
transform-origin: center;
|
|
33
|
+
white-space: nowrap;
|
|
31
34
|
}
|
|
32
35
|
}
|
|
@@ -6,7 +6,7 @@ var vue = require('vue');
|
|
|
6
6
|
require('../../utils/index.js');
|
|
7
7
|
require('../../hooks/index.js');
|
|
8
8
|
require('../index.js');
|
|
9
|
-
var
|
|
9
|
+
var useBaseMainStore = require('../../hooks/useBaseMainStore.js');
|
|
10
10
|
var adaptive = require('../../utils/adaptive.js');
|
|
11
11
|
var useLocale = require('../../hooks/useLocale.js');
|
|
12
12
|
var index = require('../hyIcon/index.js');
|
|
@@ -21,17 +21,33 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
21
21
|
initSelectSvgName: {
|
|
22
22
|
type: String,
|
|
23
23
|
default: () => {
|
|
24
|
-
return "dispatch-share1-user-
|
|
24
|
+
return "dispatch-share1-user-off";
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
initSvgName: {
|
|
28
28
|
type: String,
|
|
29
29
|
default: () => {
|
|
30
|
-
return "dispatch-share1-user-
|
|
30
|
+
return "dispatch-share1-user-high";
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
device: {
|
|
34
|
+
type: Object,
|
|
35
|
+
default: () => {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
deviceList: {
|
|
40
|
+
type: Array,
|
|
41
|
+
default: () => {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
isBusy: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: () => {
|
|
48
|
+
return false;
|
|
31
49
|
}
|
|
32
50
|
},
|
|
33
|
-
device: Object,
|
|
34
|
-
// 设备信息
|
|
35
51
|
audioContextType: {
|
|
36
52
|
type: Boolean,
|
|
37
53
|
default: () => {
|
|
@@ -57,17 +73,38 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
57
73
|
}
|
|
58
74
|
}
|
|
59
75
|
},
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
setup(__props) {
|
|
77
|
+
const { baseMainStore } = useBaseMainStore.useBaseMainStore();
|
|
62
78
|
const props = __props;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
const isGbDevice = vue.computed(
|
|
66
|
-
() => props.device?.gbDevice === 1 && (props.device?.deviceType || props.device?.type) !== 13
|
|
67
|
-
);
|
|
68
|
-
const headImg = vue.computed(() => {
|
|
69
|
-
return props.device && (vue.unref(userAvatarMap)?.get(props.device.deviceId) || props.device.headImg);
|
|
79
|
+
const getDeviceMap = vue.computed(() => {
|
|
80
|
+
return baseMainStore.value.getters.getDeviceMap;
|
|
70
81
|
});
|
|
82
|
+
const deviceListNum = vue.computed(() => {
|
|
83
|
+
return props.deviceList.length;
|
|
84
|
+
});
|
|
85
|
+
const displayDevice = vue.computed(() => {
|
|
86
|
+
const device = props.deviceList.length === 1 ? props.deviceList[0] : props.device;
|
|
87
|
+
if (props.deviceList.length === 0 && device.deviceId && !device.headImg) {
|
|
88
|
+
const headImgFromMap = getDeviceMap.value.get(device.deviceId);
|
|
89
|
+
if (headImgFromMap) {
|
|
90
|
+
return {
|
|
91
|
+
...device,
|
|
92
|
+
headImg: headImgFromMap
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return device;
|
|
97
|
+
});
|
|
98
|
+
const imgError = vue.ref(false);
|
|
99
|
+
vue.watch(
|
|
100
|
+
() => displayDevice.value.headImg,
|
|
101
|
+
() => {
|
|
102
|
+
imgError.value = false;
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
function setImgError(type) {
|
|
106
|
+
imgError.value = type;
|
|
107
|
+
}
|
|
71
108
|
function parseRem(res) {
|
|
72
109
|
let px = res;
|
|
73
110
|
if (px) {
|
|
@@ -80,57 +117,124 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
80
117
|
return "";
|
|
81
118
|
}
|
|
82
119
|
return (_ctx, _cache) => {
|
|
120
|
+
const _component_HyUserAvatar = vue.resolveComponent("HyUserAvatar");
|
|
83
121
|
return vue.openBlock(), vue.createElementBlock(
|
|
84
122
|
"div",
|
|
85
123
|
{
|
|
86
124
|
style: vue.normalizeStyle({
|
|
87
125
|
width: `${parseRem(__props.width)}rem`,
|
|
88
126
|
height: `${parseRem(__props.height)}rem`,
|
|
89
|
-
"border-color":
|
|
127
|
+
"border-color": deviceListNum.value > 1 ? "rgb(var(--hy-auxiliary), 1)" : displayDevice.value.onlineState === 1 ? __props.audioContextType ? "rgb(var(--hy-theme), 1)" : displayDevice.value.gbDevice === 1 && (displayDevice.value.deviceType || displayDevice.value.type) !== 13 ? "#FDE777" : "rgb(var(--hy-auxiliary), 1)" : "rgb(var(--hy-theme), 1)"
|
|
90
128
|
}),
|
|
91
|
-
class: "
|
|
129
|
+
class: "hyUserAvatar border p-[0.3%] font-bold"
|
|
92
130
|
},
|
|
93
131
|
[
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
{
|
|
97
|
-
|
|
98
|
-
style: vue.normalizeStyle(
|
|
99
|
-
__props.device?.onlineState === 1 ? "background:linear-gradient(180deg, #5A2120 0%, #C81F12 100%); color:#FDE777;" : "background: rgb(var(--hy-background-2)); color: rgb(var(--hy-auxiliary));"
|
|
100
|
-
),
|
|
101
|
-
class: "user-avatar font-[600] text-base"
|
|
132
|
+
deviceListNum.value > 1 ? (vue.openBlock(), vue.createElementBlock("ul", {
|
|
133
|
+
key: 0,
|
|
134
|
+
style: {
|
|
135
|
+
"border-color": "rgb(var(--hy-theme), 1)"
|
|
102
136
|
},
|
|
103
|
-
"
|
|
104
|
-
4
|
|
105
|
-
/* STYLE */
|
|
106
|
-
)) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
107
|
-
key: 1,
|
|
108
|
-
class: "user-avatar"
|
|
137
|
+
class: "w-full h-full flex items-center justify-center overflow-hidden flex-wrap box-border content-center"
|
|
109
138
|
}, [
|
|
110
|
-
|
|
139
|
+
(vue.openBlock(true), vue.createElementBlock(
|
|
140
|
+
vue.Fragment,
|
|
141
|
+
null,
|
|
142
|
+
vue.renderList(__props.deviceList.slice(0, 9), (item, index) => {
|
|
143
|
+
return vue.openBlock(), vue.createElementBlock(
|
|
144
|
+
"li",
|
|
145
|
+
{
|
|
146
|
+
key: index,
|
|
147
|
+
class: vue.normalizeClass([{
|
|
148
|
+
"w-full h-full": deviceListNum.value === 1,
|
|
149
|
+
"p-[2%]": deviceListNum.value > 1,
|
|
150
|
+
"w-[50%] h-[50%]": deviceListNum.value > 1 && deviceListNum.value <= 4,
|
|
151
|
+
"w-[33%] h-[33%]": deviceListNum.value > 4
|
|
152
|
+
}, "box-border"])
|
|
153
|
+
},
|
|
154
|
+
[
|
|
155
|
+
vue.createVNode(_component_HyUserAvatar, {
|
|
156
|
+
iconType: __props.iconType,
|
|
157
|
+
device: {
|
|
158
|
+
...item
|
|
159
|
+
},
|
|
160
|
+
class: "!w-full !h-full !border-0 !bg-background-3 !font-[100]",
|
|
161
|
+
ref_for: true,
|
|
162
|
+
ref: "userHeadPortraitRef"
|
|
163
|
+
}, null, 8, ["iconType", "device"])
|
|
164
|
+
],
|
|
165
|
+
2
|
|
166
|
+
/* CLASS */
|
|
167
|
+
);
|
|
168
|
+
}),
|
|
169
|
+
128
|
|
170
|
+
/* KEYED_FRAGMENT */
|
|
171
|
+
)),
|
|
172
|
+
__props.isBusy ? (vue.openBlock(), vue.createElementBlock("li", {
|
|
111
173
|
key: 0,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
174
|
+
class: "iconTypeBox bg-warning shadow-[0_0_4px_1px] !shadow-warning"
|
|
175
|
+
})) : vue.createCommentVNode("v-if", true)
|
|
176
|
+
])) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
177
|
+
key: 1,
|
|
178
|
+
class: "w-full h-full"
|
|
179
|
+
}, [
|
|
180
|
+
displayDevice.value.gbDevice === 1 && (displayDevice.value.deviceType || displayDevice.value.type) !== 13 ? (vue.openBlock(), vue.createElementBlock(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
key: 0,
|
|
184
|
+
style: vue.normalizeStyle(
|
|
185
|
+
displayDevice.value.onlineState === 1 ? "background:linear-gradient(180deg, #5A2120 0%, #C81F12 100%); color:#FDE777;" : "background:rgb(var(--hy-background-2), 1); color:rgb(var(--hy-auxiliary), 1);"
|
|
186
|
+
),
|
|
187
|
+
class: "headPortrait flex items-center justify-center overflow-hidden text-base"
|
|
188
|
+
},
|
|
189
|
+
" GB ",
|
|
190
|
+
4
|
|
191
|
+
/* STYLE */
|
|
192
|
+
)) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
115
193
|
key: 1,
|
|
116
|
-
"
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
194
|
+
class: "headPortrait flex items-center justify-center overflow-hidden"
|
|
195
|
+
}, [
|
|
196
|
+
displayDevice.value.headImg && !imgError.value ? (vue.openBlock(), vue.createElementBlock("img", {
|
|
197
|
+
key: 0,
|
|
198
|
+
src: displayDevice.value.headImg,
|
|
199
|
+
alt: displayDevice.value.name || vue.unref(useLocale.$t)("userAvatar.userAvatar"),
|
|
200
|
+
onError: ($event) => setImgError(true)
|
|
201
|
+
}, null, 40, ["src", "alt", "onError"])) : displayDevice.value.name ? (vue.openBlock(), vue.createElementBlock(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
key: 1,
|
|
205
|
+
class: "text-theme nameText"
|
|
206
|
+
},
|
|
207
|
+
vue.toDisplayString(displayDevice.value.name.slice(-2)),
|
|
208
|
+
1
|
|
209
|
+
/* TEXT */
|
|
210
|
+
)) : displayDevice.value.onlineState === 1 ? (vue.openBlock(), vue.createBlock(vue.unref(index.HyIcon), {
|
|
211
|
+
key: 2,
|
|
212
|
+
"svg-name": __props.initSelectSvgName,
|
|
213
|
+
class: "svgBox"
|
|
214
|
+
}, null, 8, ["svg-name"])) : (vue.openBlock(), vue.createBlock(vue.unref(index.HyIcon), {
|
|
215
|
+
key: 3,
|
|
216
|
+
"svg-name": __props.initSvgName,
|
|
217
|
+
class: "svgBox"
|
|
218
|
+
}, null, 8, ["svg-name"]))
|
|
219
|
+
])),
|
|
220
|
+
__props.iconType ? (vue.openBlock(), vue.createElementBlock(
|
|
221
|
+
"span",
|
|
222
|
+
{
|
|
223
|
+
key: 2,
|
|
224
|
+
class: vue.normalizeClass([
|
|
225
|
+
"iconTypeBox",
|
|
226
|
+
displayDevice.value.onlineState === 1 ? displayDevice.value.busy === 1 ? "bg-warning shadow-[0_0_4px_1px] !shadow-warning" : "bg-success shadow-[0_0_4px_1px] !shadow-success" : "bg-info"
|
|
227
|
+
])
|
|
228
|
+
},
|
|
229
|
+
null,
|
|
230
|
+
2
|
|
231
|
+
/* CLASS */
|
|
232
|
+
)) : vue.createCommentVNode("v-if", true),
|
|
233
|
+
__props.isBusy ? (vue.openBlock(), vue.createElementBlock("span", {
|
|
234
|
+
key: 3,
|
|
235
|
+
class: "iconTypeBox bg-warning shadow-[0_0_4px_1px] !shadow-warning"
|
|
236
|
+
})) : vue.createCommentVNode("v-if", true)
|
|
237
|
+
]))
|
|
134
238
|
],
|
|
135
239
|
4
|
|
136
240
|
/* STYLE */
|