123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <template>
- <div class="preview-layer">
- <div class="pull-meta">
- <ResourceView :data="media.url" :type="media.type" />
- </div>
- </div>
- </template>
- <script lang="ts">
- import { ref, watchEffect, defineComponent, PropType } from "vue";
- import { getResource } from "@/env";
- import { MediaType } from "./index.vue";
- import ResourceView from "./resource.vue";
- import type { MediaItem } from "./index.vue";
- export const Preview = defineComponent({
- name: "static-preview",
- props: {
- media: {
- type: Object as PropType<MediaItem>,
- required: true,
- },
- },
- emits: {
- close: () => true,
- },
- setup(props) {
- const staticURL = ref("");
- watchEffect(() => {
- const data = props.media.url;
- const url =
- typeof data === "string" ? getResource(data) : URL.createObjectURL(data);
- staticURL.value = url;
- return () => URL.revokeObjectURL(url);
- });
- return {
- staticURL,
- MediaType,
- };
- },
- });
- export default Preview;
- </script>
- <style scoped lang="scss" src="./style.scss"></style>
|