From c3dee857b42553361b9eadd4666b3269287420ac Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Mon, 5 Feb 2024 01:09:09 +0800 Subject: [PATCH 01/14] feat: add footer copyright --- README.md | 14 +++++++++++--- components/AiPrompt.vue | 4 ++++ components/BaseFooter.vue | 8 ++++++++ components/Footer.vue | 6 ------ components/SimpleCopyright.vue | 26 ++++++++++++++++++++++++++ components/SpringFestivalCouplets.vue | 2 +- nuxt.config.ts | 3 ++- package.json | 3 +++ pages/index.vue | 2 ++ uno.config.ts | 2 +- 10 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 components/BaseFooter.vue delete mode 100644 components/Footer.vue create mode 100644 components/SimpleCopyright.vue diff --git a/README.md b/README.md index cfe7ceb..a329e70 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,19 @@ # AI Couplets - AI 对联/春联 -## Todo - -- [ ] 分享春联 +Powered by [DeepSeek 开发平台](https://platform.deepseek.com/). ## Dev +### Config API Key + +```bash +cp .env.example .env + +# .env +# you can get free tokens from https://platform.deepseek.com/ +OPENAI_API_KEY=your_deepseek_api_key +``` + ```bash pnpm i pnpm dev diff --git a/components/AiPrompt.vue b/components/AiPrompt.vue index 66625f2..09ffd4a 100644 --- a/components/AiPrompt.vue +++ b/components/AiPrompt.vue @@ -3,6 +3,9 @@ import consola from 'consola' const app = useAppStore() +/** + * generate sfc 春联 + */ async function generate() { app.loading = true const data = await $fetch('/api/generate', { @@ -30,6 +33,7 @@ async function generate() { class="font-zmx w-full btn" text="black 2xl" :class="{ 'btn-disabled': app.loading }" flex items-center justify-center + :disabled="app.loading" @click="generate" > {{ app.loading ? '生成中...' : '生成春联' }} diff --git a/components/BaseFooter.vue b/components/BaseFooter.vue new file mode 100644 index 0000000..1b67150 --- /dev/null +++ b/components/BaseFooter.vue @@ -0,0 +1,8 @@ + diff --git a/components/Footer.vue b/components/Footer.vue deleted file mode 100644 index a5a221e..0000000 --- a/components/Footer.vue +++ /dev/null @@ -1,6 +0,0 @@ - diff --git a/components/SimpleCopyright.vue b/components/SimpleCopyright.vue new file mode 100644 index 0000000..2699d79 --- /dev/null +++ b/components/SimpleCopyright.vue @@ -0,0 +1,26 @@ + + + diff --git a/components/SpringFestivalCouplets.vue b/components/SpringFestivalCouplets.vue index fecd934..07eb75f 100644 --- a/components/SpringFestivalCouplets.vue +++ b/components/SpringFestivalCouplets.vue @@ -112,7 +112,7 @@ async function shareLink() { -
+
diff --git a/nuxt.config.ts b/nuxt.config.ts index b556893..756bc4c 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -47,7 +47,8 @@ export default defineNuxtConfig({ app: { head: { - viewport: 'width=device-width,initial-scale=1', + // no scale + viewport: 'width=device-width,initial-scale=1,user-scalable=no', // // // diff --git a/package.json b/package.json index b1c5fe4..e6df7d5 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,9 @@ "type": "module", "private": true, "packageManager": "pnpm@8.15.1", + "repository": { + "url": "https://github.com/YunYouJun/ai-sfc" + }, "scripts": { "build": "nuxi build", "dev:pwa": "VITE_PLUGIN_PWA=true nuxi dev", diff --git a/pages/index.vue b/pages/index.vue index ee722dc..f520331 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -27,5 +27,7 @@ const app = useAppStore()
+ +
diff --git a/uno.config.ts b/uno.config.ts index 0db2143..8493678 100644 --- a/uno.config.ts +++ b/uno.config.ts @@ -11,7 +11,7 @@ import { export default defineConfig({ shortcuts: [ - ['btn', 'text-xl px-4 py-2 rounded inline-block bg-yellow-500 text-white cursor-pointer active:bg-yellow-600 disabled:cursor-default disabled:bg-gray-600 disabled:opacity-50'], + ['btn', 'text-xl px-4 py-2 rounded inline-block bg-yellow-500 text-white cursor-pointer active:bg-yellow-600 disabled:cursor-default disabled:bg-yellow-600 disabled:opacity-90'], ['icon-btn', 'inline-block cursor-pointer select-none opacity-75 transition duration-200 ease-in-out hover:opacity-100 hover:text-red-600'], ], presets: [ From ab45f6000560477831f0296e4e14df4313364338 Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Mon, 5 Feb 2024 01:13:01 +0800 Subject: [PATCH 02/14] fix: copy img --- components/SpringFestivalCouplets.vue | 14 +- pnpm-lock.yaml | 3132 +++++++++++-------------- 2 files changed, 1395 insertions(+), 1751 deletions(-) diff --git a/components/SpringFestivalCouplets.vue b/components/SpringFestivalCouplets.vue index 07eb75f..a0e7a8f 100644 --- a/components/SpringFestivalCouplets.vue +++ b/components/SpringFestivalCouplets.vue @@ -13,16 +13,17 @@ defineProps<{ const app = useAppStore() +const sfcContainer = ref(null) + /** * Download image */ async function download() { - const container = document.getElementById('spring-festival-container') - if (!container) + if (!sfcContainer.value) return // const url = await screenShotToBase64(container) - const url = await toPng(container, { + const url = await toPng(sfcContainer.value, { includeQueryParams: true, }) @@ -34,12 +35,11 @@ async function download() { * Copy image to clipboard */ async function copyImg() { - const container = document.getElementById('girid-container') - if (!container) + if (!sfcContainer.value) return // const url = await screenShotToBase64(container) - const blob = await toBlob(container, { + const blob = await toBlob(sfcContainer.value, { includeQueryParams: true, }) @@ -60,7 +60,7 @@ async function shareLink() {