qinyan пре 1 година
родитељ
комит
8e607cd38c

+ 2 - 6
src/components/AssetsList.tsx

@@ -1,4 +1,3 @@
-import { css } from "@linaria/core";
 import { List } from "@queenjs/ui";
 import { Empty, Pagination, Spin } from "ant-design-vue";
 import { defineUI } from "queenjs";
@@ -17,7 +16,7 @@ export default defineUI({
       const loading = control.state.loading;
 
       return (
-        <div class={styles}>
+        <div>
           {loading && (
             <div class="h-200px flex items-center justify-center">
               <Spin spinning tip="加载中"></Spin>
@@ -35,6 +34,7 @@ export default defineUI({
                 <Pagination
                   size="default"
                   hideOnSinglePage
+                  showSizeChanger={false}
                   pageSize={control.state.size}
                   total={control.state.total}
                   current={control.state.page}
@@ -48,7 +48,3 @@ export default defineUI({
     };
   },
 });
-
-const styles = css`
-  /*  */
-`;

+ 1 - 1
src/modules/editor/components/Viewport/Slider/SliderRight/CompTree.tsx

@@ -91,7 +91,7 @@ const CompNode = defineComponent({
       return (
         <div class={nodeStyle}>
           <Image src={thumbnail} size={240} />
-          <span class="flex-1">{props.title}</span>
+          <span class="w-0 flex-1 truncate">{props.title}</span>
           <span class="space-x-4px">
             {actions.map((action) =>
               action.getVisible.call(editor, comp) ? (

+ 1 - 1
src/modules/editor/controllers/CompUICtrl/index.ts

@@ -48,7 +48,7 @@ export class CompUICtrl extends ModuleControl<EditorModule> {
       });
     });
   }
-  private async initUserUI() {
+  async initUserUI() {
     const listCtrl = new PageListController<
       { _id: string; title: string; thumbnail: string },
       any

+ 1 - 0
src/modules/editor/module/actions/edit.ts

@@ -141,6 +141,7 @@ export const editActions = EditorModule.action({
       await this.controls.uploader.uploadBlobs(data);
       await this.https.createComp(data);
       queenApi.messageSuccess("保存成功");
+      this.controls.compUICtrl.initUserUI();
     } catch (error: any) {
       throw Exception.error(error.toString());
     } finally {

+ 14 - 22
src/modules/resource/actions/material.ts

@@ -3,29 +3,21 @@ import { ResourceModule } from "..";
 
 export const materialActions = ResourceModule.action({
   async uploadMaterial() {
-    const [blob] = await queenApi.selectFile({ accept: "image/*, video/*" });
-
-    // const url = URL.createObjectURL(blob);
-    // const data = { url, size: blob.size };
-    // await this.controls.uploader.uploadBlobs(data, {
-    //   createPathKey: this.helpers.createFileName,
-    // });
+    const files = await this.helper.uploadResource({
+      accept: "image/*, video/mp4",
+      multiple: true,
+    });
 
-    const data = await this.controls.uploader.uploadFile(blob, "queenshow");
+    let souceObj = files[0];
+    for (const key in files) {
+      souceObj = files[key];
+      await this.https.createResource(souceObj);
+    }
 
-    const souceObj = {
-      file: data,
-      fileType: blob.type.split("/")[0],
-      from: "upload",
+    this.controls.materialListCtrl.state.query = {
+      fileType: this.store.type,
     };
-    await this.https.createResource(souceObj);
-    // this.store.setSourceType(souceObj.fileType);
-
-    // this.controls.materialListCtrl.state.query = {
-    //   fileType: this.store.type,
-    // };
-    // this.controls.materialListCtrl.loadPage(1);
-
+    this.controls.materialListCtrl.loadPage(1);
     return souceObj;
   },
 
@@ -36,7 +28,7 @@ export const materialActions = ResourceModule.action({
     });
     if (!res) return;
     await this.https.deleteResource(record._id);
-    this.controls.materialListCtrl.fresh();
+    // this.controls.materialListCtrl.fresh();
   },
 
   downloadMaterial(record) {
@@ -45,7 +37,7 @@ export const materialActions = ResourceModule.action({
 
   async selectMaterial(record) {
     const _params = new URLSearchParams(decodeURIComponent(location.search));
-    const host = _params.get("host")
+    const host = _params.get("host");
 
     if (location.host == "www.infish.cn") {
       const url = `${location.origin}/projects/queenshow/index.html?host=${host}#/create/${record._id}`;

+ 40 - 31
src/modules/resource/helper.ts

@@ -32,40 +32,49 @@ export const helper = ResourceModule.helper({
     return ctrl;
   },
 
-  createSourceController() {
-    const { controls, actions } = this;
+  // createSourceController() {
+  //   const { controls, actions } = this;
 
-    const ctrl = new MaterialController();
-    ctrl.imageCtrl = controls.materialImageListCtrl;
-    ctrl.vidoeCtrl = controls.materialVideoListCtrl;
-    ctrl.taskCtrl = controls.renderTaskListCtrl;
-    ctrl.tplCtrl = controls.matTempListCtrl;
+  //   const ctrl = new MaterialController();
+  //   ctrl.imageCtrl = controls.materialImageListCtrl;
+  //   ctrl.vidoeCtrl = controls.materialVideoListCtrl;
+  //   ctrl.taskCtrl = controls.renderTaskListCtrl;
+  //   ctrl.tplCtrl = controls.matTempListCtrl;
 
-    ctrl.onBtnClick = async function (name: string) {
-      if (name == "upload") {
-        const uploaded = await actions.uploadMaterial();
-        ctrl.switchTab(uploaded.fileType, false);
-        ctrl.getCurrControl().loadPage(1);
-        return;
-      }
-      ctrl.showDialog(name);
-    };
-    ctrl.onItemClick = function (name, record) {
-      if (name == "delete") return actions.deleteMaterial(record);
-      return actions.downloadMaterial(record);
-    };
-    return ctrl;
-  },
+  //   ctrl.onBtnClick = async function (name: string) {
+  //     if (name == "upload") {
+  //       const uploaded = await actions.uploadMaterial();
+  //       ctrl.switchTab(uploaded.fileType, false);
+  //       ctrl.getCurrControl().loadPage(1);
+  //       return;
+  //     }
+  //     ctrl.showDialog(name);
+  //   };
+  //   ctrl.onItemClick = function (name, record) {
+  //     if (name == "delete") return actions.deleteMaterial(record);
+  //     return actions.downloadMaterial(record);
+  //   };
+  //   return ctrl;
+  // },
 
-  async uploadResource(accept = "image/*") {
-    const [blob] = await queenApi.selectFile({ accept });
-    const data = await this.controls.uploader.uploadFile(blob, "queenshow");
+  async uploadResource(opts?: { accept?: string; multiple?: boolean }) {
+    const result = [];
+    const blobs = await queenApi.selectFile(opts);
 
-    const souceObj = {
-      file: data,
-      fileType: blob.type.split("/")[0],
-      from: "upload",
-    };
-    return souceObj;
+    queenApi.showLoading("上传中……");
+
+    for (const key in blobs) {
+      const blob = blobs[key];
+      const file = await this.controls.uploader.uploadFile(blob, "queenshow");
+      const souceObj = {
+        file,
+        fileType: blob.type.split("/")[0],
+        from: "upload",
+      };
+      result.push(souceObj);
+    }
+    
+    queenApi.hideLoading();
+    return result;
   },
 });

+ 37 - 32
src/pages/website/Material2/components/Material.tsx

@@ -7,51 +7,56 @@ import { any } from "vue-types";
 import MaterialItem from "./MaterialItem";
 import Toolbar from "./MaterialToolbar";
 
-
 export default defineUI({
-    props: {
-        Controller: any<MaterialController>().isRequired,
-    },
-    slots: {
-        Toolbar,
-        AssetsList,
-        MaterialItem,
-    },
+  props: {
+    Controller: any<MaterialController>().isRequired,
+  },
+  slots: {
+    Toolbar,
+    AssetsList,
+    MaterialItem,
+  },
 
-    setup(props, { slots }) {
-        onMounted(() => {
-             props.Controller.getCurrControl().loadPage(1);
-        });
+  setup(props, { slots }) {
+    onMounted(() => {
+      props.Controller.getCurrControl().loadPage(1);
+    });
 
         return ()=>{
-            const state = props.Controller.state;
+      const state = props.Controller.state;
             const control = props.Controller.getCurrControl()
-            
-            return (<div class={rootStyles}>
-              {
-                !state.isSelect &&  <h3 class="text-22px">我的素材</h3>
-              }
 
-            <slots.Toolbar Controller={props.Controller} />
+      return (
+        <div class={rootStyles}>
+          {!state.isSelect && (
+            <div class="flex items-baseline">
+              <h3 class="text-22px m-0">我的素材</h3>
+              <span class="ml-5px text-gray-300 text-12px">
+                (图片支持jpg、png、gif、svg,不超过5M,视频支持mp4,不超过200M)
+              </span>
+            </div>
+          )}
+
+          <slots.Toolbar Controller={props.Controller} />
 
-            <slots.AssetsList
-              columns={6}
-              class="mt-30px"
-              control={control}
-              item={(record: any) => (
-                <slots.MaterialItem
-                  record={record}
+          <slots.AssetsList
+            columns={6}
+            class="mt-30px"
+            control={control}
+            item={(record: any) => (
+              <slots.MaterialItem
+                record={record}
                   use={ state.currTab == "task" ? "task" : (state.isSelect? "select": "show")}
-                  onDelete={() => props.Controller.onItemClick("delete", record)}
+                onDelete={() => props.Controller.onItemClick("delete", record)}
                   onDownload={() =>props.Controller.onItemClick("download", record)}
                   onUse={()=>props.Controller.onItemClick("use", record)}
                   onPreview={() =>props.Controller.onItemClick("preview", record)}
-                />
-              )}
-            />
+              />
+            )}
+          />
           </div>);
         }
-    },
+  },
 
 })
 

+ 6 - 2
src/pages/website/Material2/controller.tsx

@@ -55,8 +55,12 @@ export default function createController(resource:any, isSelectModel:boolean, se
       }
       showModal(name);
     };
-    ctrl.onItemClick = function (name, record) {
-      if (name == "delete") return actions.deleteMaterial(record);
+    ctrl.onItemClick = async function (name, record) {
+      if (name == "delete") {
+         await actions.deleteMaterial(record);
+         this.getCurrControl().fresh();
+         return;
+      }
       else if (name == "preview") return showPreviewModal({
         url: record.file.url,
         fileType: record.fileType,

+ 1 - 1
src/pages/website/Promotion2/components/ShareModal.tsx

@@ -60,7 +60,7 @@ export default defineComponent({
                   class="absolute left-0 bottom-0 w-1/1 text-center py-5px text-14px bg-dark-200 bg-opacity-80 cursor-pointer"
                   onClick={async () => {
                     const res: any = await controller.changeThumbnail();
-                    state.thumbnail = res?.file?.url;
+                    state.thumbnail = res[0]?.file?.url;
                   }}
                 >
                   更换封面