From 75f431d7bf3579105f3a39d8c1ff7a549296e77c Mon Sep 17 00:00:00 2001 From: HoshinoSuzumi Date: Wed, 20 Mar 2024 18:00:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=98=E7=94=BB=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=9B=BE=E7=89=87=E5=AD=98=E5=82=A8=E4=BC=98?= =?UTF-8?q?=E5=8C=96=20ui:=20=E4=BC=98=E5=8C=96=E5=AD=97=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.config.ts | 2 +- assets/css/tailwind.css | 9 +++ components/aigc/drawing/ResultBlock.vue | 75 +++++++++++++++++++++++-- composables/useHistory.ts | 3 +- nuxt.config.ts | 57 ++++++++++--------- package.json | 2 + pages/aigc/drawing/index.vue | 42 +++++++++----- tailwind.config.ts | 24 ++++---- yarn.lock | 26 ++++++++- 9 files changed, 181 insertions(+), 59 deletions(-) create mode 100644 assets/css/tailwind.css 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', + }) + }) +}