|
@@ -4,18 +4,93 @@ import { Divider, Dropdown, Menu, Tag } from "ant-design-vue";
|
|
|
import { EyeOutlined } from "@ant-design/icons-vue";
|
|
|
import dayjs from "dayjs";
|
|
|
import { defineUI } from "queenjs";
|
|
|
-import { any, bool } from "vue-types";
|
|
|
+import { any, bool, object } from "vue-types";
|
|
|
import { useAuth } from "@queenjs-modules/auth";
|
|
|
import Thumbnail from "@/components/Thumbnail";
|
|
|
+import { reactive, defineComponent} from "vue";
|
|
|
|
|
|
+
|
|
|
+const VideoItem = defineComponent({
|
|
|
+ props: {
|
|
|
+ record: object<any>(),
|
|
|
+ },
|
|
|
+ emits: ["click"],
|
|
|
+ setup(props, { emit }) {
|
|
|
+ const state = reactive({
|
|
|
+ play: false,
|
|
|
+ });
|
|
|
+
|
|
|
+ return () => {
|
|
|
+ const { record } = props;
|
|
|
+ const { play } = state;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ style={{ aspectRatio: 1.5 }}
|
|
|
+ class="overflow-hidden cursor-pointer"
|
|
|
+ onMouseenter={() => (state.play = true)}
|
|
|
+ onMouseleave={() => (state.play = false)}
|
|
|
+ onClick={() => emit("click", record.file.url)}
|
|
|
+ >
|
|
|
+ {!play ? (
|
|
|
+ <Thumbnail
|
|
|
+ class="w-1/1 h-1/1"
|
|
|
+ size={240}
|
|
|
+ objectContain={false}
|
|
|
+ src={record.thumbnail}
|
|
|
+ />
|
|
|
+ ) : (
|
|
|
+ <video
|
|
|
+ muted
|
|
|
+ autoplay
|
|
|
+ controls={false}
|
|
|
+ src={record.file.url}
|
|
|
+ class="w-1/1 h-1/1 object-cover"
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ const ImageItem = defineComponent({
|
|
|
+ props: {
|
|
|
+ record: object<any>(),
|
|
|
+ },
|
|
|
+ emits: ["click"],
|
|
|
+ setup(props, { emit }) {
|
|
|
+ return () => {
|
|
|
+ const { record } = props;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Thumbnail
|
|
|
+ size={240}
|
|
|
+ class="draggable-item"
|
|
|
+ style={{ aspectRatio: 1 }}
|
|
|
+ onClick={() => emit("click", record.file.url)}
|
|
|
+ objectContain={true}
|
|
|
+ src={record.file.url}
|
|
|
+ />
|
|
|
+ );
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
export default defineUI({
|
|
|
props: {
|
|
|
record: any(),
|
|
|
tagable: bool().def(false),
|
|
|
+ isVideo: bool().def(false),
|
|
|
},
|
|
|
emits: ["edit", "preview", "menu", "click"],
|
|
|
setup(props, { emit }) {
|
|
|
const auth = useAuth();
|
|
|
+ const state = reactive({
|
|
|
+ play: false,
|
|
|
+ });
|
|
|
+
|
|
|
|
|
|
return () => {
|
|
|
const { record } = props;
|
|
@@ -25,16 +100,10 @@ export default defineUI({
|
|
|
|
|
|
return (
|
|
|
<div class={cx(itemStyles, "relative")}>
|
|
|
- <Thumbnail
|
|
|
- size={240}
|
|
|
- class="draggable-item"
|
|
|
- style={{ aspectRatio: 1 }}
|
|
|
- onClick={() => emit("click")}
|
|
|
- objectContain={record.fileType == "image" ? true : false}
|
|
|
- src={
|
|
|
- record.fileType == "video" ? record.thumbnail : record.file.url
|
|
|
- }
|
|
|
- />
|
|
|
+ {
|
|
|
+ props.isVideo ? <VideoItem record={props.record} /> : <ImageItem record={props.record} />
|
|
|
+ }
|
|
|
+
|
|
|
{isSys && props.tagable && (
|
|
|
<Tag
|
|
|
color={record.published? "green": "#E88B00" }
|