free-fe-core-modules 0.1.20 → 0.1.22
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/free-field/Fields/AgreementCheck.js +4 -0
- package/free-field/Fields/File.vue +1 -1
- package/free-field/Fields/FileList.vue +1 -1
- package/free-field/Fields/Image.vue +1 -1
- package/free-field/Fields/ImageList.vue +1 -1
- package/free-field/Fields/Rich.vue +47 -0
- package/free-field/composible/useUploader.js +10 -1
- package/package.json +1 -1
|
@@ -26,6 +26,10 @@ export default defineComponent({
|
|
|
26
26
|
|
|
27
27
|
const { proxy:vm } = getCurrentInstance();
|
|
28
28
|
const { fieldData, setFieldData } = useFreeField(props);
|
|
29
|
+
if (fieldData.value === void 0) {
|
|
30
|
+
setFieldData(false, emit);
|
|
31
|
+
}
|
|
32
|
+
|
|
29
33
|
const hasError = ref(false);
|
|
30
34
|
|
|
31
35
|
const fieldTip = (tip) => {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
|
|
52
52
|
<div v-else-if="!!fieldData.value?.id" class="file-list row items-start justify-start">
|
|
53
53
|
<q-card flat class="file-list-item">
|
|
54
|
-
<e-icon class="file-image" :name="fileThumb(fieldData.value)" thumb
|
|
54
|
+
<e-icon class="file-image" :name="fileThumb(fieldData.value, ctx)" thumb
|
|
55
55
|
:relative="filePreviewType(fieldData.value) !== 'image'" @click="preview(fieldData.value)">
|
|
56
56
|
<div class="view-btn-wrapper absolute-full justify-center text-center">
|
|
57
57
|
<q-btn flat class="view-btn full-height full-width">查看</q-btn>
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
<div v-if="Array.isArray(allFiles) && allFiles.length"
|
|
78
78
|
class="file-list file-list-card row items-start justify-start q-gutter-xl">
|
|
79
79
|
<q-card flat class="file-list-item" v-for="(file, index) in allFiles || []" :key="index">
|
|
80
|
-
<e-icon class="file-image" :name="fileThumb(file)" thumb :relative="filePreviewType(file) !== 'image'"
|
|
80
|
+
<e-icon class="file-image" :name="fileThumb(file, ctx)" thumb :relative="filePreviewType(file) !== 'image'"
|
|
81
81
|
@click="preview(file)">
|
|
82
82
|
<div class="view-btn-wrapper absolute-full justify-center text-center">
|
|
83
83
|
<q-btn flat class="view-btn full-height full-width">查看</q-btn>
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
|
|
62
62
|
<div v-else-if="fieldData.value?.id" class="file-list row items-start justify-start">
|
|
63
63
|
<q-card flat class="file-list-item">
|
|
64
|
-
<e-icon class="file-image" :name="fileThumb(fieldData.value)" :thumb="!Field?.Options?.NoThumb"
|
|
64
|
+
<e-icon class="file-image" :name="fileThumb(fieldData.value, ctx)" :thumb="!Field?.Options?.NoThumb"
|
|
65
65
|
:relative="filePreviewType(fieldData.value) !== 'image'" @click="preview(fieldData.value)">
|
|
66
66
|
<div class="view-btn-wrapper absolute-full justify-center text-center">
|
|
67
67
|
<q-btn flat class="view-btn full-height full-width" @click="preview(fieldData.value)">查看</q-btn>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
<div v-if="Array.isArray(allFiles) && allFiles.length"
|
|
28
28
|
class="file-list row items-start justify-start q-gutter-xl">
|
|
29
29
|
<q-card flat class="file-list-item" v-for="(file, index) in allFiles" :key="index">
|
|
30
|
-
<e-icon class="file-image" :name="fileThumb(file)" thumb :relative="filePreviewType(file) !== 'image'"
|
|
30
|
+
<e-icon class="file-image" :name="fileThumb(file, ctx)" thumb :relative="filePreviewType(file) !== 'image'"
|
|
31
31
|
@click="preview(file)">
|
|
32
32
|
<div class="view-btn-wrapper absolute-full justify-center text-center">
|
|
33
33
|
<q-btn flat class="view-btn full-height full-width" @click="preview(file)">查看</q-btn>
|
|
@@ -273,6 +273,48 @@ export default defineComponent({
|
|
|
273
273
|
return isVal;
|
|
274
274
|
};
|
|
275
275
|
|
|
276
|
+
const handleVideoUpload = (file, editor) => {
|
|
277
|
+
const formData = new FormData();
|
|
278
|
+
formData.append('file', file, file.name || 'pasted-video');
|
|
279
|
+
|
|
280
|
+
vm.postRequest('/upload', formData, {
|
|
281
|
+
__ignoreDecycle: true,
|
|
282
|
+
headers: {
|
|
283
|
+
'Content-Type': 'multipart/form-data',
|
|
284
|
+
},
|
|
285
|
+
}).then((res) => {
|
|
286
|
+
if (res && res.data && res.data.id) {
|
|
287
|
+
const videoUrl = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}${vm.ctx.config.videoUrlBase}${res.data.id}${props.Field.Options?.UploadedImageUrlArgs || ''}`;
|
|
288
|
+
|
|
289
|
+
// 插入视频元素到编辑器
|
|
290
|
+
editor.insertContent(`
|
|
291
|
+
<div class="video-container" style="margin: 10px 0;">
|
|
292
|
+
<video src="${videoUrl}" controls style="max-width: 100%; height: auto;">
|
|
293
|
+
您的浏览器不支持视频播放
|
|
294
|
+
</video>
|
|
295
|
+
</div>
|
|
296
|
+
`);
|
|
297
|
+
}
|
|
298
|
+
}).catch(() => {
|
|
299
|
+
});
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const paste_preprocess = (editor, args) => {
|
|
303
|
+
const items = args.clipboardData.items;
|
|
304
|
+
|
|
305
|
+
for (let i = 0; i < items.length; i++) {
|
|
306
|
+
const item = items[i];
|
|
307
|
+
|
|
308
|
+
// 检查是否为视频文件
|
|
309
|
+
if (item.kind === 'file' && item.type.startsWith('video/')) {
|
|
310
|
+
const file = item.getAsFile();
|
|
311
|
+
|
|
312
|
+
// 处理视频上传
|
|
313
|
+
handleVideoUpload(file, editor);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
|
|
276
318
|
const tinySetup = (editor) => {
|
|
277
319
|
// add button for indent 2ems
|
|
278
320
|
editor.on('init', () => {
|
|
@@ -331,6 +373,11 @@ export default defineComponent({
|
|
|
331
373
|
}
|
|
332
374
|
});
|
|
333
375
|
}
|
|
376
|
+
|
|
377
|
+
// 处理粘贴视频文件
|
|
378
|
+
editor.on('paste', (e) => {
|
|
379
|
+
paste_preprocess(editor, e);
|
|
380
|
+
});
|
|
334
381
|
};
|
|
335
382
|
|
|
336
383
|
const tinyChanged = (v) => {
|
|
@@ -158,10 +158,19 @@ export function useUploader(props) {
|
|
|
158
158
|
return typeList.join(',');
|
|
159
159
|
});
|
|
160
160
|
|
|
161
|
-
const fileThumb = computed(() => (file) => {
|
|
161
|
+
const fileThumb = computed(() => (file, app) => {
|
|
162
162
|
const unknownType = 'insert_drive_file';
|
|
163
163
|
if (!file) return unknownType;
|
|
164
164
|
|
|
165
|
+
if (app?.config?.['core-modules']?.fileTypeIconMap) {
|
|
166
|
+
const { fType, fExt } = _getFileType(file);
|
|
167
|
+
const key = `${fType}.${fExt}`;
|
|
168
|
+
const icon = app.config['core-modules'].fileTypeIconMap[key];
|
|
169
|
+
if (icon) {
|
|
170
|
+
return icon;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
165
174
|
let type = '';
|
|
166
175
|
// const fTypes = file.type.split('/');
|
|
167
176
|
// const [fType, fExt] = fTypes;
|