index.ts
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import '@/views/operation/notification/module/user-card';
import '@/views/operation/notification/module/project-card';
import '@/views/operation/notification/module/activity-card';
import '@wangeditor/editor/dist/css/style.css';
import { Boot } from '@wangeditor/editor';
import useOss from '@/hooks/oss';
type InsertImageFnType = (url: string, alt: string, href: string) => void;
type InsertVideoFnType = (url: string, poster: string) => void;
Boot.setToolbarConfig({
excludeKeys: ['fullScreen', 'codeBlock', 'undo', 'redo'],
insertKeys: { index: 30, keys: ['user-card', 'activity-card', 'project-card'] },
});
Boot.setEditorConfig({
MENU_CONF: {
uploadImage: {
allowedFileTypes: ['image/*'],
async customUpload(file: File, insertFn: InsertImageFnType) {
return useOss()
.upload(file, 'image')
.then(({ name, url }) => insertFn(url, name, url));
},
},
uploadVideo: {
allowedFileTypes: ['video/*'],
maxNumberOfFiles: 1,
maxFileSize: 1024 * 1024 * 1024,
timeout: 60 * 1000,
async customUpload(file: File, insertFn: InsertVideoFnType) {
return useOss()
.upload(file, 'video')
.then(({ url }) => insertFn(url, `${url}?x-oss-process=video/snapshot,t_1000,f_png`));
},
},
},
});