|
@@ -46,6 +46,7 @@
|
|
|
import { onMounted, onUnmounted, reactive, ref, watch } from "vue";
|
|
|
import { shapeLib, chartLib, formLib } from "@/services/defaults";
|
|
|
import { getPngFolders, getPngs } from "@/services/png";
|
|
|
+import { getIconFolders, getIcons } from "@/services/icons";
|
|
|
import { getComponents, getComponentsList } from "@/services/api";
|
|
|
import { convertPen } from "@/services/upgrade";
|
|
|
import { deepClone } from "@meta2d/core";
|
|
@@ -134,12 +135,20 @@ const getCommponentsLib = async () => {
|
|
|
};
|
|
|
|
|
|
const getMaterialLib = async () => {
|
|
|
- const [pngs] = await Promise.all([getPngFolders()]);
|
|
|
+ const pngs = await getPngFolders();
|
|
|
console.log("png", pngs);
|
|
|
return pngs;
|
|
|
};
|
|
|
let materialLib: any[] = [];
|
|
|
|
|
|
+const getIconsLib = async () => {
|
|
|
+ const icons = await getIconFolders();
|
|
|
+ console.log(icons);
|
|
|
+ return icons;
|
|
|
+};
|
|
|
+
|
|
|
+let iconsLib: any[] = [];
|
|
|
+
|
|
|
const groupChange = async (name: string) => {
|
|
|
panelValue.value = [];
|
|
|
activeGroup.value = name;
|
|
@@ -165,7 +174,10 @@ const groupChange = async (name: string) => {
|
|
|
showList.value = materialLib;
|
|
|
break;
|
|
|
case "图标":
|
|
|
- showList.value = [];
|
|
|
+ if (iconsLib.length === 0) {
|
|
|
+ iconsLib = await getIconsLib();
|
|
|
+ }
|
|
|
+ showList.value = iconsLib;
|
|
|
break;
|
|
|
case "图形":
|
|
|
showList.value = shapeLib;
|
|
@@ -181,6 +193,7 @@ const showList = ref<any[]>([]);
|
|
|
const showType = ref(0);
|
|
|
const panelValue = ref([]);
|
|
|
const handlePanelChange = (e: any) => {
|
|
|
+ console.log("e", e);
|
|
|
// console.log("change", e,panelValue.value);
|
|
|
// if (activeGroup.value === '素材') {
|
|
|
// const data:any = materialLib[e[0]];
|
|
@@ -194,6 +207,7 @@ const handlePanelChange = (e: any) => {
|
|
|
watch(
|
|
|
() => panelValue.value,
|
|
|
async (newV: any[], oldV: any[]) => {
|
|
|
+ console.log(newV, oldV);
|
|
|
const newOpen: any = [];
|
|
|
for (let v of newV) {
|
|
|
!oldV.includes(v) && newOpen.push(v);
|
|
@@ -212,6 +226,14 @@ watch(
|
|
|
console.log(materialLib);
|
|
|
showList.value = deepClone(materialLib);
|
|
|
}
|
|
|
+ } else if (activeGroup.value === "图标") {
|
|
|
+ const data: any = iconsLib[newOpen[0]];
|
|
|
+ if (!data.list || data.list.length === 0) {
|
|
|
+ data.list = await getIcons(
|
|
|
+ globalThis.folderJson ? data.pinyin : data.name
|
|
|
+ );
|
|
|
+ showList.value = deepClone(iconsLib);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
);
|
|
@@ -273,6 +295,13 @@ const dragend = (event: any) => {
|
|
|
event.target.style.opacity = 1;
|
|
|
};
|
|
|
|
|
|
+//获取所有图形库
|
|
|
+const getGraphics = async () => {
|
|
|
+ // if (!materialLib.length) {
|
|
|
+ // materialLib = await getPngFolders();
|
|
|
+ // }
|
|
|
+};
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
groupChange("图形");
|
|
|
document.removeEventListener("dragstart", dragstart);
|
|
@@ -369,6 +398,10 @@ onUnmounted(() => {
|
|
|
height: 32px;
|
|
|
width: 32px;
|
|
|
background: #fff0;
|
|
|
+ :deep(.t-image) {
|
|
|
+ background-color: #fff;
|
|
|
+ border-radius: 2px;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/* i {
|
|
@@ -378,10 +411,6 @@ onUnmounted(() => {
|
|
|
width: 40px;
|
|
|
margin: 10px;
|
|
|
} */
|
|
|
- .t-image {
|
|
|
- background-color: #fff;
|
|
|
- border-radius: 4px;
|
|
|
- }
|
|
|
|
|
|
svg {
|
|
|
color: var(--color);
|