diff --git a/app.config.ts b/app.config.ts index 614fe62..17218a8 100644 --- a/app.config.ts +++ b/app.config.ts @@ -1,6 +1,6 @@ export default defineAppConfig({ ui: { - primary: 'green', + primary: 'indigo', gray: 'neutral', strategy: 'merge', button: { diff --git a/assets/css/tailwind.css b/assets/css/tailwind.css new file mode 100644 index 0000000..585aad5 --- /dev/null +++ b/assets/css/tailwind.css @@ -0,0 +1,9 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; + +@layer base { + html { + font-family: 'Rubik', 'Noto Sans SC', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, Noto Sans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji; + } +} diff --git a/components/aigc/drawing/ResultBlock.vue b/components/aigc/drawing/ResultBlock.vue index e95a43c..d34f801 100644 --- a/components/aigc/drawing/ResultBlock.vue +++ b/components/aigc/drawing/ResultBlock.vue @@ -2,6 +2,7 @@ import type {ResultBlockMeta} from '~/components/aigc/drawing/index'; import type {PropType} from 'vue'; import dayjs from 'dayjs'; +import {get} from 'idb-keyval'; const props = defineProps({ icon: { @@ -14,17 +15,62 @@ const props = defineProps({ prompt: { type: String, }, + fid: { + type: String, + required: true, + }, images: { type: Array, - default: (): Array => [], }, meta: { type: Object as PropType, }, }) +const toast = useToast() + const expand_prompt = ref(false) const show_meta = ref(true) + +const cachedImages = ref([]) +const cachedImagesInterval = ref(null) + +onMounted(async () => { + cachedImagesInterval.value = setInterval(async () => { + cachedImages.value = await get(props.fid) as string[] || [] + }, 1000) +}) + +onUnmounted(() => { + if (cachedImagesInterval.value) { + clearInterval(cachedImagesInterval.value) + } +}) + +const handle_download = (url: string) => { + const a = document.createElement('a') + a.href = url + a.download = `xsh_ai_drawing-${dayjs(props.meta?.datetime! * 1000).format('YYYY-MM-DD-HH-mm-ss')}.png` + a.click() +} + +const copyToClipboard = (text: string) => { + navigator.clipboard.writeText(text).then(() => { + toast.add({ + title: '复制成功', + description: '已将内容复制到剪贴板', + color: 'primary', + icon: 'i-tabler-copy', + }) + }).catch(() => { + toast.add({ + title: '复制失败', + description: '无法复制到剪贴板', + color: 'red', + icon: 'i-tabler-circle-x', + }) + }) +}