diff --git a/.env.example b/.env.example index 5a95d73..7e831e4 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,6 @@ DATABASE_URL=file:./db.sqlite STATIC_DIR=static UPLOAD_SUBDIR=upload -NITRO_PORT=3399 SCHEDULER_MAX_CONCURRENCY=5 SCHEDULER_LOG_RETENTION_DAYS=30 BOOTSTRAP_ADMIN_USERNAME=admin @@ -11,4 +10,5 @@ GITHUB_CLIENT_SECRET=your_github_client_secret GITEA_CLIENT_ID=your_gitea_client_id GITEA_CLIENT_SECRET=your_gitea_client_secret GITEA_URL=https://gitea.com +NITRO_PORT=3399 APP_URL=http://localhost:3399 \ No newline at end of file diff --git a/app/components/index/IdeaCard.vue b/app/components/index/IdeaCard.vue new file mode 100644 index 0000000..f558341 --- /dev/null +++ b/app/components/index/IdeaCard.vue @@ -0,0 +1,207 @@ + + + + + diff --git a/app/pages/index/index.vue b/app/pages/index/index.vue index d6d5b1d..100b90a 100644 --- a/app/pages/index/index.vue +++ b/app/pages/index/index.vue @@ -2,57 +2,499 @@ definePageMeta({ layout: 'home', }) + +const { $toast } = useNuxtApp() + +// ── Form state ── +const author = ref('') +const content = ref('') +const platform = ref(null) +const submitting = ref(false) + +// Platform options +const platforms = ['网站', 'Windows 应用', 'App', '小程序', '插件/扩展', '命令行工具', '其他'] + +// ── Ideas list ── +const page = ref(1) +const { data, refresh, pending } = await useFetch('/api/ideas', { + query: computed(() => ({ page: page.value, pageSize: 30 })), +}) + +const ideas = computed(() => (data.value as any)?.data?.items ?? []) +const hasMore = computed(() => (data.value as any)?.data?.hasMore ?? false) + +// ── Detail dialog ── +const selectedIdea = ref(null) +const showDetail = ref(false) + +function openDetail(idea: any) { + selectedIdea.value = idea + showDetail.value = true +} + +function closeDetail() { + showDetail.value = false +} + +// ── Submit ── +async function submitIdea() { + const trimmedAuthor = author.value.trim() + const trimmedContent = content.value.trim() + + if (!trimmedContent) { + $toast.warning('请输入你的想法') + return + } + + submitting.value = true + try { + await $fetch('/api/ideas', { + method: 'POST', + body: { author: trimmedAuthor, content: trimmedContent, platform: platform.value }, + }) + author.value = '' + content.value = '' + platform.value = null + $toast.success('想法已发布 ✨') + await refresh() + } catch (e: any) { + $toast.error(e?.data?.message || '发布失败,请重试') + } finally { + submitting.value = false + } +} + +// ── Load more ── +async function loadMore() { + page.value++ + await refresh() +}