|
@@ -1,14 +1,16 @@
|
|
|
-import { css, cx } from "@linaria/core";
|
|
|
-import { defineComponent, onMounted } from "vue";
|
|
|
-import { any } from "vue-types";
|
|
|
import List from "@/components/AssetsList";
|
|
|
-import { PageListController } from "@queenjs/controllers";
|
|
|
-import { defineUI } from "queenjs";
|
|
|
+import { useEditor } from "@/modules/editor";
|
|
|
+import { EyeOutlined } from "@ant-design/icons-vue";
|
|
|
+import { css, cx } from "@linaria/core";
|
|
|
+import { IconMore } from "@queenjs/icons";
|
|
|
import { Image, View } from "@queenjs/ui";
|
|
|
-import { useResource } from "..";
|
|
|
+import { Divider, Dropdown, Menu, Select } from "ant-design-vue";
|
|
|
import dayjs from "dayjs";
|
|
|
-import { useEditor } from "@/modules/editor";
|
|
|
-import { Select } from "ant-design-vue";
|
|
|
+import { defineUI } from "queenjs";
|
|
|
+import { defineComponent, onMounted } from "vue";
|
|
|
+import { any } from "vue-types";
|
|
|
+import { useResource } from "../../";
|
|
|
+import { InnerListController } from "./innerListController";
|
|
|
export default defineComponent({
|
|
|
props: {
|
|
|
record: any(),
|
|
@@ -16,34 +18,12 @@ export default defineComponent({
|
|
|
setup(props, { emit }) {
|
|
|
const resource = useResource();
|
|
|
const editor = useEditor();
|
|
|
- const ListCtrl = new PageListController(resource.config?.httpConfig);
|
|
|
- ListCtrl.setCrudPrefix("/wk/h5");
|
|
|
- ListCtrl.state.query = { id: props.record._id };
|
|
|
+ const ctrl = InnerListController(resource, editor);
|
|
|
+
|
|
|
+ ctrl.ListCtrl.state.query = { id: props.record._id };
|
|
|
onMounted(() => {
|
|
|
- ListCtrl.loadPage(1);
|
|
|
+ ctrl.ListCtrl.loadPage(1);
|
|
|
});
|
|
|
- const previewInModal = async (id: string, title: string) => {
|
|
|
- if (!id) {
|
|
|
- return;
|
|
|
- }
|
|
|
- const ret = await resource.actions.getCommitHistoryDetail(id);
|
|
|
- if (!ret) {
|
|
|
- return;
|
|
|
- }
|
|
|
- editor.store.setDesignData(ret);
|
|
|
- editor.actions.switchMode("preview");
|
|
|
- resource.showModal(
|
|
|
- <div class={"!p-0"}>
|
|
|
- <div class={"h-600px scrollbar"}>
|
|
|
- <editor.components.Preview class="pointer-events-none" />
|
|
|
- </div>
|
|
|
- </div>,
|
|
|
- {
|
|
|
- title: title,
|
|
|
- destroyOnClose: true,
|
|
|
- }
|
|
|
- );
|
|
|
- };
|
|
|
|
|
|
return () => {
|
|
|
return (
|
|
@@ -52,17 +32,16 @@ export default defineComponent({
|
|
|
gap="24px"
|
|
|
class={"p-24px h-full scrollbar"}
|
|
|
columns={6}
|
|
|
- control={ListCtrl}
|
|
|
+ control={ctrl.ListCtrl}
|
|
|
item={(item: any) => (
|
|
|
<ListItem
|
|
|
item={item}
|
|
|
record={props.record}
|
|
|
- onPreview={(id, title) => {
|
|
|
- previewInModal(id, title);
|
|
|
+ onMenu={(menu: string, item: any) => {
|
|
|
+ ctrl.onMenuClick(menu, item);
|
|
|
}}
|
|
|
- onEdit={async (record) => {
|
|
|
- await resource.actions.updateCommitData(record);
|
|
|
- ListCtrl.fresh();
|
|
|
+ onEdit={async (id: string) => {
|
|
|
+ ctrl.onEdit(id);
|
|
|
}}
|
|
|
/>
|
|
|
)}
|
|
@@ -77,7 +56,7 @@ const ListItem = defineUI({
|
|
|
item: any(),
|
|
|
record: any(),
|
|
|
},
|
|
|
- emits: ["edit", "preview"],
|
|
|
+ emits: ["edit", "preview", "menu"],
|
|
|
setup(props, { emit }) {
|
|
|
return () => {
|
|
|
const { item, record } = props;
|
|
@@ -96,9 +75,15 @@ const ListItem = defineUI({
|
|
|
<div class="absolute inset-0 flex items-center justify-center opacity-0 hover:opacity-100 transition-opacity">
|
|
|
<div
|
|
|
class="text-white icon_action w-60px leading-60px orange cursor-pointer rounded-1/2 text-center transition-opacity hover:opacity-90 active:opacity-80"
|
|
|
- onClick={() => emit("preview", wks.id, h5?.title)}
|
|
|
+ onClick={() => emit("edit", wks.id)}
|
|
|
+ >
|
|
|
+ 编辑
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="text-white icon_action w-60px ml-10px leading-60px cursor-pointer rounded-1/2 text-center transition-opacity hover:opacity-90 active:opacity-80"
|
|
|
+ onClick={() => emit("menu", "share", wks.id)}
|
|
|
>
|
|
|
- 查看
|
|
|
+ 分享
|
|
|
</div>
|
|
|
</div>
|
|
|
{record.flags && record.flags.length > 0 && (
|
|
@@ -109,7 +94,7 @@ const ListItem = defineUI({
|
|
|
options={options}
|
|
|
onChange={(v) => {
|
|
|
wks.flag = v;
|
|
|
- emit("edit", {
|
|
|
+ emit("menu", "changeFlag", {
|
|
|
id: record._id,
|
|
|
wkId: wks.id,
|
|
|
flag: wks.flag,
|
|
@@ -124,8 +109,32 @@ const ListItem = defineUI({
|
|
|
<div class="text-white text-bold truncate">{h5?.title}</div>
|
|
|
<div class="flex items-center text-opacity-60 text-white text-12px mt-5px">
|
|
|
{dayjs(wks.commitTime).format("YYYY.MM.DD")} 提交
|
|
|
+ <Divider type="vertical"></Divider>
|
|
|
+ {h5.views || 0} <EyeOutlined class={"ml-6px"} />
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <Dropdown
|
|
|
+ placement="bottom"
|
|
|
+ overlay={
|
|
|
+ <Menu class="w-90px">
|
|
|
+ <Menu.Item>
|
|
|
+ <div
|
|
|
+ onClick={() =>
|
|
|
+ emit("menu", "delete", {
|
|
|
+ title: h5?.title,
|
|
|
+ worksId: wks.id,
|
|
|
+ id: record._id,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </div>
|
|
|
+ </Menu.Item>
|
|
|
+ </Menu>
|
|
|
+ }
|
|
|
+ >
|
|
|
+ <IconMore class="ml-10px text-22px cursor-pointer" />
|
|
|
+ </Dropdown>
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|