Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

feat(FTUE): implement multi-step onboarding wizard

Timothy Yina694377e0621
diff --git a/app/assets/css/tailwind.css b/app/assets/css/tailwind.css
index d5942379..247f3efe 100644
--- a/app/assets/css/tailwind.css
+++ b/app/assets/css/tailwind.css
@@ -50,3 +50,17 @@
--leading-normal: normal;
}
+
+.custom-scrollbar::-webkit-scrollbar {
+ width: 6px;
+}
+.custom-scrollbar::-webkit-scrollbar-track {
+ background: transparent;
+}
+.custom-scrollbar::-webkit-scrollbar-thumb {
+ background: rgba(255, 255, 255, 0.1);
+ border-radius: 10px;
+}
+.custom-scrollbar::-webkit-scrollbar-thumb:hover {
+ background: rgba(255, 255, 255, 0.2);
+}
diff --git a/app/assets/images/noise.svg b/app/assets/images/noise.svg
new file mode 100644
index 00000000..5aba4043
--- /dev/null
+++ b/app/assets/images/noise.svg
@@ -0,0 +1,7 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="500" height="500">
+ <filter id="noise" x="0" y="0">
+ <feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/>
+ <feBlend mode="screen"/>
+ </filter>
+ <rect width="500" height="500" filter="url(#noise)" opacity="0.5"/>
+</svg>
\ No newline at end of file
diff --git a/app/components/Wizard/Button.vue b/app/components/Wizard/Button.vue
new file mode 100644
index 00000000..c39d80d3
--- /dev/null
+++ b/app/components/Wizard/Button.vue
@@ -0,0 +1,24 @@
+<script setup lang="ts">
+defineOptions({
+ inheritAttrs: false
+})
+</script>
+
+<template>
+ <UButton
+ v-bind="$attrs"
+ :ui="{
+ base: 'transition-all duration-300 font-medium',
+ rounded: 'rounded-xl',
+ variant: {
+ solid: 'bg-linear-to-r from-primary-600 to-primary-500 hover:from-primary-500 hover:to-primary-400 text-white shadow-lg shadow-primary-500/20 hover:shadow-primary-500/40 border border-white/10',
+ outline: 'bg-white/5 hover:bg-white/10 text-white border border-white/10 hover:border-white/20',
+ ghost: 'text-neutral-400 hover:text-white hover:bg-white/5'
+ }
+ }"
+ >
+ <template v-for="(_, name) in $slots" #[name]="slotData">
+ <slot :name="name" v-bind="slotData" />
+ </template>
+ </UButton>
+</template>
diff --git a/app/components/Wizard/Checkbox.vue b/app/components/Wizard/Checkbox.vue
new file mode 100644
index 00000000..34706744
--- /dev/null
+++ b/app/components/Wizard/Checkbox.vue
@@ -0,0 +1,31 @@
+<script setup lang="ts">
+defineOptions({
+ inheritAttrs: false
+})
+
+const props = defineProps<{
+ modelValue?: boolean
+}>()
+
+const emit = defineEmits(['update:modelValue'])
+
+const value = computed({
+ get: () => props.modelValue,
+ set: (val) => emit('update:modelValue', val)
+})
+</script>
+
+<template>
+ <UCheckbox
+ v-bind="$attrs"
+ v-model="value"
+ :ui="{
+ base: 'border-white/10 bg-white/5 data-[state=checked]:bg-primary-500 data-[state=checked]:border-primary-500 text-white',
+ label: 'text-neutral-300 font-medium'
+ }"
+ >
+ <template v-for="(_, name) in $slots" #[name]="slotData">
+ <slot :name="name" v-bind="slotData" />
+ </template>
+ </UCheckbox>
+</template>
diff --git a/app/components/Wizard/FormField.vue b/app/components/Wizard/FormField.vue
new file mode 100644
index 00000000..b0c9c367
--- /dev/null
+++ b/app/components/Wizard/FormField.vue
@@ -0,0 +1,21 @@
+<script setup lang="ts">
+defineOptions({
+ inheritAttrs: false
+})
+</script>
+
+<template>
+ <UFormField
+ v-bind="$attrs"
+ :ui="{
+ label: 'text-neutral-300 font-medium mb-1.5',
+ description: 'text-neutral-500 text-xs mt-1',
+ error: 'text-red-400 text-xs mt-1',
+ hint: 'text-neutral-500 text-xs'
+ }"
+ >
+ <template v-for="(_, name) in $slots" #[name]="slotData">
+ <slot :name="name" v-bind="slotData" />
+ </template>
+ </UFormField>
+</template>
diff --git a/app/components/Wizard/Input.vue b/app/components/Wizard/Input.vue
new file mode 100644
index 00000000..80564881
--- /dev/null
+++ b/app/components/Wizard/Input.vue
@@ -0,0 +1,36 @@
+<script setup lang="ts">
+defineOptions({
+ inheritAttrs: false
+})
+
+const props = defineProps<{
+ modelValue?: string | number
+}>()
+
+const emit = defineEmits(['update:modelValue'])
+
+const value = computed({
+ get: () => props.modelValue,
+ set: (val) => emit('update:modelValue', val)
+})
+</script>
+
+<template>
+ <UInput
+ v-bind="$attrs"
+ v-model="value"
+ :ui="{
+ root: 'relative w-full',
+ base: 'w-full bg-white/5 border border-white/10 text-white placeholder:text-neutral-500 focus:ring-2 focus:ring-primary-500/20 focus:border-primary-500 transition-all duration-200 rounded-lg',
+ padding: { sm: 'px-3 py-2.5', md: 'px-4 py-3', lg: 'px-5 py-4' },
+ variant: {
+ outline: 'shadow-sm'
+ }
+ }"
+ variant="none"
+ >
+ <template v-for="(_, name) in $slots" #[name]="slotData">
+ <slot :name="name" v-bind="slotData" />
+ </template>
+ </UInput>
+</template>
diff --git a/app/components/Wizard/ProviderSelector.vue b/app/components/Wizard/ProviderSelector.vue
new file mode 100644
index 00000000..d5b17172
--- /dev/null
+++ b/app/components/Wizard/ProviderSelector.vue
@@ -0,0 +1,51 @@
+<script lang="ts">
+export interface ProviderOption {
+ label: string
+ value: string
+ icon?: string
+ description?: string
+}
+</script>
+
+<script setup lang="ts">
+defineProps<{
+ modelValue: string
+ options: ProviderOption[]
+}>()
+
+defineEmits<{
+ (e: 'update:modelValue', value: string): void
+}>()
+</script>
+
+<template>
+ <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
+ <div
+ v-for="option in options"
+ :key="option.value"
+ class="relative cursor-pointer group rounded-xl border p-4 transition-all duration-200"
+ :class="[
+ modelValue === option.value
+ ? 'bg-primary-500/10 border-primary-500 ring-1 ring-primary-500/50'
+ : 'bg-white/5 border-white/10 hover:bg-white/10 hover:border-white/20'
+ ]"
+ @click="$emit('update:modelValue', option.value)"
+ >
+ <div class="flex items-start justify-between mb-3">
+ <div
+ v-if="option.icon"
+ class="size-10 flex items-center justify-center rounded-lg transition-colors"
+ :class="modelValue === option.value ? 'bg-primary-500 text-white' : 'bg-white/10 text-neutral-400 group-hover:text-white'"
+ >
+ <UIcon :name="option.icon" class="size-6" />
+ </div>
+ <div v-if="modelValue === option.value" class="text-primary-400">
+ <UIcon name="tabler:circle-check" class="size-6" />
+ </div>
+ </div>
+
+ <h3 class="font-medium text-white mb-1">{{ $t(option.label) || option.label }}</h3>
+ <p v-if="option.description" class="text-xs text-neutral-400 leading-relaxed">{{ $t(option.description) || option.description }}</p>
+ </div>
+ </div>
+</template>
diff --git a/app/components/Wizard/Step.vue b/app/components/Wizard/Step.vue
new file mode 100644
index 00000000..9f5f03b4
--- /dev/null
+++ b/app/components/Wizard/Step.vue
@@ -0,0 +1,44 @@
+<script setup lang="ts">
+import { motion } from 'motion-v'
+
+defineProps<{
+ title: string
+ description?: string
+}>()
+</script>
+
+<template>
+ <motion.div
+ :initial="{ opacity: 0, x: 20 }"
+ :animate="{ opacity: 1, x: 0 }"
+ :exit="{ opacity: 0, x: -20 }"
+ :transition="{ duration: 0.4, ease: 'easeOut' }"
+ class="flex flex-col h-full"
+ >
+ <!-- Header -->
+ <div class="shrink-0 px-6 lg:px-12 py-8 border-b border-white/10">
+ <div class="max-w-2xl mx-auto space-y-2">
+ <h1 class="text-3xl font-bold tracking-tight text-white">
+ {{ title }}
+ </h1>
+ <p v-if="description" class="text-lg text-neutral-400">
+ {{ description }}
+ </p>
+ </div>
+ </div>
+
+ <!-- Scrollable Content -->
+ <div class="flex-1 overflow-y-auto custom-scrollbar px-6 lg:px-12 py-8">
+ <div class="max-w-2xl mx-auto h-full">
+ <slot />
+ </div>
+ </div>
+
+ <!-- Footer -->
+ <div v-if="$slots.actions" class="shrink-0 px-6 lg:px-12 py-6 border-t border-white/10">
+ <div class="max-w-2xl mx-auto flex items-center justify-end gap-4">
+ <slot name="actions" />
+ </div>
+ </div>
+ </motion.div>
+</template>
diff --git a/app/composables/useWizardForm.ts b/app/composables/useWizardForm.ts
new file mode 100644
index 00000000..8db26394
--- /dev/null
+++ b/app/composables/useWizardForm.ts
@@ -0,0 +1,96 @@
+import type { FieldDescriptor, SettingsFieldsResponse } from '~~/shared/types/settings'
+import { useWizardStore } from '~/stores/wizard'
+
+/**
+ * Wizard Form Composable
+ * Handles fetching schema and managing state for wizard steps
+ *
+ * @param namespace Namespace for the wizard step (e.g. 'admin', 'storage')
+ */
+export function useWizardForm(namespace: string) {
+ const toast = useToast()
+ const fields = ref<FieldDescriptor[]>([])
+ const loading = ref(false)
+ const error = ref<string | null>(null)
+ const store = useWizardStore()
+
+ // Map namespace to store state
+ const state = computed({
+ get: () => {
+ switch (namespace) {
+ case 'admin': return store.admin
+ case 'app': return store.site
+ case 'storage': return store.storage
+ case 'map': return store.map
+ default: return {}
+ }
+ },
+ set: (val) => {
+ switch (namespace) {
+ case 'admin': store.updateAdmin(val); break
+ case 'app': store.updateSite(val); break
+ case 'storage': store.updateStorage(val); break
+ case 'map': store.updateMap(val); break
+ }
+ }
+ })
+
+ const fetchSchema = async () => {
+ loading.value = true
+ error.value = null
+ try {
+ const response = await $fetch<SettingsFieldsResponse>('/api/wizard/schema', {
+ query: { namespace }
+ })
+ fields.value = response.fields
+
+ // Initialize state from schema if store is empty
+ // We create a temporary object to hold default values
+ const defaults: Record<string, any> = {}
+ response.fields.forEach(field => {
+ defaults[field.key] = field.value ?? field.defaultValue ?? ''
+ })
+
+ // Merge defaults with existing store state
+ // Existing store state takes precedence
+ const currentState = state.value
+ const newState = { ...defaults, ...currentState }
+
+ // Update store
+ state.value = newState
+
+ } catch (e: any) {
+ error.value = e.message
+ toast.add({
+ title: 'Failed to load wizard schema',
+ description: e.message,
+ color: 'error'
+ })
+ } finally {
+ loading.value = false
+ }
+ }
+
+ const isFieldVisible = (field: FieldDescriptor) => {
+ if (!field.ui?.visibleIf) return true
+ const { fieldKey, value } = field.ui.visibleIf
+ return state.value[fieldKey] === value
+ }
+
+ // Helper to get field by key
+ const getField = (key: string) => fields.value.find(f => f.key === key)
+
+ onMounted(() => {
+ fetchSchema()
+ })
+
+ return {
+ fields,
+ state,
+ loading,
+ error,
+ isFieldVisible,
+ fetchSchema,
+ getField
+ }
+}
diff --git a/app/layouts/onboarding.vue b/app/layouts/onboarding.vue
new file mode 100644
index 00000000..2ce0e969
--- /dev/null
+++ b/app/layouts/onboarding.vue
@@ -0,0 +1,229 @@
+<script setup lang="ts">
+import { motion } from 'motion-v'
+
+const route = useRoute()
+
+const steps = [
+ { label: '欢迎', route: 'onboarding' },
+ { label: '管理员账户', route: 'onboarding-admin' },
+ { label: '站点信息', route: 'onboarding-site' },
+ { label: '存储配置', route: 'onboarding-storage' },
+ { label: '地图服务', route: 'onboarding-map' },
+ { label: '完成', route: 'onboarding-complete' },
+]
+
+const currentStepIndex = computed(() => {
+ return steps.findIndex((s) => s.route === route.name)
+})
+</script>
+
+<template>
+ <div
+ class="min-h-screen flex items-center justify-center bg-neutral-950 text-white relative overflow-hidden selection:bg-primary-500/30"
+ >
+ <!-- Background Elements -->
+ <div class="absolute inset-0 pointer-events-none">
+ <!-- Noise Texture -->
+ <div
+ class="absolute inset-0 bg-[url('~/assets/images/noise.svg')] mix-blend-overlay"
+ ></div>
+
+ <!-- Spotlights -->
+ <motion.div
+ class="absolute -top-[20%] -left-[10%] w-[50vw] h-[50vw] bg-primary-500/20 rounded-full blur-[120px]"
+ :animate="{
+ x: [0, 50, 0],
+ y: [0, 30, 0],
+ scale: [1, 1.1, 1],
+ }"
+ :transition="{
+ duration: 20,
+ repeat: Infinity,
+ repeatType: 'reverse',
+ ease: 'easeInOut',
+ }"
+ />
+ <motion.div
+ class="absolute top-[40%] -right-[10%] w-[40vw] h-[40vw] bg-purple-500/10 rounded-full blur-[100px]"
+ :animate="{
+ x: [0, -30, 0],
+ y: [0, 50, 0],
+ scale: [1, 1.2, 1],
+ }"
+ :transition="{
+ duration: 15,
+ repeat: Infinity,
+ repeatType: 'reverse',
+ ease: 'easeInOut',
+ delay: 2,
+ }"
+ />
+ <motion.div
+ class="absolute -bottom-[20%] left-[20%] w-[45vw] h-[45vw] bg-blue-500/10 rounded-full blur-[120px]"
+ :animate="{
+ x: [0, 40, 0],
+ y: [0, -40, 0],
+ }"
+ :transition="{
+ duration: 18,
+ repeat: Infinity,
+ repeatType: 'reverse',
+ ease: 'easeInOut',
+ delay: 5,
+ }"
+ />
+ </div>
+
+ <!-- Main Container -->
+ <motion.div
+ class="relative z-10 w-full max-w-6xl h-[80vh] max-h-[900px] mx-4 lg:mx-8 flex rounded-3xl overflow-hidden border border-white/10 bg-neutral-900/40 backdrop-blur-2xl shadow-2xl shadow-black/50"
+ :initial="{ opacity: 0, scale: 0.95, y: 20 }"
+ :animate="{ opacity: 1, scale: 1, y: 0 }"
+ :transition="{ duration: 0.8, ease: [0.16, 1, 0.3, 1] }"
+ >
+ <!-- Left Panel: Sidebar -->
+ <div
+ class="hidden lg:flex w-80 flex-col gap-6 p-8 border-r border-white/5 bg-white/3 relative"
+ >
+ <!-- Logo -->
+ <div class="flex items-center gap-3">
+ <img
+ src="/favicon-96x96.png"
+ alt="ChronoFrame Logo"
+ class="size-14 object-contain"
+ />
+ <span
+ class="text-2xl font-bold tracking-tight bg-clip-text text-transparent bg-linear-to-r from-white to-white/60"
+ >
+ ChronoFrame
+ </span>
+ </div>
+
+ <!-- Steps -->
+ <div class="flex-1">
+ <div class="space-y-1 relative">
+ <!-- Connecting Line -->
+ <div
+ class="absolute left-[27px] top-4 bottom-4 w-0.5 bg-white/5 rounded-full"
+ >
+ <!-- Active Line Wrapper -->
+ <div
+ class="absolute top-0 left-0 w-full overflow-hidden transition-[height] duration-500 ease-in-out"
+ :style="{
+ height: `${Math.min(((currentStepIndex + 1) / (steps.length - 1)) * 100, 100)}%`,
+ }"
+ >
+ <!-- Gradient Color -->
+ <div
+ class="absolute inset-0"
+ :style="{
+ background: `linear-gradient(to bottom, var(--color-primary-500) ${
+ (currentStepIndex / (currentStepIndex + 1)) * 100
+ }%, transparent)`,
+ }"
+ ></div>
+
+ <!-- Flowing Light -->
+ <motion.div
+ class="absolute left-0 w-full h-20 bg-linear-to-b from-transparent via-white/60 to-transparent opacity-70"
+ :animate="{ top: ['-100%', '100%'] }"
+ :transition="{
+ duration: 1.6,
+ repeat: Infinity,
+ ease: 'linear',
+ repeatDelay: 0.5,
+ }"
+ />
+ </div>
+ </div>
+
+ <div
+ v-for="(step, index) in steps"
+ :key="step.route"
+ class="relative flex items-center gap-4 py-3 pl-2 group"
+ >
+ <!-- Active Indicator Background -->
+ <motion.div
+ v-if="index === currentStepIndex"
+ layout-id="activeStep"
+ class="absolute inset-0 bg-white/5 rounded-xl -z-10"
+ :transition="{ type: 'spring', stiffness: 300, damping: 30 }"
+ />
+
+ <!-- Step Circle -->
+ <div
+ class="relative z-10 size-10 rounded-full flex items-center justify-center text-sm font-medium transition-all duration-500 border-2"
+ :class="[
+ index < currentStepIndex
+ ? 'bg-primary-500 border-primary-500 text-white shadow-lg shadow-primary-500/20'
+ : index === currentStepIndex
+ ? 'bg-neutral-900 border-primary-500 text-primary-400 shadow-lg shadow-primary-500/10'
+ : 'bg-neutral-900 border-white/10 text-neutral-500 group-hover:border-white/20',
+ ]"
+ >
+ <UIcon
+ v-if="index < currentStepIndex"
+ name="tabler:check"
+ class="w-5 h-5"
+ />
+ <span v-else>{{ index + 1 }}</span>
+ </div>
+
+ <!-- Label -->
+ <div class="flex flex-col">
+ <span
+ class="text-sm font-medium transition-colors duration-300"
+ :class="[
+ index <= currentStepIndex
+ ? 'text-white'
+ : 'text-neutral-500 group-hover:text-neutral-400',
+ ]"
+ >
+ {{ step.label }}
+ </span>
+ <span
+ v-if="index === currentStepIndex"
+ class="text-xs text-primary-400/80 font-medium"
+ >
+ 当前进行
+ </span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- Footer -->
+ <div class="text-xs text-neutral-500 font-medium">
+ v{{ $config.public.VERSION }}
+ </div>
+ </div>
+
+ <!-- Right Panel: Content -->
+ <div
+ class="flex-1 flex flex-col relative overflow-hidden bg-neutral-900/20"
+ >
+ <!-- Top Bar (Mobile only) -->
+ <div
+ class="lg:hidden flex items-center justify-between p-6 border-b border-white/5 bg-neutral-900/50 backdrop-blur-md z-20"
+ >
+ <div class="flex items-center gap-3">
+ <img
+ src="/favicon-96x96.png"
+ alt="ChronoFrame Logo"
+ class="size-8 object-contain"
+ />
+ <span class="font-bold">ChronoFrame</span>
+ </div>
+ <div class="text-sm text-neutral-400">
+ Step {{ currentStepIndex + 1 }}/{{ steps.length }}
+ </div>
+ </div>
+
+ <!-- Content Area -->
+ <div class="flex-1 flex flex-col overflow-hidden">
+ <slot />
+ </div>
+ </div>
+ </motion.div>
+ </div>
+</template>
diff --git a/app/middleware/setup.global.ts b/app/middleware/setup.global.ts
new file mode 100644
index 00000000..fe7e5108
--- /dev/null
+++ b/app/middleware/setup.global.ts
@@ -0,0 +1,27 @@
+import { useSettingsStore } from '~/stores/settings'
+
+export default defineNuxtRouteMiddleware(async (to, _from) => {
+ const settingsStore = useSettingsStore()
+
+ // Ensure settings are loaded
+ if (!settingsStore.isReady) {
+ try {
+ await settingsStore.initSettings()
+ } catch (e) {
+ console.error('Failed to load settings in middleware', e)
+ }
+ }
+
+ const isFirstLaunch = settingsStore.getSetting('system:firstLaunch')
+ const isOnboarding = to.path.startsWith('/onboarding')
+
+ if (isFirstLaunch === true) {
+ if (!isOnboarding) {
+ return navigateTo('/onboarding')
+ }
+ } else {
+ if (isOnboarding) {
+ // ignore
+ }
+ }
+})
diff --git a/app/pages/dashboard/settings/demo.vue b/app/pages/dashboard/settings/demo.vue
deleted file mode 100644
index 455f6c05..00000000
--- a/app/pages/dashboard/settings/demo.vue
+++ /dev/null
@@ -1,384 +0,0 @@
-<template>
- <div class="space-y-6">
- <!-- 页面标题 -->
- <div class="border-b pb-4">
- <h1 class="text-2xl font-bold">设置</h1>
- <p class="text-gray-500 dark:text-gray-400 text-sm mt-1">管理应用程序设置和偏好</p>
- </div>
-
- <!-- 通用设置卡片 -->
- <UCard variant="soft">
- <template #header>
- <div class="flex items-center gap-2">
- <UIcon name="i-heroicons-cog-6-tooth" class="text-primary" />
- <h2 class="text-lg font-semibold">通用设置</h2>
- </div>
- </template>
-
- <div class="space-y-6">
- <!-- 文本输入 -->
- <UFormField label="应用名称" description="设置你的应用显示名称">
- <UInput
- v-model="formData.appName"
- placeholder="输入应用名称"
- icon="i-heroicons-pencil"
- />
- </UFormField>
-
- <!-- 描述文本 -->
- <UFormField label="应用描述" description="简要描述你的应用功能">
- <UTextarea
- v-model="formData.appDescription"
- placeholder="输入应用描述..."
- :rows="3"
- autoresize
- />
- </UFormField>
-
- <!-- 数字输入 -->
- <UFormField label="每页显示条数" description="设置列表页每页显示的条目数">
- <UInputNumber
- v-model="formData.itemsPerPage"
- :min="10"
- :max="100"
- :step="10"
- />
- </UFormField>
-
- <!-- 下拉选择 -->
- <UFormField label="主题" description="选择应用的主题">
- <USelect
- v-model="formData.theme"
- :options="themeOptions"
- option-attribute="label"
- value-attribute="value"
- placeholder="选择主题"
- />
- </UFormField>
-
- <!-- 开关切换 -->
- <UFormField>
- <USwitch
- v-model="formData.darkMode"
- label="深色模式"
- description="启用深色主题"
- />
- </UFormField>
- </div>
- </UCard>
-
- <!-- 存储设置卡片 -->
- <UCard variant="soft">
- <template #header>
- <div class="flex items-center gap-2">
- <UIcon name="i-heroicons-cloud" class="text-primary" />
- <h2 class="text-lg font-semibold">存储设置</h2>
- </div>
- </template>
-
- <div class="space-y-6">
- <!-- 存储提供商选择 -->
- <UFormField label="存储提供商" description="选择要使用的存储服务">
- <USelect
- v-model="formData.storageProvider"
- :options="storageProviderOptions"
- option-attribute="label"
- value-attribute="value"
- placeholder="选择存储提供商"
- />
- </UFormField>
-
- <!-- 存储桶名称 -->
- <UFormField label="存储桶名称" description="存储文件的 S3 存储桶名称">
- <UInput
- v-model="formData.bucketName"
- placeholder="e.g., my-bucket"
- icon="i-heroicons-server-stack"
- />
- </UFormField>
-
- <!-- 最大上传大小 -->
- <UFormField label="最大上传大小 (MB)" description="限制单个文件的最大上传大小">
- <UInputNumber
- v-model="formData.maxUploadSize"
- :min="1"
- :max="1000"
- :step="10"
- />
- </UFormField>
-
- <!-- 自动备份开关 -->
- <UFormField>
- <USwitch
- v-model="formData.autoBackup"
- label="自动备份"
- description="定期将数据备份到存储服务"
- />
- </UFormField>
- </div>
- </UCard>
-
- <!-- 显示设置卡片 -->
- <UCard variant="soft">
- <template #header>
- <div class="flex items-center gap-2">
- <UIcon name="i-heroicons-eye" class="text-primary" />
- <h2 class="text-lg font-semibold">显示设置</h2>
- </div>
- </template>
-
- <div class="space-y-6">
- <!-- 布局选择 -->
- <UFormField label="默认布局" description="选择相册默认显示方式">
- <USelect
- v-model="formData.defaultLayout"
- :options="layoutOptions"
- option-attribute="label"
- value-attribute="value"
- placeholder="选择布局"
- />
- </UFormField>
-
- <!-- 图片加载质量 -->
- <UFormField label="图片加载质量" description="选择缩略图的质量等级">
- <USelect
- v-model="formData.imageQuality"
- :options="qualityOptions"
- option-attribute="label"
- value-attribute="value"
- placeholder="选择质量"
- />
- </UFormField>
-
- <!-- 每行显示列数 -->
- <UFormField label="每行显示列数" description="网格布局中每行显示的列数">
- <UInputNumber
- v-model="formData.columnsPerRow"
- :min="2"
- :max="10"
- :step="1"
- />
- </UFormField>
-
- <!-- 显示文件信息 -->
- <UFormField>
- <USwitch
- v-model="formData.showFileInfo"
- label="显示文件信息"
- description="在图片下方显示文件名和大小"
- />
- </UFormField>
-
- <!-- 启用图片预览 -->
- <UFormField>
- <USwitch
- v-model="formData.enablePreview"
- label="启用快速预览"
- description="鼠标悬停时显示快速预览"
- />
- </UFormField>
- </div>
- </UCard>
-
- <!-- 性能设置卡片 -->
- <UCard variant="soft">
- <template #header>
- <div class="flex items-center gap-2">
- <UIcon name="i-heroicons-bolt" class="text-primary" />
- <h2 class="text-lg font-semibold">性能设置</h2>
- </div>
- </template>
-
- <div class="space-y-6">
- <!-- 缓存大小 -->
- <UFormField label="缓存大小 (MB)" description="本地缓存的最大大小">
- <UInputNumber
- v-model="formData.cacheSize"
- :min="10"
- :max="500"
- :step="50"
- />
- </UFormField>
-
- <!-- 预加载配置 -->
- <UFormField label="预加载条数" description="滚动时预加载的图片数量">
- <UInputNumber
- v-model="formData.preloadCount"
- :min="5"
- :max="50"
- :step="5"
- />
- </UFormField>
-
- <!-- 启用压缩 -->
- <UFormField>
- <USwitch
- v-model="formData.enableCompression"
- label="启用压缩"
- description="传输前压缩图片以减少带宽"
- />
- </UFormField>
-
- <!-- 启用缓存 -->
- <UFormField>
- <USwitch
- v-model="formData.enableCache"
- label="启用缓存"
- description="缓存已加载的图片到本地"
- />
- </UFormField>
- </div>
- </UCard>
-
- <!-- 通知设置卡片 -->
- <UCard variant="soft">
- <template #header>
- <div class="flex items-center gap-2">
- <UIcon name="i-heroicons-bell" class="text-primary" />
- <h2 class="text-lg font-semibold">通知设置</h2>
- </div>
- </template>
-
- <div class="space-y-6">
- <!-- 通知频率 -->
- <UFormField label="通知频率" description="接收应用通知的频率">
- <USelect
- v-model="formData.notificationFrequency"
- :options="frequencyOptions"
- option-attribute="label"
- value-attribute="value"
- placeholder="选择频率"
- />
- </UFormField>
-
- <!-- 邮件通知 -->
- <UFormField>
- <USwitch
- v-model="formData.emailNotification"
- label="邮件通知"
- description="通过邮件接收重要通知"
- />
- </UFormField>
-
- <!-- 上传完成提醒 -->
- <UFormField>
- <USwitch
- v-model="formData.uploadNotification"
- label="上传完成提醒"
- description="上传完成时显示提醒"
- />
- </UFormField>
-
- <!-- 错误通知 -->
- <UFormField>
- <USwitch
- v-model="formData.errorNotification"
- label="错误通知"
- description="发生错误时立即通知"
- />
- </UFormField>
- </div>
- </UCard>
-
- <!-- 操作按钮 -->
- <div class="flex gap-3 justify-end border-t pt-6">
- <UButton variant="outline" @click="resetForm">重置</UButton>
- <UButton @click="saveSettings">保存设置</UButton>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-definePageMeta({
- layout: 'dashboard',
-})
-
-// 定义选项
-const themeOptions = [
- { label: '亮色', value: 'light' },
- { label: '深色', value: 'dark' },
- { label: '自动', value: 'auto' }
-]
-
-const storageProviderOptions = [
- { label: 'Amazon S3', value: 's3' },
- { label: 'Cloudflare R2', value: 'r2' },
- { label: 'GitHub', value: 'github' },
- { label: '本地存储', value: 'local' }
-]
-
-const layoutOptions = [
- { label: '网格布局', value: 'grid' },
- { label: '列表布局', value: 'list' },
- { label: '瀑布流', value: 'masonry' },
- { label: '时间轴', value: 'timeline' }
-]
-
-const qualityOptions = [
- { label: '低质量 (快速)', value: 'low' },
- { label: '中等质量', value: 'medium' },
- { label: '高质量', value: 'high' },
- { label: '原始质量', value: 'original' }
-]
-
-const frequencyOptions = [
- { label: '从不', value: 'never' },
- { label: '仅重要', value: 'important' },
- { label: '每日摘要', value: 'daily' },
- { label: '实时', value: 'realtime' }
-]
-
-// 表单数据
-const formData = ref({
- // 通用设置
- appName: 'ChronoFrame',
- appDescription: '高性能照片管理和相册应用',
- itemsPerPage: 20,
- theme: 'auto',
- darkMode: false,
-
- // 存储设置
- storageProvider: 's3',
- bucketName: 'photos-bucket',
- maxUploadSize: 100,
- autoBackup: true,
-
- // 显示设置
- defaultLayout: 'masonry',
- imageQuality: 'high',
- columnsPerRow: 4,
- showFileInfo: true,
- enablePreview: true,
-
- // 性能设置
- cacheSize: 200,
- preloadCount: 20,
- enableCompression: true,
- enableCache: true,
-
- // 通知设置
- notificationFrequency: 'important',
- emailNotification: false,
- uploadNotification: true,
- errorNotification: true
-})
-
-// 原始表单数据备份
-const originalFormData = JSON.parse(JSON.stringify(formData.value))
-
-// 保存设置
-const saveSettings = () => {
- console.log('保存设置:', formData.value)
- // TODO: 接入数据保存逻辑
-}
-
-// 重置表单
-const resetForm = () => {
- formData.value = JSON.parse(JSON.stringify(originalFormData))
- console.log('已重置表单')
-}
-</script>
-
-<style scoped>
-/* 自定义样式可根据需要添加 */
-</style>
diff --git a/app/pages/dashboard/settings/storage.vue b/app/pages/dashboard/settings/storage.vue
index 366c24de..1f3f23f0 100644
--- a/app/pages/dashboard/settings/storage.vue
+++ b/app/pages/dashboard/settings/storage.vue
@@ -1,5 +1,5 @@
<script lang="ts" setup>
-import { UButton, UChip } from '#components'
+import { UChip, UButton } from '#components'
import type { TableColumn } from '@nuxt/ui'
import {
s3StorageConfigSchema,
@@ -512,7 +512,7 @@ const onStorageDelete = async (storageId: number) => {
<UButton
label="创建存储"
variant="soft"
- icon="i-heroicons-check"
+ icon="tabler:check"
type="submit"
form="createStorageForm"
/>
diff --git a/app/pages/onboarding/admin.vue b/app/pages/onboarding/admin.vue
new file mode 100644
index 00000000..9aee45aa
--- /dev/null
+++ b/app/pages/onboarding/admin.vue
@@ -0,0 +1,79 @@
+<script setup lang="ts">
+import { z } from 'zod'
+
+definePageMeta({
+ layout: 'onboarding',
+})
+
+const router = useRouter()
+
+// Use the wizard form composable
+const { fields, state, loading: fetchingSchema, isFieldVisible } = useWizardForm('admin')
+
+// Construct schema dynamically or keep it static?
+// For admin, static is safer for the specific password logic,
+// but we can make it partial to allow extra fields if API adds them.
+const schema = z.object({
+ username: z.string().min(2, 'Username must be at least 2 characters'),
+ email: z.email('Invalid email address'),
+ password: z.string().min(6, 'Password must be at least 6 characters'),
+ confirmPassword: z.string()
+}).refine((data) => data.password === data.confirmPassword, {
+ message: "Passwords don't match",
+ path: ["confirmPassword"],
+})
+
+function onSubmit() {
+ // Validation passed, data is already in the store via useWizardForm binding
+ router.push('/onboarding/site')
+}
+</script>
+
+<template>
+ <WizardStep
+ title="管理员账户"
+ description="创建一个管理员账户"
+ >
+ <div v-if="fetchingSchema" class="flex justify-center py-8">
+ <UIcon name="tabler:loader" class="animate-spin w-8 h-8 text-gray-400" />
+ </div>
+
+ <UForm
+ v-else
+ id="admin-form"
+ :schema="schema"
+ :state="state"
+ class="space-y-4"
+ @submit="onSubmit"
+ >
+ <template v-for="field in fields" :key="field.key">
+ <WizardFormField
+ v-if="isFieldVisible(field)"
+ :label="$t(field.label || '')"
+ :name="field.key"
+ :required="field.ui.required"
+ :help="$t(field.ui.help || '')"
+ >
+ <WizardInput
+ v-model="state[field.key]"
+ :type="field.ui.type === 'password' ? 'password' : 'text'"
+ :placeholder="field.ui.placeholder"
+ />
+ </WizardFormField>
+ </template>
+ </UForm>
+
+ <template #actions>
+ <WizardButton
+ type="submit"
+ form="admin-form"
+ color="primary"
+ size="lg"
+ :disabled="fetchingSchema"
+ trailing-icon="tabler:arrow-right"
+ >
+ 下一步
+ </WizardButton>
+ </template>
+ </WizardStep>
+</template>
diff --git a/app/pages/onboarding/complete.vue b/app/pages/onboarding/complete.vue
new file mode 100644
index 00000000..3171f4ba
--- /dev/null
+++ b/app/pages/onboarding/complete.vue
@@ -0,0 +1,119 @@
+<script setup lang="ts">
+import { useWizardStore } from '~/stores/wizard'
+
+definePageMeta({
+ layout: 'onboarding',
+})
+
+const loading = ref(false)
+const store = useWizardStore()
+const toast = useToast()
+
+async function onComplete() {
+ loading.value = true
+ try {
+ // 1. Prepare Admin Data
+ const adminData = store.admin
+
+ // 2. Prepare Site Data
+ const siteData = store.site
+
+ // 3. Prepare Storage Data
+ const storageState = store.storage
+ const storageProvider = storageState.provider
+ const storageConfig: Record<string, any> = { provider: storageProvider }
+
+ // Extract provider specific keys
+ Object.keys(storageState).forEach((key) => {
+ if (key.startsWith(storageProvider + '.')) {
+ const configKey = key.split('.')[1]!
+ storageConfig[configKey] = storageState[key]
+ }
+ })
+
+ const storageData = {
+ name: storageState.name,
+ config: storageConfig,
+ }
+
+ // 4. Prepare Map Data
+ const mapState = store.map
+ const mapProvider = mapState.provider
+ const mapTokenKey = `${mapProvider}.token`
+ const mapStyleKey = `${mapProvider}.style`
+
+ const mapData = {
+ provider: mapProvider,
+ token: mapState[mapTokenKey],
+ style: mapState[mapStyleKey],
+ }
+
+ // 5. Submit All
+ await $fetch('/api/wizard/submit', {
+ method: 'POST',
+ body: {
+ admin: adminData,
+ site: siteData,
+ storage: storageData,
+ map: mapData,
+ },
+ })
+
+ // Clear store
+ store.clear()
+
+ // Force reload to apply settings
+ window.location.href = '/dashboard'
+ } catch (error: any) {
+ console.error(error)
+ toast.add({
+ title: 'Setup Failed',
+ description: error.data?.message || 'Failed to complete setup',
+ color: 'error',
+ })
+ } finally {
+ loading.value = false
+ }
+}
+</script>
+
+<template>
+ <WizardStep
+ title="即将完成!"
+ description="您的 ChronoFrame 画廊已准备好使用。"
+ >
+ <div
+ class="flex flex-col items-center justify-center py-12 space-y-8 text-center"
+ >
+ <div class="relative">
+ <div
+ class="absolute inset-0 bg-green-500/20 blur-3xl rounded-full"
+ ></div>
+ <div
+ class="relative size-28 bg-linear-to-br from-green-400/20 to-green-600/20 rounded-full flex items-center justify-center border border-green-500/30 shadow-2xl shadow-green-500/20"
+ >
+ <UIcon
+ name="tabler:check"
+ class="size-18 text-green-400"
+ />
+ </div>
+ </div>
+
+ <div class="max-w-md text-neutral-300 text-lg">
+ <p>
+ 您已完成了所有基本配置。现在可以使用管理员账户登录并开始上传照片。
+ </p>
+ </div>
+
+ <WizardButton
+ size="xl"
+ color="primary"
+ :loading="loading"
+ class="px-6 py-3 text-base font-bold shadow-xl shadow-primary-500/20 hover:shadow-primary-500/40 transition-all duration-300"
+ @click="onComplete"
+ >
+ 前往仪表盘
+ </WizardButton>
+ </div>
+ </WizardStep>
+</template>
diff --git a/app/pages/onboarding/index.vue b/app/pages/onboarding/index.vue
new file mode 100644
index 00000000..ebc7eeb7
--- /dev/null
+++ b/app/pages/onboarding/index.vue
@@ -0,0 +1,111 @@
+<script setup lang="ts">
+definePageMeta({
+ layout: 'onboarding',
+})
+</script>
+
+<template>
+ <WizardStep
+ title="欢迎使用 ChronoFrame"
+ description="跟随向导,在几分钟内设置好您的画廊。"
+ >
+ <div class="space-y-8">
+ <div class="text-neutral-300 space-y-4 text-lg leading-relaxed">
+ <p>
+ ChronoFrame
+ 是一款多功能个人画廊应用程序。在您开始上传照片之前,我们需要先配置一些内容:
+ </p>
+ </div>
+
+ <div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <div
+ class="p-4 rounded-xl bg-white/5 border border-white/10 flex items-start gap-4"
+ >
+ <div
+ class="size-12 flex items-center justify-center rounded-lg bg-primary-500/20 text-primary-400"
+ >
+ <UIcon
+ name="tabler:user"
+ class="size-6"
+ />
+ </div>
+ <div>
+ <h3 class="font-medium text-white">管理员账户</h3>
+ <p class="text-sm text-neutral-400 mt-1">用于登录管理后台</p>
+ </div>
+ </div>
+
+ <div
+ class="p-4 rounded-xl bg-white/5 border border-white/10 flex items-start gap-4"
+ >
+ <div
+ class="size-12 flex items-center justify-center rounded-lg bg-purple-500/20 text-purple-400"
+ >
+ <UIcon
+ name="tabler:device-laptop"
+ class="size-6"
+ />
+ </div>
+ <div>
+ <h3 class="font-medium text-white">站点信息</h3>
+ <p class="text-sm text-neutral-400 mt-1">个性化您的画廊</p>
+ </div>
+ </div>
+
+ <div
+ class="p-4 rounded-xl bg-white/5 border border-white/10 flex items-start gap-4"
+ >
+ <div
+ class="size-12 flex items-center justify-center rounded-lg bg-blue-500/20 text-blue-400"
+ >
+ <UIcon
+ name="tabler:server"
+ class="size-6"
+ />
+ </div>
+ <div>
+ <h3 class="font-medium text-white">存储</h3>
+ <p class="text-sm text-neutral-400 mt-1">
+ 将您的照片存储在本地或云端
+ </p>
+ </div>
+ </div>
+
+ <div
+ class="p-4 rounded-xl bg-white/5 border border-white/10 flex items-start gap-4"
+ >
+ <div
+ class="size-12 flex items-center justify-center rounded-lg bg-green-500/20 text-green-400"
+ >
+ <UIcon
+ name="tabler:map"
+ class="size-6"
+ />
+ </div>
+ <div>
+ <h3 class="font-medium text-white">地图服务</h3>
+ <p class="text-sm text-neutral-400 mt-1">
+ 位置可视化、照片拍摄地标记
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <template #actions>
+ <div class="w-full flex justify-between items-center">
+ <p class="text-xs text-neutral-500 font-medium">
+ ChronoFrame 不会收集您的任何数据。
+ </p>
+ <WizardButton
+ to="/onboarding/admin"
+ color="primary"
+ size="lg"
+ trailing-icon="tabler:arrow-right"
+ >
+ 开始吧
+ </WizardButton>
+ </div>
+ </template>
+ </WizardStep>
+</template>
diff --git a/app/pages/onboarding/map.vue b/app/pages/onboarding/map.vue
new file mode 100644
index 00000000..b8ba7576
--- /dev/null
+++ b/app/pages/onboarding/map.vue
@@ -0,0 +1,124 @@
+<script setup lang="ts">
+import { z } from 'zod'
+import type { ProviderOption } from '~/components/Wizard/ProviderSelector.vue'
+
+definePageMeta({
+ layout: 'onboarding',
+})
+
+const router = useRouter()
+
+const {
+ fields,
+ state,
+ loading: fetchingSchema,
+ isFieldVisible,
+} = useWizardForm('map')
+
+// Dynamic schema
+const schema = computed(() => {
+ const s: Record<string, any> = {}
+ fields.value.forEach((field) => {
+ if (!isFieldVisible(field)) return
+
+ let validator: z.ZodTypeAny = z.string()
+ if (field.ui.required) {
+ validator = (validator as z.ZodString).min(
+ 1,
+ `${field.label} is required`,
+ )
+ } else {
+ validator = (validator as z.ZodString).optional()
+ }
+ s[field.key] = validator
+ })
+ return z.object(s)
+})
+
+function onSubmit() {
+ // Validation passed, data is already in the store via useWizardForm binding
+ // Transformation of map config will happen in the final step
+ router.push('/onboarding/complete')
+}
+</script>
+
+<template>
+ <WizardStep
+ title="地图服务"
+ description="为地球仪视图以及照片详情中的小地图配置地图服务"
+ >
+ <div
+ v-if="fetchingSchema"
+ class="flex justify-center py-8"
+ >
+ <UIcon
+ name="tabler:loader"
+ class="animate-spin w-8 h-8 text-gray-400"
+ />
+ </div>
+
+ <div
+ v-else
+ class="space-y-6"
+ >
+ <!-- Provider Selector -->
+ <template
+ v-for="field in fields"
+ :key="field.key"
+ >
+ <WizardProviderSelector
+ v-if="field.key === 'provider' && field.ui.type === 'custom'"
+ v-model="state[field.key]"
+ :options="(field.ui.options as ProviderOption[]) || []"
+ />
+ </template>
+
+ <UForm
+ id="map-form"
+ :state="state"
+ :schema="schema"
+ class="space-y-4"
+ @submit="onSubmit"
+ >
+ <template
+ v-for="field in fields"
+ :key="field.key"
+ >
+ <WizardFormField
+ v-if="isFieldVisible(field) && field.key !== 'provider'"
+ :label="$t(field.label || '')"
+ :name="field.key"
+ :required="field.ui.required"
+ :help="$t(field.ui.help || '')"
+ >
+ <WizardInput
+ v-if="field.ui.type === 'password'"
+ v-model="state[field.key]"
+ type="password"
+ :placeholder="$t(field.ui.placeholder || '')"
+ />
+ <WizardInput
+ v-else
+ v-model="state[field.key]"
+ type="text"
+ :placeholder="$t(field.ui.placeholder || '')"
+ />
+ </WizardFormField>
+ </template>
+ </UForm>
+ </div>
+
+ <template #actions>
+ <WizardButton
+ type="submit"
+ form="map-form"
+ color="primary"
+ size="lg"
+ :disabled="fetchingSchema"
+ trailing-icon="tabler:arrow-right"
+ >
+ 完成设置
+ </WizardButton>
+ </template>
+ </WizardStep>
+</template>
diff --git a/app/pages/onboarding/site.vue b/app/pages/onboarding/site.vue
new file mode 100644
index 00000000..ae297dbf
--- /dev/null
+++ b/app/pages/onboarding/site.vue
@@ -0,0 +1,87 @@
+<script setup lang="ts">
+import { z } from 'zod'
+
+definePageMeta({
+ layout: 'onboarding',
+})
+
+const router = useRouter()
+
+// Use wizard form for 'app' namespace (site settings)
+const {
+ fields,
+ state,
+ loading: fetchingSchema,
+ isFieldVisible,
+} = useWizardForm('app')
+
+const schema = z.object({
+ title: z.string().min(1, 'Title is required'),
+ slogan: z.string().optional(),
+ author: z.string().optional(),
+ avatarUrl: z.string().url('Invalid URL').optional().or(z.literal('')),
+})
+
+function onSubmit() {
+ // Validation passed, data is already in the store via useWizardForm binding
+ router.push('/onboarding/storage')
+}
+</script>
+
+<template>
+ <WizardStep
+ title="站点信息"
+ description="配置站点基本信息"
+ >
+ <div
+ v-if="fetchingSchema"
+ class="flex justify-center py-8"
+ >
+ <UIcon
+ name="tabler:loader"
+ class="animate-spin w-8 h-8 text-gray-400"
+ />
+ </div>
+
+ <UForm
+ v-else
+ id="site-form"
+ :schema="schema"
+ :state="state"
+ class="space-y-4"
+ @submit="onSubmit"
+ >
+ <template
+ v-for="field in fields"
+ :key="field.key"
+ >
+ <WizardFormField
+ v-if="isFieldVisible(field)"
+ :label="$t(field.label || '')"
+ :name="field.key"
+ :required="field.ui.required"
+ :help="$t(field.ui.help || '')"
+ >
+ <WizardInput
+ v-model="state[field.key]"
+ :type="field.ui.type === 'url' ? 'url' : 'text'"
+ :placeholder="field.ui.placeholder"
+ />
+ </WizardFormField>
+ </template>
+ </UForm>
+
+ <template #actions>
+ <WizardButton
+ type="submit"
+ form="site-form"
+ color="primary"
+ size="lg"
+ :disabled="fetchingSchema"
+ trailing-icon="tabler:arrow-right"
+ >
+ 下一步
+ </WizardButton>
+ </template>
+ </WizardStep>
+</template>
diff --git a/app/pages/onboarding/storage.vue b/app/pages/onboarding/storage.vue
new file mode 100644
index 00000000..8f7c7a4b
--- /dev/null
+++ b/app/pages/onboarding/storage.vue
@@ -0,0 +1,143 @@
+<script setup lang="ts">
+import { z } from 'zod'
+import type { ProviderOption } from '~/components/Wizard/ProviderSelector.vue'
+
+definePageMeta({
+ layout: 'onboarding',
+})
+
+const router = useRouter()
+
+const {
+ fields,
+ state,
+ loading: fetchingSchema,
+ isFieldVisible,
+} = useWizardForm('storage')
+
+// Dynamic schema based on visible fields
+const schema = computed(() => {
+ const s: Record<string, any> = {}
+ fields.value.forEach((field) => {
+ if (!isFieldVisible(field)) return
+
+ // Basic validation based on UI config
+ let validator: z.ZodTypeAny
+
+ if (field.type === 'boolean' || field.ui.type === 'toggle') {
+ validator = z.boolean()
+ } else {
+ validator = z.string()
+ if (field.ui.required) {
+ validator = (validator as z.ZodString).min(
+ 1,
+ `${field.label} is required`,
+ )
+ } else {
+ validator = (validator as z.ZodString).optional()
+ }
+ }
+
+ if (field.ui.type === 'number') {
+ // If we had number types, we'd handle them here
+ // validator = z.number()
+ }
+
+ s[field.key] = validator
+ })
+ return z.object(s)
+})
+
+function onSubmit() {
+ // Validation passed, data is already in the store via useWizardForm binding
+ // Transformation of storage config will happen in the final step
+ router.push('/onboarding/map')
+}
+</script>
+
+<template>
+ <WizardStep
+ title="存储配置"
+ description="选择将您的照片存储在何处"
+ >
+ <div
+ v-if="fetchingSchema"
+ class="flex justify-center py-8"
+ >
+ <UIcon
+ name="tabler:loader"
+ class="animate-spin w-8 h-8 text-gray-400"
+ />
+ </div>
+
+ <div
+ v-else
+ class="space-y-8"
+ >
+ <!-- Provider Selector (Custom Field) -->
+ <template
+ v-for="field in fields"
+ :key="field.key"
+ >
+ <WizardProviderSelector
+ v-if="field.key === 'provider' && field.ui.type === 'custom'"
+ v-model="state[field.key]"
+ :options="(field.ui.options as ProviderOption[]) || []"
+ />
+ </template>
+
+ <UForm
+ id="storage-form"
+ :state="state"
+ :schema="schema"
+ class="space-y-4"
+ @submit="onSubmit"
+ >
+ <template
+ v-for="field in fields"
+ :key="field.key"
+ >
+ <!-- Skip provider field as it's rendered above -->
+ <WizardFormField
+ v-if="isFieldVisible(field) && field.key !== 'provider'"
+ :label="$t(field.label || '')"
+ :name="field.key"
+ :required="field.ui.required"
+ :help="$t(field.ui.help || '')"
+ >
+ <WizardInput
+ v-if="field.ui.type === 'password'"
+ v-model="state[field.key]"
+ type="password"
+ :placeholder="$t(field.ui.placeholder || '')"
+ />
+ <WizardCheckbox
+ v-else-if="field.ui.type === 'toggle'"
+ v-model="state[field.key]"
+ :label="$t(field.label || '')"
+ />
+ <WizardInput
+ v-else
+ v-model="state[field.key]"
+ type="text"
+ :placeholder="$t(field.ui.placeholder || '')"
+ />
+ </WizardFormField>
+ </template>
+ </UForm>
+ </div>
+
+ <template #actions>
+ <WizardButton
+ type="submit"
+ form="storage-form"
+ color="primary"
+ size="lg"
+ :disabled="fetchingSchema"
+ trailing-icon="tabler:arrow-right"
+ >
+ 下一步
+ </WizardButton>
+ </template>
+ </WizardStep>
+</template>
diff --git a/app/stores/wizard.ts b/app/stores/wizard.ts
new file mode 100644
index 00000000..b0056f6c
--- /dev/null
+++ b/app/stores/wizard.ts
@@ -0,0 +1,44 @@
+import { defineStore } from 'pinia'
+import { useLocalStorage } from '@vueuse/core'
+
+export const useWizardStore = defineStore('wizard', () => {
+ const admin = ref(useLocalStorage<Record<string, any>>('wizard-admin', {}))
+ const site = ref(useLocalStorage<Record<string, any>>('wizard-site', {}))
+ const storage = ref(useLocalStorage<Record<string, any>>('wizard-storage', {}))
+ const map = ref(useLocalStorage<Record<string, any>>('wizard-map', {}))
+
+ const updateAdmin = (data: Record<string, any>) => {
+ admin.value = { ...admin.value, ...data }
+ }
+
+ const updateSite = (data: Record<string, any>) => {
+ site.value = { ...site.value, ...data }
+ }
+
+ const updateStorage = (data: Record<string, any>) => {
+ storage.value = { ...storage.value, ...data }
+ }
+
+ const updateMap = (data: Record<string, any>) => {
+ map.value = { ...map.value, ...data }
+ }
+
+ const clear = () => {
+ admin.value = {}
+ site.value = {}
+ storage.value = {}
+ map.value = {}
+ }
+
+ return {
+ admin,
+ site,
+ storage,
+ map,
+ updateAdmin,
+ updateSite,
+ updateStorage,
+ updateMap,
+ clear,
+ }
+})
diff --git a/i18n/locales/en.json b/i18n/locales/en.json
index 54f9ea8e..9c345e88 100644
--- a/i18n/locales/en.json
+++ b/i18n/locales/en.json
@@ -942,6 +942,28 @@
}
},
"storage": {
+ "name": {
+ "label": "Provider Name",
+ "description": "Name of the storage provider configuration"
+ },
+ "provider": {
+ "label": "Storage Provider",
+ "description": "Select the storage service provider",
+ "options": {
+ "local": {
+ "label": "Local Storage",
+ "description": "Store photos directly on the server's filesystem."
+ },
+ "s3": {
+ "label": "S3 Compatible",
+ "description": "Use AWS S3, Cloudflare R2, or other S3-compatible services."
+ },
+ "openlist": {
+ "label": "OpenList",
+ "description": "Connect to an Alist or OpenList instance for storage."
+ }
+ }
+ },
"s3": {
"bucket": {
"label": "Bucket Name",
@@ -1037,5 +1059,25 @@
}
}
}
+ },
+ "wizard": {
+ "admin": {
+ "username": { "label": "Username" },
+ "email": { "label": "Email" },
+ "password": { "label": "Password" },
+ "confirmPassword": { "label": "Confirm Password" }
+ },
+ "map": {
+ "provider": {
+ "mapbox": {
+ "label": "Mapbox",
+ "description": "High-performance maps with rich styling options."
+ },
+ "maplibre": {
+ "label": "MapLibre",
+ "description": "Open-source fork of Mapbox GL JS."
+ }
+ }
+ }
}
}
diff --git a/i18n/locales/ja.json b/i18n/locales/ja.json
index b2df0d97..1ade6d3c 100644
--- a/i18n/locales/ja.json
+++ b/i18n/locales/ja.json
@@ -885,6 +885,28 @@
}
},
"storage": {
+ "name": {
+ "label": "設定名",
+ "description": "ストレージプロバイダー設定の名前"
+ },
+ "provider": {
+ "label": "ストレージプロバイダー",
+ "description": "ストレージサービスプロバイダーを選択",
+ "options": {
+ "local": {
+ "label": "ローカルストレージ",
+ "description": "写真をサーバーのファイルシステムに直接保存します。"
+ },
+ "s3": {
+ "label": "S3 互換",
+ "description": "AWS S3、Cloudflare R2、またはその他の S3 互換サービスを使用します。"
+ },
+ "openlist": {
+ "label": "OpenList",
+ "description": "Alist または OpenList インスタンスに接続して保存します。"
+ }
+ }
+ },
"s3": {
"bucket": {
"label": "バケット名",
@@ -980,5 +1002,25 @@
}
}
}
+ },
+ "wizard": {
+ "admin": {
+ "username": { "label": "ユーザー名" },
+ "email": { "label": "メールアドレス" },
+ "password": { "label": "パスワード" },
+ "confirmPassword": { "label": "パスワード(確認)" }
+ },
+ "map": {
+ "provider": {
+ "mapbox": {
+ "label": "Mapbox",
+ "description": "豊富なスタイルオプションを備えた高性能マップ。"
+ },
+ "maplibre": {
+ "label": "MapLibre",
+ "description": "Mapbox GL JS のオープンソースフォーク。"
+ }
+ }
+ }
}
}
diff --git a/i18n/locales/zh-Hans.json b/i18n/locales/zh-Hans.json
index f8827bb1..7557ccba 100644
--- a/i18n/locales/zh-Hans.json
+++ b/i18n/locales/zh-Hans.json
@@ -944,6 +944,28 @@
}
},
"storage": {
+ "name": {
+ "label": "配置名称",
+ "description": "存储提供者配置的名称"
+ },
+ "provider": {
+ "label": "存储提供者",
+ "description": "选择存储服务提供者",
+ "options": {
+ "local": {
+ "label": "本地存储",
+ "description": "直接将照片存储在服务器的文件系统中。"
+ },
+ "s3": {
+ "label": "S3 兼容存储",
+ "description": "使用 AWS S3、Cloudflare R2 或其他 S3 兼容服务。"
+ },
+ "openlist": {
+ "label": "OpenList",
+ "description": "连接到 Alist 或 OpenList 实例进行存储。"
+ }
+ }
+ },
"s3": {
"bucket": {
"label": "存储桶名称",
@@ -1039,5 +1061,25 @@
}
}
}
+ },
+ "wizard": {
+ "admin": {
+ "username": { "label": "用户名" },
+ "email": { "label": "电子邮箱" },
+ "password": { "label": "密码" },
+ "confirmPassword": { "label": "确认密码" }
+ },
+ "map": {
+ "provider": {
+ "mapbox": {
+ "label": "Mapbox",
+ "description": "具有丰富样式选项的高性能地图。"
+ },
+ "maplibre": {
+ "label": "MapLibre",
+ "description": "Mapbox GL JS 的开源分支。"
+ }
+ }
+ }
}
}
diff --git a/i18n/locales/zh-Hant-HK.json b/i18n/locales/zh-Hant-HK.json
index 6a0883fc..363487b5 100644
--- a/i18n/locales/zh-Hant-HK.json
+++ b/i18n/locales/zh-Hant-HK.json
@@ -885,6 +885,28 @@
}
},
"storage": {
+ "name": {
+ "label": "配置名稱",
+ "description": "儲存提供者配置嘅名稱"
+ },
+ "provider": {
+ "label": "儲存提供者",
+ "description": "選擇儲存服務提供者",
+ "options": {
+ "local": {
+ "label": "本地儲存",
+ "description": "直接將相片儲存喺伺服器嘅檔案系統中。"
+ },
+ "s3": {
+ "label": "S3 兼容儲存",
+ "description": "使用 AWS S3、Cloudflare R2 或其他 S3 兼容服務。"
+ },
+ "openlist": {
+ "label": "OpenList",
+ "description": "連接到 Alist 或 OpenList 實例進行儲存。"
+ }
+ }
+ },
"s3": {
"bucket": {
"label": "儲存桶名稱",
@@ -980,5 +1002,25 @@
}
}
}
+ },
+ "wizard": {
+ "admin": {
+ "username": { "label": "用戶名" },
+ "email": { "label": "電子郵箱" },
+ "password": { "label": "密碼" },
+ "confirmPassword": { "label": "確認密碼" }
+ },
+ "map": {
+ "provider": {
+ "mapbox": {
+ "label": "Mapbox",
+ "description": "具有豐富樣式選項的高性能地圖。"
+ },
+ "maplibre": {
+ "label": "MapLibre",
+ "description": "Mapbox GL JS 的開源分支。"
+ }
+ }
+ }
}
}
diff --git a/i18n/locales/zh-Hant-TW.json b/i18n/locales/zh-Hant-TW.json
index 4bd06e78..81dd5be8 100644
--- a/i18n/locales/zh-Hant-TW.json
+++ b/i18n/locales/zh-Hant-TW.json
@@ -885,6 +885,28 @@
}
},
"storage": {
+ "name": {
+ "label": "配置名稱",
+ "description": "儲存提供者配置的名稱"
+ },
+ "provider": {
+ "label": "儲存提供者",
+ "description": "選擇儲存服務提供者",
+ "options": {
+ "local": {
+ "label": "本地儲存",
+ "description": "直接將照片儲存在伺服器的檔案系統中。"
+ },
+ "s3": {
+ "label": "S3 相容儲存",
+ "description": "使用 AWS S3、Cloudflare R2 或其他 S3 相容服務。"
+ },
+ "openlist": {
+ "label": "OpenList",
+ "description": "連接到 Alist 或 OpenList 實例進行儲存。"
+ }
+ }
+ },
"s3": {
"bucket": {
"label": "儲存桶名稱",
@@ -980,5 +1002,25 @@
}
}
}
+ },
+ "wizard": {
+ "admin": {
+ "username": { "label": "使用者名稱" },
+ "email": { "label": "電子郵件" },
+ "password": { "label": "密碼" },
+ "confirmPassword": { "label": "確認密碼" }
+ },
+ "map": {
+ "provider": {
+ "mapbox": {
+ "label": "Mapbox",
+ "description": "具有豐富樣式選項的高效能地圖。"
+ },
+ "maplibre": {
+ "label": "MapLibre",
+ "description": "Mapbox GL JS 的開源分支。"
+ }
+ }
+ }
}
}
diff --git a/package.json b/package.json
index 02d1cb42..5b52672e 100644
--- a/package.json
+++ b/package.json
@@ -82,6 +82,7 @@
"@iconify-json/lucide": "^1.2.70",
"@iconify-json/material-symbols": "^1.2.33",
"@iconify-json/mdi": "^1.2.3",
+ "@iconify-json/simple-icons": "^1.2.59",
"@iconify-json/streamline": "^1.2.5",
"@iconify-json/svg-spinners": "^1.2.4",
"@iconify-json/tabler": "^1.2.22",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index e2b1bcef..79380f11 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -165,6 +165,9 @@ importers:
'@iconify-json/mdi':
specifier: ^1.2.3
version: 1.2.3
+ '@iconify-json/simple-icons':
+ specifier: ^1.2.59
+ version: 1.2.59
'@iconify-json/streamline':
specifier: ^1.2.5
version: 1.2.5
@@ -1060,8 +1063,8 @@ packages:
'@iconify-json/[email protected]':
resolution: {integrity: sha512-O3cLwbDOK7NNDf2ihaQOH5F9JglnulNDFV7WprU2dSoZu3h3cWH//h74uQAB87brHmvFVxIOkuBX2sZSzYhScg==}
- '@iconify-json/[email protected]':
- resolution: {integrity: sha512-OQQYl8yC5j3QklZOYnK31QYe5h47IhyCoxSLd53f0e0nA4dgi8VOZS30SgSAbsecQ+S0xlGJMjXIHTIqZ+ML3w==}
+ '@iconify-json/[email protected]':
+ resolution: {integrity: sha512-fYx/InyQsWFW4wVxWka3CGDJ6m/fXoTqWBSl+oA3FBXO5RhPAb6S3Y5bRgCPnrYevErH8VjAL0TZevIqlN2PhQ==}
'@iconify-json/[email protected]':
resolution: {integrity: sha512-u6l9BOJoIIPjjDXWl6D/hPDzeBk5WiaEHZ+U9SbkQ14N9hgotaYyIZVMfgF175CG1TTS06j8k15D3FM2OYaFIw==}
@@ -8809,7 +8812,7 @@ snapshots:
dependencies:
'@iconify/types': 2.0.0
- '@iconify-json/[email protected]':
+ '@iconify-json/[email protected]':
dependencies:
'@iconify/types': 2.0.0
@@ -16152,7 +16155,7 @@ snapshots:
dependencies:
'@docsearch/css': 4.2.0
'@docsearch/js': 4.2.0
- '@iconify-json/simple-icons': 1.2.54
+ '@iconify-json/simple-icons': 1.2.59
'@shikijs/core': 3.13.0
'@shikijs/transformers': 3.13.0
'@shikijs/types': 3.13.0
diff --git a/scripts/migrate.mjs b/scripts/migrate.mjs
index cc18e0c9..b15011f7 100644
--- a/scripts/migrate.mjs
+++ b/scripts/migrate.mjs
@@ -4,38 +4,6 @@ import { drizzle } from 'drizzle-orm/better-sqlite3'
import Database from 'better-sqlite3'
import { fileURLToPath } from 'url'
import { dirname, join } from 'path'
-import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
-import { scrypt, randomBytes } from 'node:crypto'
-import { promisify } from 'node:util'
-
-const scryptAsync = promisify(scrypt)
-
-/**
- * 基于 @adonisjs/hash 的 Scrypt 驱动程序兼容实现
- */
-async function hashPassword(password) {
- const options = {
- cost: 16384, // N parameter (CPU/memory cost)
- blockSize: 8, // r parameter (block size)
- parallelization: 1, // p parameter (parallelization factor)
- keyLength: 64, // derived key length
- saltSize: 16, // salt size in bytes
- }
-
- const salt = randomBytes(options.saltSize)
-
- const derivedKey = await scryptAsync(password, salt, options.keyLength, {
- cost: options.cost,
- blockSize: options.blockSize,
- parallelization: options.parallelization,
- })
-
- // $scrypt$n=16384,r=8,p=1$salt$hash
- const saltBase64 = salt.toString('base64')
- const hashBase64 = derivedKey.toString('base64')
-
- return `$scrypt$n=${options.cost},r=${options.blockSize},p=${options.parallelization}$${saltBase64}$${hashBase64}`
-}
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
@@ -46,40 +14,10 @@ try {
const sqlite = new Database(process.env.DATABASE_URL || './data/app.sqlite3')
const db = drizzle(sqlite)
- migrate(db, {
+ await migrate(db, {
migrationsFolder: join(__dirname, '../server/database/migrations'),
})
- const usersTable = sqliteTable('users', {
- id: integer('id').primaryKey({ autoIncrement: true }),
- username: text('name').notNull().unique(),
- email: text('email').notNull().unique(),
- password: text('password'),
- avatar: text('avatar'),
- createdAt: integer('created_at', { mode: 'timestamp' }).notNull(),
- isAdmin: integer('is_admin').default(0).notNull(),
- })
-
- const existingUsers = await db.select().from(usersTable)
-
- if (existingUsers.length === 0) {
- console.log('No users found, creating admin user...')
- const hashedPassword = await hashPassword(
- process.env.CFRAME_ADMIN_PASSWORD || 'CF1234@!',
- )
-
- await db.insert(usersTable).values({
- username: process.env.CFRAME_ADMIN_NAME || 'Chronoframe',
- email: process.env.CFRAME_ADMIN_EMAIL || '[email protected]', // This default email does not exist
- password: hashedPassword,
- createdAt: new Date(),
- isAdmin: 1,
- })
- console.log('Admin user created successfully.')
- } else {
- console.log('User already exists, skipping admin user creation.')
- }
-
console.log('Database migrations completed successfully!')
sqlite.close()
} catch (error) {
diff --git a/server/api/system/settings/all.get.ts b/server/api/system/settings/all.get.ts
index 9acc5dd6..ff611126 100644
--- a/server/api/system/settings/all.get.ts
+++ b/server/api/system/settings/all.get.ts
@@ -1,27 +1,36 @@
-import { useDB, tables, eq } from '~~/server/utils/db'
+import { useDB, tables, eq, or, and } from '~~/server/utils/db'
/**
* 获取所有公开设置
* 仅返回 isPublic=true 的设置,按命名空间分组
+ * 特例:始终返回 system:firstLaunch 以便前端判断是否需要初始化
*/
export default eventHandler(async () => {
const db = useDB()
-
+
// 查询所有公开设置
const allSettings = db
.select()
.from(tables.settings)
- .where(eq(tables.settings.isPublic, true))
+ .where(
+ or(
+ eq(tables.settings.isPublic, true),
+ and(
+ eq(tables.settings.namespace, 'system'),
+ eq(tables.settings.key, 'firstLaunch'),
+ ),
+ ),
+ )
.all()
-
+
// 按命名空间分组
const grouped: Record<string, Record<string, any>> = {}
-
+
for (const setting of allSettings) {
if (!grouped[setting.namespace]) {
grouped[setting.namespace] = {}
}
-
+
// 解析值
let value: any = setting.value
try {
@@ -35,10 +44,10 @@ export default eventHandler(async () => {
} catch {
// 保持原始值
}
-
+
grouped[setting.namespace][setting.key] = value
}
-
+
return {
timestamp: Date.now(),
data: grouped,
diff --git a/server/api/wizard/admin.post.ts b/server/api/wizard/admin.post.ts
new file mode 100644
index 00000000..fd21123c
--- /dev/null
+++ b/server/api/wizard/admin.post.ts
@@ -0,0 +1,50 @@
+import { z } from 'zod'
+
+export default eventHandler(async (event) => {
+ const db = useDB()
+ const { email, password, username } = await readValidatedBody(
+ event,
+ z.object({
+ email: z.email(),
+ password: z.string().min(6),
+ username: z.string().min(2).default('admin'),
+ }).parse,
+ )
+
+ // Check if any user exists
+ const existingUser = db.select().from(tables.users).limit(1).get()
+ if (existingUser) {
+ // If users exist, we might want to update the admin or throw error
+ // For wizard, let's assume we are setting up the first user.
+ // If a user exists, maybe we just update the password if it's the same email?
+ // Or throw error.
+ // Let's throw error for now to be safe, or maybe just allow updating the first user if it matches.
+ if (existingUser.email === email) {
+ // Update existing
+ await db.update(tables.users)
+ .set({
+ password: await hashPassword(password),
+ username,
+ isAdmin: 1
+ })
+ .where(eq(tables.users.id, existingUser.id))
+ .run()
+ return { success: true }
+ }
+
+ throw createError({
+ statusCode: 400,
+ message: 'User already exists',
+ })
+ }
+
+ await db.insert(tables.users).values({
+ email,
+ username,
+ password: await hashPassword(password),
+ isAdmin: 1,
+ createdAt: new Date(),
+ }).run()
+
+ return { success: true }
+})
diff --git a/server/api/wizard/complete.post.ts b/server/api/wizard/complete.post.ts
new file mode 100644
index 00000000..87f6b03b
--- /dev/null
+++ b/server/api/wizard/complete.post.ts
@@ -0,0 +1,9 @@
+import { settingsManager } from '~~/server/services/settings/settingsManager'
+
+export default eventHandler(async (event) => {
+ // Set firstLaunch to false
+ // Pass true as the last argument (sudo) to bypass readonly check
+ await settingsManager.set('system', 'firstLaunch', false, undefined, true)
+
+ return { success: true }
+})
diff --git a/server/api/wizard/map.post.ts b/server/api/wizard/map.post.ts
new file mode 100644
index 00000000..eb9d3d85
--- /dev/null
+++ b/server/api/wizard/map.post.ts
@@ -0,0 +1,25 @@
+import { z } from 'zod'
+import { settingsManager } from '~~/server/services/settings/settingsManager'
+
+export default eventHandler(async (event) => {
+ const body = await readValidatedBody(
+ event,
+ z.object({
+ provider: z.enum(['mapbox', 'maplibre']),
+ token: z.string().min(1),
+ style: z.string().optional(),
+ }).parse,
+ )
+
+ await settingsManager.set('map', 'provider', body.provider)
+
+ if (body.provider === 'mapbox') {
+ await settingsManager.set('map', 'mapbox.token', body.token)
+ if (body.style) await settingsManager.set('map', 'mapbox.style', body.style)
+ } else {
+ await settingsManager.set('map', 'maplibre.token', body.token)
+ if (body.style) await settingsManager.set('map', 'maplibre.style', body.style)
+ }
+
+ return { success: true }
+})
diff --git a/server/api/wizard/schema.get.ts b/server/api/wizard/schema.get.ts
new file mode 100644
index 00000000..c850c692
--- /dev/null
+++ b/server/api/wizard/schema.get.ts
@@ -0,0 +1,159 @@
+import { z } from 'zod'
+import { settingsManager } from '~~/server/services/settings/settingsManager'
+import { getSettingUIConfig } from '~~/server/services/settings/ui-config'
+import type { FieldDescriptor } from '~~/shared/types/settings'
+
+export default eventHandler(async (event) => {
+ const query = await getValidatedQuery(
+ event,
+ z.object({
+ namespace: z.string().min(1),
+ }).parse,
+ )
+
+ // 1. Admin Account Schema
+ if (query.namespace === 'admin') {
+ const fields: FieldDescriptor[] = [
+ {
+ namespace: 'admin',
+ key: 'username',
+ type: 'string',
+ defaultValue: 'admin',
+ value: 'admin',
+ label: 'wizard.admin.username.label',
+ ui: { type: 'input', required: true, placeholder: 'admin' }
+ },
+ {
+ namespace: 'admin',
+ key: 'email',
+ type: 'string',
+ defaultValue: '',
+ value: '',
+ label: 'wizard.admin.email.label',
+ ui: { type: 'input', required: true, placeholder: '[email protected]' }
+ },
+ {
+ namespace: 'admin',
+ key: 'password',
+ type: 'string',
+ defaultValue: '',
+ value: '',
+ label: 'wizard.admin.password.label',
+ ui: { type: 'password', required: true }
+ },
+ {
+ namespace: 'admin',
+ key: 'confirmPassword',
+ type: 'string',
+ defaultValue: '',
+ value: '',
+ label: 'wizard.admin.confirmPassword.label',
+ ui: { type: 'password', required: true }
+ }
+ ] as any[]
+
+ return { namespace: 'admin', fields }
+ }
+
+ // 2. Storage Schema (Custom for Wizard)
+ if (query.namespace === 'storage') {
+ const storageFields = [
+ { key: 'provider', type: 'string', defaultValue: 'local', label: 'settings.storage.provider.label' },
+ { key: 'name', type: 'string', defaultValue: 'Default Storage', label: 'settings.storage.name.label' },
+ // Local
+ { key: 'local.basePath', type: 'string', defaultValue: './data/storage', label: 'settings.storage.local.basePath.label' },
+ { key: 'local.baseUrl', type: 'string', defaultValue: '/storage', label: 'settings.storage.local.baseUrl.label' },
+ { key: 'local.prefix', type: 'string', defaultValue: 'photos/', label: 'settings.storage.local.prefix.label' },
+ // S3
+ { key: 's3.endpoint', type: 'string', defaultValue: '', label: 'settings.storage.s3.endpoint.label' },
+ { key: 's3.bucket', type: 'string', defaultValue: '', label: 'settings.storage.s3.bucket.label' },
+ { key: 's3.region', type: 'string', defaultValue: 'auto', label: 'settings.storage.s3.region.label' },
+ { key: 's3.accessKeyId', type: 'string', defaultValue: '', label: 'settings.storage.s3.accessKeyId.label' },
+ { key: 's3.secretAccessKey', type: 'string', defaultValue: '', label: 'settings.storage.s3.secretAccessKey.label' },
+ { key: 's3.prefix', type: 'string', defaultValue: '/photos', label: 'settings.storage.s3.prefix.label' },
+ { key: 's3.cdnUrl', type: 'string', defaultValue: '', label: 'settings.storage.s3.cdnUrl.label' },
+ { key: 's3.forcePathStyle', type: 'boolean', defaultValue: false, label: 'settings.storage.s3.forcePathStyle.label' },
+ { key: 's3.maxKeys', type: 'number', defaultValue: 1000, label: 'settings.storage.s3.maxKeys.label' },
+ // OpenList
+ { key: 'openlist.baseUrl', type: 'string', defaultValue: '', label: 'settings.storage.openlist.baseUrl.label' },
+ { key: 'openlist.rootPath', type: 'string', defaultValue: '/photos', label: 'settings.storage.openlist.rootPath.label' },
+ { key: 'openlist.token', type: 'string', defaultValue: '', label: 'settings.storage.openlist.token.label' },
+ { key: 'openlist.cdnUrl', type: 'string', defaultValue: '', label: 'settings.storage.openlist.cdnUrl.label' },
+ { key: 'openlist.uploadEndpoint', type: 'string', defaultValue: '/api/fs/put', label: 'settings.storage.openlist.uploadEndpoint.label' },
+ { key: 'openlist.downloadEndpoint', type: 'string', defaultValue: '', label: 'settings.storage.openlist.downloadEndpoint.label' },
+ { key: 'openlist.listEndpoint', type: 'string', defaultValue: '', label: 'settings.storage.openlist.listEndpoint.label' },
+ { key: 'openlist.deleteEndpoint', type: 'string', defaultValue: '/api/fs/remove', label: 'settings.storage.openlist.deleteEndpoint.label' },
+ { key: 'openlist.metaEndpoint', type: 'string', defaultValue: '/api/fs/get', label: 'settings.storage.openlist.metaEndpoint.label' },
+ { key: 'openlist.pathField', type: 'string', defaultValue: 'path', label: 'settings.storage.openlist.pathField.label' },
+ ]
+
+ const fields = storageFields.map(field => {
+ const ui = getSettingUIConfig('storage', field.key)
+ return {
+ namespace: 'storage',
+ key: field.key,
+ type: field.type,
+ defaultValue: field.defaultValue,
+ value: field.defaultValue,
+ label: field.label,
+ ui: ui || { type: 'input' }
+ }
+ }) as FieldDescriptor[]
+
+ return { namespace: 'storage', fields }
+ }
+
+ // 3. App & Map Schemas (From Settings Manager)
+ try {
+ const schema = await settingsManager.getSchema()
+ const namespaceSettings = schema.filter(
+ (s) => s.namespace === query.namespace,
+ )
+
+ const fields = namespaceSettings.map((setting) => {
+ const uiConfig = getSettingUIConfig(query.namespace, setting.key)
+
+ // Patch for Wizard Map Provider to use rich selector
+ if (query.namespace === 'map' && setting.key === 'provider') {
+ return {
+ ...setting,
+ ui: {
+ type: 'custom',
+ options: [
+ {
+ label: 'wizard.map.provider.mapbox.label',
+ value: 'mapbox',
+ icon: 'simple-icons:mapbox',
+ description: 'wizard.map.provider.mapbox.description'
+ },
+ {
+ label: 'wizard.map.provider.maplibre.label',
+ value: 'maplibre',
+ icon: 'simple-icons:maplibre',
+ description: 'wizard.map.provider.maplibre.description'
+ },
+ ]
+ }
+ }
+ }
+
+ return {
+ ...setting,
+ ui: uiConfig || {
+ type: 'input' as const,
+ required: false,
+ },
+ }
+ })
+
+ return {
+ namespace: query.namespace,
+ fields,
+ }
+ } catch {
+ throw createError({
+ statusCode: 500,
+ statusMessage: 'Failed to fetch wizard schema',
+ })
+ }
+})
diff --git a/server/api/wizard/site.post.ts b/server/api/wizard/site.post.ts
new file mode 100644
index 00000000..57f14654
--- /dev/null
+++ b/server/api/wizard/site.post.ts
@@ -0,0 +1,21 @@
+import { z } from 'zod'
+import { settingsManager } from '~~/server/services/settings/settingsManager'
+
+export default eventHandler(async (event) => {
+ const body = await readValidatedBody(
+ event,
+ z.object({
+ title: z.string().min(1),
+ slogan: z.string().optional(),
+ avatarUrl: z.string().optional(),
+ author: z.string().optional(),
+ }).parse,
+ )
+
+ await settingsManager.set('app', 'title', body.title)
+ if (body.slogan) await settingsManager.set('app', 'slogan', body.slogan)
+ if (body.avatarUrl) await settingsManager.set('app', 'avatarUrl', body.avatarUrl)
+ if (body.author) await settingsManager.set('app', 'author', body.author)
+
+ return { success: true }
+})
diff --git a/server/api/wizard/storage.post.ts b/server/api/wizard/storage.post.ts
new file mode 100644
index 00000000..d80e9fc2
--- /dev/null
+++ b/server/api/wizard/storage.post.ts
@@ -0,0 +1,26 @@
+import { z } from 'zod'
+import { settingsManager } from '~~/server/services/settings/settingsManager'
+import { storageConfigSchema } from '~~/shared/types/storage'
+
+export default eventHandler(async (event) => {
+ const body = await readValidatedBody(
+ event,
+ z.object({
+ name: z.string().min(1),
+ config: storageConfigSchema,
+ }).parse,
+ )
+
+ const id = await settingsManager.storage.addProvider({
+ name: body.name,
+ provider: body.config.provider,
+ config: body.config,
+ })
+
+ // Set as active provider if it's the first one or explicitly requested?
+ // The addProvider method already sets it as active if it's the only one.
+ // We might want to force set it as active here since it's the wizard.
+ await settingsManager.set('storage', 'provider', id)
+
+ return { success: true, id }
+})
diff --git a/server/api/wizard/submit.post.ts b/server/api/wizard/submit.post.ts
new file mode 100644
index 00000000..91d886cf
--- /dev/null
+++ b/server/api/wizard/submit.post.ts
@@ -0,0 +1,93 @@
+import { z } from 'zod'
+import { settingsManager } from '~~/server/services/settings/settingsManager'
+import { storageConfigSchema } from '~~/shared/types/storage'
+import { useDB, tables, eq } from '~~/server/utils/db'
+
+export default eventHandler(async (event) => {
+ const body = await readValidatedBody(
+ event,
+ z.object({
+ admin: z.object({
+ email: z.string().email(),
+ password: z.string().min(6),
+ username: z.string().min(2).default('admin'),
+ }),
+ site: z.object({
+ title: z.string().min(1),
+ slogan: z.string().optional(),
+ avatarUrl: z.string().optional(),
+ author: z.string().optional(),
+ }),
+ storage: z.object({
+ name: z.string().min(1),
+ config: storageConfigSchema,
+ }),
+ map: z.object({
+ provider: z.enum(['mapbox', 'maplibre']),
+ token: z.string().min(1),
+ style: z.string().optional(),
+ }),
+ }).parse,
+ )
+
+ const db = useDB()
+
+ // 1. Handle Admin User
+ const existingUser = db.select().from(tables.users).limit(1).get()
+ if (existingUser) {
+ if (existingUser.email === body.admin.email) {
+ await db.update(tables.users)
+ .set({
+ password: await hashPassword(body.admin.password),
+ username: body.admin.username,
+ isAdmin: 1
+ })
+ .where(eq(tables.users.id, existingUser.id))
+ .run()
+ } else {
+ throw createError({
+ statusCode: 400,
+ message: 'User already exists',
+ })
+ }
+ } else {
+ await db.insert(tables.users).values({
+ email: body.admin.email,
+ username: body.admin.username,
+ password: await hashPassword(body.admin.password),
+ isAdmin: 1,
+ createdAt: new Date(),
+ }).run()
+ }
+
+ // 2. Handle Site Settings
+ await settingsManager.set('app', 'title', body.site.title)
+ if (body.site.slogan) await settingsManager.set('app', 'slogan', body.site.slogan)
+ if (body.site.avatarUrl) await settingsManager.set('app', 'avatarUrl', body.site.avatarUrl)
+ if (body.site.author) await settingsManager.set('app', 'author', body.site.author)
+
+ // 3. Handle Storage Settings
+ // Check if provider already exists to avoid duplicates if re-running?
+ // For now, just add it.
+ const id = await settingsManager.storage.addProvider({
+ name: body.storage.name,
+ provider: body.storage.config.provider,
+ config: body.storage.config,
+ })
+ await settingsManager.set('storage', 'provider', id)
+
+ // 4. Handle Map Settings
+ await settingsManager.set('map', 'provider', body.map.provider)
+ if (body.map.provider === 'mapbox') {
+ await settingsManager.set('map', 'mapbox.token', body.map.token)
+ if (body.map.style) await settingsManager.set('map', 'mapbox.style', body.map.style)
+ } else {
+ await settingsManager.set('map', 'maplibre.token', body.map.token)
+ if (body.map.style) await settingsManager.set('map', 'maplibre.style', body.map.style)
+ }
+
+ // 5. Mark Complete
+ await settingsManager.set('system', 'firstLaunch', false, undefined, true)
+
+ return { success: true }
+})
diff --git a/server/plugins/1.seed.ts b/server/plugins/1.seed.ts
index af63e059..413c8a2d 100644
--- a/server/plugins/1.seed.ts
+++ b/server/plugins/1.seed.ts
@@ -1,4 +1,4 @@
export default defineNitroPlugin(async (_nitroApp) => {
- await runTask('db:migrate')
- await runTask('db:seed')
+ // await runTask('db:migrate')
+ // await runTask('db:seed')
})
diff --git a/server/services/settings/ui-config.ts b/server/services/settings/ui-config.ts
index 6a22fd24..8da69a9d 100644
--- a/server/services/settings/ui-config.ts
+++ b/server/services/settings/ui-config.ts
@@ -101,8 +101,162 @@ export const LOCATION_SETTINGS_UI: Record<string, FieldUIConfig> = {
export const STORAGE_SETTINGS_UI: Record<string, FieldUIConfig> = {
provider: {
- type: 'select',
- help: 'settings.storage.provider.help',
+ type: 'custom',
+ options: [
+ {
+ label: 'settings.storage.provider.options.local.label',
+ value: 'local',
+ icon: 'tabler:server',
+ description: 'settings.storage.provider.options.local.description'
+ },
+ {
+ label: 'settings.storage.provider.options.s3.label',
+ value: 's3',
+ icon: 'tabler:brand-aws',
+ description: 'settings.storage.provider.options.s3.description'
+ },
+ {
+ label: 'settings.storage.provider.options.openlist.label',
+ value: 'openlist',
+ icon: 'tabler:stack',
+ description: 'settings.storage.provider.options.openlist.description'
+ },
+ ]
+ },
+ name: {
+ type: 'input',
+ required: true,
+ },
+ // Local
+ 'local.basePath': {
+ type: 'input',
+ required: true,
+ help: 'settings.storage.local.basePath.description',
+ visibleIf: { fieldKey: 'provider', value: 'local' }
+ },
+ 'local.baseUrl': {
+ type: 'input',
+ help: 'settings.storage.local.baseUrl.description',
+ visibleIf: { fieldKey: 'provider', value: 'local' }
+ },
+ 'local.prefix': {
+ type: 'input',
+ placeholder: 'photos/',
+ help: 'settings.storage.local.prefix.description',
+ visibleIf: { fieldKey: 'provider', value: 'local' }
+ },
+ // S3
+ 's3.endpoint': {
+ type: 'input',
+ required: true,
+ placeholder: 'https://s3.amazonaws.com',
+ help: 'settings.storage.s3.endpoint.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ 's3.bucket': {
+ type: 'input',
+ required: true,
+ help: 'settings.storage.s3.bucket.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ 's3.region': {
+ type: 'input',
+ required: true,
+ help: 'settings.storage.s3.region.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ 's3.accessKeyId': {
+ type: 'input',
+ required: true,
+ help: 'settings.storage.s3.accessKeyId.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ 's3.secretAccessKey': {
+ type: 'password',
+ required: true,
+ help: 'settings.storage.s3.secretAccessKey.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ 's3.prefix': {
+ type: 'input',
+ placeholder: '/photos',
+ help: 'settings.storage.s3.prefix.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ 's3.cdnUrl': {
+ type: 'input',
+ help: 'settings.storage.s3.cdnUrl.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ 's3.forcePathStyle': {
+ type: 'toggle',
+ help: 'settings.storage.s3.forcePathStyle.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ 's3.maxKeys': {
+ type: 'number',
+ help: 'settings.storage.s3.maxKeys.description',
+ visibleIf: { fieldKey: 'provider', value: 's3' }
+ },
+ // OpenList
+ 'openlist.baseUrl': {
+ type: 'input',
+ required: true,
+ placeholder: 'https://alist.example.com',
+ help: 'settings.storage.openlist.baseUrl.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.rootPath': {
+ type: 'input',
+ required: true,
+ placeholder: '/photos',
+ help: 'settings.storage.openlist.rootPath.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.token': {
+ type: 'password',
+ required: true,
+ help: 'settings.storage.openlist.token.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.cdnUrl': {
+ type: 'input',
+ help: 'settings.storage.openlist.cdnUrl.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.uploadEndpoint': {
+ type: 'input',
+ placeholder: '/api/fs/put',
+ help: 'settings.storage.openlist.uploadEndpoint.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.downloadEndpoint': {
+ type: 'input',
+ help: 'settings.storage.openlist.downloadEndpoint.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.listEndpoint': {
+ type: 'input',
+ help: 'settings.storage.openlist.listEndpoint.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.deleteEndpoint': {
+ type: 'input',
+ placeholder: '/api/fs/remove',
+ help: 'settings.storage.openlist.deleteEndpoint.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.metaEndpoint': {
+ type: 'input',
+ placeholder: '/api/fs/get',
+ help: 'settings.storage.openlist.metaEndpoint.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
+ },
+ 'openlist.pathField': {
+ type: 'input',
+ placeholder: 'path',
+ help: 'settings.storage.openlist.pathField.description',
+ visibleIf: { fieldKey: 'provider', value: 'openlist' }
},
}
diff --git a/shared/types/settings.ts b/shared/types/settings.ts
index afa27fe0..7a193770 100644
--- a/shared/types/settings.ts
+++ b/shared/types/settings.ts
@@ -54,6 +54,7 @@ export interface FieldUIConfig {
label: string
value: SettingValue
icon?: string
+ description?: string
}>
// 验证规则(前端 UX 提示)