|
@@ -246,7 +246,7 @@ import { autoSave, delAttrs } from '@/services/common';
|
|
import { debounce, throttle } from '@/services/debouce';
|
|
import { debounce, throttle } from '@/services/debouce';
|
|
import { searchObjectPinyin } from '@/services/pinyin';
|
|
import { searchObjectPinyin } from '@/services/pinyin';
|
|
import { getCookie } from '@/services/cookie';
|
|
import { getCookie } from '@/services/cookie';
|
|
-
|
|
|
|
|
|
+import { parseSvg } from '@meta2d/svg'
|
|
import WechatPay from './WechatPay.vue';
|
|
import WechatPay from './WechatPay.vue';
|
|
import { filename } from '@/services/file';
|
|
import { filename } from '@/services/file';
|
|
import { useUser } from '@/services/user';
|
|
import { useUser } from '@/services/user';
|
|
@@ -1022,29 +1022,39 @@ const beforeUpload = (file: any) => {
|
|
};
|
|
};
|
|
|
|
|
|
const fileSuccessed = async (content: any) => {
|
|
const fileSuccessed = async (content: any) => {
|
|
|
|
+ let file = content.file.raw
|
|
const c: any = {
|
|
const c: any = {
|
|
name: filename(content.file.name),
|
|
name: filename(content.file.name),
|
|
image: content.response.url,
|
|
image: content.response.url,
|
|
folder: uploadGroup.name === '我的组件' ? '' : uploadGroup.name,
|
|
folder: uploadGroup.name === '我的组件' ? '' : uploadGroup.name,
|
|
};
|
|
};
|
|
-
|
|
|
|
- const ret: any = await addCollection('le5leV-components', c);
|
|
|
|
-
|
|
|
|
- if (ret && uploadGroup.name !== '我的组件') {
|
|
|
|
- c._id = ret._id || ret.id;
|
|
|
|
- if (!uploadGroup.list) {
|
|
|
|
- uploadGroup.list = [];
|
|
|
|
- }
|
|
|
|
- uploadGroup.list.push(c);
|
|
|
|
- await axios.post('/api/data/folders/update', {
|
|
|
|
- _id: uploadGroup._id || uploadGroup.id,
|
|
|
|
- list: uploadGroup.list,
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- if (!uploadGroup.list) {
|
|
|
|
- uploadGroup.list = [];
|
|
|
|
|
|
+ // 若是svg格式 则开启解析
|
|
|
|
+ if(content.file.name.endsWith('.svg')){
|
|
|
|
+ let fileReader = new FileReader()
|
|
|
|
+ fileReader.readAsText(file)
|
|
|
|
+ fileReader.onload = async ()=>{
|
|
|
|
+ let svgText = fileReader.result
|
|
|
|
+ c.componentDatas = parseSvg(svgText as string)
|
|
|
|
+ c.component = true
|
|
|
|
+ const ret: any = await addCollection('le5leV-components', c);
|
|
|
|
+
|
|
|
|
+ if (ret && uploadGroup.name !== '我的组件') {
|
|
|
|
+ c._id = ret._id || ret.id;
|
|
|
|
+ if (!uploadGroup.list) {
|
|
|
|
+ uploadGroup.list = [];
|
|
|
|
+ }
|
|
|
|
+ uploadGroup.list.push(c);
|
|
|
|
+ await axios.post('/api/data/folders/update', {
|
|
|
|
+ _id: uploadGroup._id || uploadGroup.id,
|
|
|
|
+ list: uploadGroup.list,
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ if (!uploadGroup.list) {
|
|
|
|
+ uploadGroup.list = [];
|
|
|
|
+ }
|
|
|
|
+ uploadGroup.list.push(c);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- uploadGroup.list.push(c);
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|