Kaynağa Gözat

del render image

bianjiang 1 yıl önce
ebeveyn
işleme
95ce13df76

+ 2 - 2
src/comm/controllers/ProjectCtrl/index.ts

@@ -58,7 +58,7 @@ export class ProjectController extends Controller {
   async onReady() {
     const params = new URLSearchParams(location.search);
     const projectPath = params.get("id") as string;
-    this.RootDir = projectPath;
+    this.RootDir = decodeURI(projectPath);
     const deviceCtrl = useCtx().deviceCtrl;
 
     deviceCtrl.GetAppDataDir().then((dir: any) => {
@@ -174,7 +174,7 @@ export class ProjectController extends Controller {
   getRelativeUri(url: string) {
     let s = this.HostURL.length;
     let pre = url.substring(0, s);
-    if (pre == this.HostURL) return url.substring(s + 1);
+    if (pre == this.HostURL) return url.substring(s);
 
     s = this.RootDir.length;
     pre = url.substring(0, s);

+ 25 - 6
src/modules/editor/components/Viewport/Slider/SliderLeft/RenderImage.tsx

@@ -6,6 +6,7 @@ import Empty from "@/components/Empty";
 import { useEditor } from "@/modules/editor";
 import { nanoid } from "nanoid";
 import SourceItem from "./Sources/SourceItem";
+import { queenApi } from "queenjs";
 export default defineComponent({
   setup(props) {
     const editor = useEditor();
@@ -15,7 +16,7 @@ export default defineComponent({
       renderImages: [] as any,
     });
     const ctx = useCtx();
-    function clickToDesign(url: string) {  
+    function clickToDesign(url: string) {
       editor.actions.addImageToDesign(url);
     }
 
@@ -41,7 +42,28 @@ export default defineComponent({
             });
         });
     }
+    const deleteImage = async (index: number) => {
+      await queenApi.showConfirm({
+        title: "删除提示",
+        content: "确认删除当前渲染图?",
+        type: "danger",
+      });
+      const ctx = useCtx();
+      const relaUrl = ctx.prjCtrl.getRelativeUri(
+        state.renderImages[index].file.url
+      );
+      const fpath = ctx.prjCtrl.getLocalAbsoluteUri(relaUrl);
+      const ok = await ctx.deviceCtrl.RemoveFile(fpath);
+      if (!ok) {
+        queenApi.messageError("删除失败");
+        return;
+      }
+      let s = state.renderImages;
+      s.splice(index, 1);
+      state.renderImages = s;
 
+      queenApi.messageSuccess("删除成功");
+    };
     onMounted(() => getData());
 
     return () => {
@@ -62,7 +84,7 @@ export default defineComponent({
               };
             }}
           >
-            {dataSource.map((item: any) => (
+            {dataSource.map((item: any, index: number) => (
               <Draggable key={item._id}>
                 <SourceItem
                   class="draggable-item cursor-pointer"
@@ -74,10 +96,7 @@ export default defineComponent({
                   onMenu={async (name) => {
                     console.log(name);
                     if (name == "delete") {
-                      //   await resource.actions.deleteMaterial(item);
-                      //   control.loadPage(1);
-                      //   queenApi.messageSuccess("删除成功!");
-                      //   return;
+                      deleteImage(index);
                     }
                   }}
                 />

+ 1 - 1
src/modules/editor/module/actions/edit.tsx

@@ -569,7 +569,7 @@ export const editActions = EditorModule.action({
   async removeStreamCard(compId: string) {
     const ctrl = this.controls.pageCtrl;
 
-    await queenApi.showConfirm({ title: "删除", content: "确认删除当前页面?" });
+    await queenApi.showConfirm({ title: "删除提示", content: "确认删除当前页面?" });
 
     let nextCard = ctrl.currStreamCardId;
     if (compId == ctrl.currStreamCardId) {

+ 2 - 0
src/modules/resource/actions/collection.tsx

@@ -4,6 +4,7 @@ import { ResourceModule } from "..";
 export const collectionAction = ResourceModule.action({
   async deleteCollection(record: any) {
     const res = await queenApi.showConfirm({
+      title:"删除提示",
       content: `删除后无法恢复,确定要删除:${record.title}?`,
       type: "danger",
     });
@@ -82,6 +83,7 @@ export const collectionAction = ResourceModule.action({
   },
   async deleteCommitData(record: any) {
     const res = await queenApi.showConfirm({
+      title:"删除提示",
       content: `删除后无法恢复,确定要删除:${record.title}?`,
       type: "danger",
     });

+ 1 - 0
src/modules/resource/actions/material.ts

@@ -36,6 +36,7 @@ export const materialActions = ResourceModule.action({
 
   async deleteMaterial(record) {
     const res = await queenApi.showConfirm({
+      title:"删除提示",
       content: `删除后不可恢复,是否要删除此素材?`,
       type: "danger",
     });

+ 4 - 0
src/modules/resource/actions/promotion.tsx

@@ -20,6 +20,7 @@ export const promotionAction = ResourceModule.action({
 
   async deletePromotion(record: any) {
     const res = await queenApi.showConfirm({
+      title:"删除提示",
       content: `删除后无法恢复,确定要删除:${record.title}?`,
       type: "danger",
     });
@@ -30,6 +31,7 @@ export const promotionAction = ResourceModule.action({
 
   async deleteCustomComp(record: any) {
     const res = await queenApi.showConfirm({
+      title:"删除提示",
       content: `删除后无法恢复,确定要删除当前组合?`,
       type: "danger",
     });
@@ -38,6 +40,7 @@ export const promotionAction = ResourceModule.action({
   },
   async deleteUserComp(record: any, title: string) {
     const res = await queenApi.showConfirm({
+      title:"删除提示",
       content: `删除后无法恢复,确定要删除当前${title}:${record.title}?`,
       type: "danger",
     });
@@ -114,6 +117,7 @@ export const promotionAction = ResourceModule.action({
 
   async deleteComp(record: any) {
     const res = await queenApi.showConfirm({
+      title:"删除提示",
       content: `删除后无法恢复,确定要删除:${record.title}?`,
       type: "danger",
     });