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.

refactor: extract shared gallery and public presentation state

HoshinoSuzumiBot4ed380c3cff5
diff --git a/app/app.vue b/app/app.vue
index ca3f695f..c392caeb 100644
--- a/app/app.vue
+++ b/app/app.vue
@@ -4,10 +4,9 @@ import dayjsLocale_zhTW from 'dayjs/locale/zh-tw'
import dayjsLocale_zhHK from 'dayjs/locale/zh-hk'
const DebugPanel = import.meta.dev
- ? defineAsyncComponent(() => import('~/components/debug/Panel.vue'))
+ ? defineAsyncComponent(() => import('#gallery/components/debug/Panel.vue'))
: null
-const router = useRouter()
const dayjs = useDayjs()
const colorMode = useColorMode()
const localeRef = ref('en')
@@ -57,57 +56,13 @@ const { data, refresh, status } = await useFetch(() => apiEndpoint.value, {
const photos = computed(() => (data.value as Photo[]) || [])
await useInstanceOpenGraph(photos)
-const { switchToIndex, closeViewer, clearReturnRoute } = useViewerState()
const {
+ viewerPhotos,
currentPhotoIndex,
isViewerOpen,
- returnRoute,
- isDirectAccess,
- scopedPhotos,
-} = storeToRefs(useViewerState())
-
-// The photo collection the viewer actually navigates: the scoped list (e.g. an
-// album) when present, otherwise the global list.
-const viewerPhotos = computed(() => scopedPhotos.value ?? photos.value)
-
-const handleIndexChange = (newIndex: number) => {
- switchToIndex(newIndex)
- const photoId = viewerPhotos.value[newIndex]?.id
- if (!photoId) return
- if (
- returnRoute.value?.startsWith('/albums/') &&
- route.path === returnRoute.value
- ) {
- router.replace({
- path: route.path,
- query: { ...route.query, photo: photoId },
- })
- } else {
- router.replace(`/${photoId}`)
- }
-}
-
-const handleClose = () => {
- closeViewer()
-
- // 如果是直接访问详情页面,关闭时返回首页
- if (isDirectAccess.value) {
- isDirectAccess.value = false
- router.replace('/')
- } else if (returnRoute.value) {
- // 如果有指定的返回路由,返回到该路由
- const destination = returnRoute.value
- clearReturnRoute()
- router.replace(destination)
- } else {
- // 否则使用历史记录或默认返回首页
- if (window.history.length > 1) {
- router.back()
- } else {
- router.replace('/')
- }
- }
-}
+ handleClose,
+ handleIndexChange,
+} = useGalleryViewer(photos)
watchEffect(() => {
dayjs.locale('zh-Hans', dayjsLocale_zhCN)
diff --git a/app/components/Wizard/Step.vue b/app/components/Wizard/Step.vue
index 4733e9d9..a57cd034 100644
--- a/app/components/Wizard/Step.vue
+++ b/app/components/Wizard/Step.vue
@@ -20,11 +20,18 @@ defineProps<{
<div class="shrink-0 px-6 lg:px-10 py-6 border-b border-white/10">
<div class="max-w-3xl mx-auto space-y-2">
<h1 class="text-2xl font-bold tracking-tight text-white">
- {{ title }}
+ {{ title }}
</h1>
- <div v-if="description" class="flex items-center justify-between">
+ <div
+ v-if="description"
+ class="flex items-center justify-between"
+ >
<p class="text-sm text-neutral-400">{{ description }}</p>
- <span v-if="tips" class="text-sm text-neutral-400 shrink-0 ml-4">{{ tips }}</span>
+ <span
+ v-if="tips"
+ class="text-sm text-neutral-400 shrink-0 ml-4"
+ >{{ tips }}</span
+ >
</div>
</div>
</div>
diff --git a/app/composables/useWizardForm.ts b/app/composables/useWizardForm.ts
index 9bb06c99..9b3809a8 100644
--- a/app/composables/useWizardForm.ts
+++ b/app/composables/useWizardForm.ts
@@ -1,7 +1,7 @@
import type {
FieldDescriptor,
SettingsFieldsResponse,
-} from '~~/shared/types/settings'
+} from '@chronoframe/gallery/shared/types/settings'
import { useWizardStore } from '~/stores/wizard'
/**
diff --git a/app/layouts/onboarding.vue b/app/layouts/onboarding.vue
index dc56c061..66b39108 100644
--- a/app/layouts/onboarding.vue
+++ b/app/layouts/onboarding.vue
@@ -11,7 +11,10 @@ const steps = computed(() => [
{ label: $t('onboarding.layout.steps.site'), route: 'onboarding-site' },
{ label: $t('onboarding.layout.steps.storage'), route: 'onboarding-storage' },
{ label: $t('onboarding.layout.steps.map'), route: 'onboarding-map' },
- { label: $t('onboarding.layout.steps.complete'), route: 'onboarding-complete' },
+ {
+ label: $t('onboarding.layout.steps.complete'),
+ route: 'onboarding-complete',
+ },
])
const currentStepIndex = computed(() => {
@@ -31,7 +34,7 @@ function isStepAccessible(index: number) {
<div class="absolute inset-0 pointer-events-none">
<!-- Noise Texture -->
<div
- class="absolute inset-0 bg-[url('~/assets/images/noise.svg')] mix-blend-overlay"
+ class="absolute inset-0 bg-[url('#gallery/assets/images/noise.svg')] mix-blend-overlay"
></div>
<!-- Spotlights -->
@@ -146,9 +149,17 @@ function isStepAccessible(index: number) {
<NuxtLink
v-for="(step, index) in steps"
:key="step.route"
- :to="isStepAccessible(index) ? (step.route === 'onboarding' ? '/onboarding' : `/onboarding/${step.route.replace('onboarding-', '')}`) : undefined"
+ :to="
+ isStepAccessible(index)
+ ? step.route === 'onboarding'
+ ? '/onboarding'
+ : `/onboarding/${step.route.replace('onboarding-', '')}`
+ : undefined
+ "
class="relative flex items-center gap-4 py-3 pl-2 group"
- :class="isStepAccessible(index) ? 'cursor-pointer' : 'cursor-default'"
+ :class="
+ isStepAccessible(index) ? 'cursor-pointer' : 'cursor-default'
+ "
>
<!-- Active Indicator Background -->
<motion.div
@@ -182,9 +193,7 @@ function isStepAccessible(index: number) {
<span
class="text-sm font-medium transition-colors duration-300"
:class="[
- isStepAccessible(index)
- ? 'text-white'
- : 'text-neutral-500',
+ isStepAccessible(index) ? 'text-white' : 'text-neutral-500',
]"
>
{{ step.label }}
@@ -223,7 +232,12 @@ function isStepAccessible(index: number) {
<span class="font-bold">ChronoFrame</span>
</div>
<div class="text-sm text-neutral-400">
- {{ $t('onboarding.layout.stepCounter', [currentStepIndex + 1, steps.length]) }}
+ {{
+ $t('onboarding.layout.stepCounter', [
+ currentStepIndex + 1,
+ steps.length,
+ ])
+ }}
</div>
</div>
diff --git a/app/middleware/setup.global.ts b/app/middleware/setup.global.ts
index fe7e5108..f7daf7a6 100644
--- a/app/middleware/setup.global.ts
+++ b/app/middleware/setup.global.ts
@@ -1,4 +1,4 @@
-import { useSettingsStore } from '~/stores/settings'
+import { useSettingsStore } from '#gallery/stores/settings'
export default defineNuxtRouteMiddleware(async (to, _from) => {
const settingsStore = useSettingsStore()
diff --git a/app/pages/onboarding/complete.vue b/app/pages/onboarding/complete.vue
index 64c7e1a5..0daf7345 100644
--- a/app/pages/onboarding/complete.vue
+++ b/app/pages/onboarding/complete.vue
@@ -69,7 +69,8 @@ async function onComplete() {
console.error(error)
toast.add({
title: $t('onboarding.complete.setupFailedTitle'),
- description: error.data?.message || $t('onboarding.complete.setupFailedDescription'),
+ description:
+ error.data?.message || $t('onboarding.complete.setupFailedDescription'),
color: 'error',
})
} finally {
diff --git a/app/pages/onboarding/index.vue b/app/pages/onboarding/index.vue
index 847473ec..85e8759c 100644
--- a/app/pages/onboarding/index.vue
+++ b/app/pages/onboarding/index.vue
@@ -29,8 +29,12 @@ definePageMeta({
/>
</div>
<div>
- <h3 class="font-medium text-white">{{ $t('onboarding.welcome.cards.admin.title') }}</h3>
- <p class="text-sm text-neutral-400 mt-1">{{ $t('onboarding.welcome.cards.admin.description') }}</p>
+ <h3 class="font-medium text-white">
+ {{ $t('onboarding.welcome.cards.admin.title') }}
+ </h3>
+ <p class="text-sm text-neutral-400 mt-1">
+ {{ $t('onboarding.welcome.cards.admin.description') }}
+ </p>
</div>
</div>
@@ -46,8 +50,12 @@ definePageMeta({
/>
</div>
<div>
- <h3 class="font-medium text-white">{{ $t('onboarding.welcome.cards.site.title') }}</h3>
- <p class="text-sm text-neutral-400 mt-1">{{ $t('onboarding.welcome.cards.site.description') }}</p>
+ <h3 class="font-medium text-white">
+ {{ $t('onboarding.welcome.cards.site.title') }}
+ </h3>
+ <p class="text-sm text-neutral-400 mt-1">
+ {{ $t('onboarding.welcome.cards.site.description') }}
+ </p>
</div>
</div>
@@ -63,7 +71,9 @@ definePageMeta({
/>
</div>
<div>
- <h3 class="font-medium text-white">{{ $t('onboarding.welcome.cards.storage.title') }}</h3>
+ <h3 class="font-medium text-white">
+ {{ $t('onboarding.welcome.cards.storage.title') }}
+ </h3>
<p class="text-sm text-neutral-400 mt-1">
{{ $t('onboarding.welcome.cards.storage.description') }}
</p>
@@ -82,7 +92,9 @@ definePageMeta({
/>
</div>
<div>
- <h3 class="font-medium text-white">{{ $t('onboarding.welcome.cards.map.title') }}</h3>
+ <h3 class="font-medium text-white">
+ {{ $t('onboarding.welcome.cards.map.title') }}
+ </h3>
<p class="text-sm text-neutral-400 mt-1">
{{ $t('onboarding.welcome.cards.map.description') }}
</p>
diff --git a/app/pages/signin.vue b/app/pages/signin.vue
index 36580929..bf7324f8 100644
--- a/app/pages/signin.vue
+++ b/app/pages/signin.vue
@@ -37,7 +37,8 @@ const onAuthSubmit = async (event: any) => {
toast.add({
color: 'error',
title: $t('auth.messages.loginFailed.title'),
- description: error?.data?.message || $t('auth.messages.loginFailed.description'),
+ description:
+ error?.data?.message || $t('auth.messages.loginFailed.description'),
})
})
.finally(() => {
diff --git a/app/plugins/custom-scripts.ts b/app/plugins/custom-scripts.ts
index 54d56fc8..6e47f799 100644
--- a/app/plugins/custom-scripts.ts
+++ b/app/plugins/custom-scripts.ts
@@ -1,4 +1,4 @@
-import { parseScriptTags } from '~/utils/parseScriptTags'
+import { parseScriptTags } from '#gallery/utils/parseScriptTags'
/**
* 将管理员配置的 <script> 标签注入到页面 <head> 和 <body> 中。
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 053507c4..411b3f02 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -1,10 +1,11 @@
import pkg from './package.json'
import type { AnalyticsConfig } from './shared/types/config'
-import i18n, { dayjsLocales } from './i18n/i18n.options'
+import { dayjsLocales } from './packages/gallery/i18n/i18n.options'
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
- extends: ['./packages/console'],
+ extends: ['./packages/console', './packages/gallery'],
+ dir: { shared: 'packages/gallery/shared' },
compatibilityDate: '2025-07-15',
devtools: { enabled: true },
@@ -26,8 +27,6 @@ export default defineNuxtConfig({
'nuxt-gtag',
],
- css: ['~/assets/css/tailwind.css'],
-
components: [{ path: '~/components/ui', pathPrefix: false }, '~/components'],
runtimeConfig: {
@@ -273,6 +272,4 @@ export default defineNuxtConfig({
],
defaultTimezone: 'Asia/Shanghai',
},
-
- i18n,
})
diff --git a/package.json b/package.json
index d205734a..0e21be72 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,8 @@
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs",
"check:packages": "node scripts/check-package-boundaries.mjs && pnpm --filter @chronoframe/jobs --filter @chronoframe/processing --filter @chronoframe/database --filter @chronoframe/core --filter @chronoframe/contracts --filter @chronoframe/storage --filter @chronoframe/media --filter @chronoframe/geocoding type-check",
- "test": "node --experimental-strip-types --test tests/*.test.ts"
+ "test": "node --experimental-strip-types --test tests/*.test.ts",
+ "check:ui": "node scripts/check-ui-boundaries.mjs"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.1149.0",
@@ -89,10 +90,11 @@
"@chronoframe/media": "workspace:*",
"@chronoframe/geocoding": "workspace:*",
"@chronoframe/core": "workspace:*",
- "h3": "^1.15.11",
"@chronoframe/database": "workspace:*",
"@chronoframe/jobs": "workspace:*",
- "@chronoframe/processing": "workspace:*"
+ "@chronoframe/processing": "workspace:*",
+ "@chronoframe/gallery": "workspace:*",
+ "@chronoframe/console": "workspace:*"
},
"packageManager": "[email protected]",
"devDependencies": {
diff --git a/packages/console/app/components/AdminTours.client.vue b/packages/console/app/components/AdminTours.client.vue
index 5c9c2ce8..91d92ceb 100644
--- a/packages/console/app/components/AdminTours.client.vue
+++ b/packages/console/app/components/AdminTours.client.vue
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { Driver, DriveStep } from 'driver.js'
-import { tourIds, type TourId } from '~~/shared/types/tours'
+import { tourIds, type TourId } from '@chronoframe/gallery/shared/types/tours'
const route = useRoute()
const { user } = useUserSession()
const { records, ready, busy, revision, load, update } = useTours()
diff --git a/packages/console/app/components/TourControls.vue b/packages/console/app/components/TourControls.vue
index 6f8d90d1..e77b988b 100644
--- a/packages/console/app/components/TourControls.vue
+++ b/packages/console/app/components/TourControls.vue
@@ -1,5 +1,8 @@
<script setup lang="ts">
-import { tourIds, type TourStatus } from '~~/shared/types/tours'
+import {
+ tourIds,
+ type TourStatus,
+} from '@chronoframe/gallery/shared/types/tours'
defineProps<{ debug?: boolean }>()
const { records, ready, busy, update } = useTours()
diff --git a/packages/console/app/components/setting/SettingAvatar.vue b/packages/console/app/components/setting/SettingAvatar.vue
index 0d4de9bf..d19c3775 100644
--- a/packages/console/app/components/setting/SettingAvatar.vue
+++ b/packages/console/app/components/setting/SettingAvatar.vue
@@ -2,11 +2,11 @@
const consoleApi = useConsoleApi()
import { settingsFieldCommitKey } from '#console/composables/useSettingsForm'
-import { getAvatarInputType } from '~/utils/avatar'
+import { getAvatarInputType } from '#gallery/utils/avatar'
import {
AVATAR_ALLOWED_MIME_TYPES,
AVATAR_MAX_INPUT_BYTES,
-} from '~~/shared/utils/avatar'
+} from '@chronoframe/gallery/shared/utils/avatar'
interface Props {
modelValue?: string | null
diff --git a/packages/console/app/components/setting/SettingField.vue b/packages/console/app/components/setting/SettingField.vue
index b3be1bb2..1dce45b5 100644
--- a/packages/console/app/components/setting/SettingField.vue
+++ b/packages/console/app/components/setting/SettingField.vue
@@ -1,6 +1,9 @@
<script setup lang="ts">
import { resolveComponent } from 'vue'
-import type { FieldDescriptor, FieldUIType } from '~~/shared/types/settings'
+import type {
+ FieldDescriptor,
+ FieldUIType,
+} from '@chronoframe/gallery/shared/types/settings'
interface Props {
field: FieldDescriptor
diff --git a/packages/console/app/components/setting/SettingSection.vue b/packages/console/app/components/setting/SettingSection.vue
index 42cdbbf7..422ebf26 100644
--- a/packages/console/app/components/setting/SettingSection.vue
+++ b/packages/console/app/components/setting/SettingSection.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import type { FieldDescriptor } from '~~/shared/types/settings'
+import type { FieldDescriptor } from '@chronoframe/gallery/shared/types/settings'
interface Props {
title: string
diff --git a/packages/console/app/components/ui/UploadQueueItem.vue b/packages/console/app/components/ui/UploadQueueItem.vue
index 0a712f41..e4783730 100644
--- a/packages/console/app/components/ui/UploadQueueItem.vue
+++ b/packages/console/app/components/ui/UploadQueueItem.vue
@@ -1,14 +1,14 @@
<script lang="ts" setup>
import { motion, AnimatePresence } from 'motion-v'
import { computed, ref, watch, nextTick, onUnmounted } from 'vue'
-import type { UploadingFile } from '~~/shared/types/uploading-file'
+import type { UploadingFile } from '@chronoframe/gallery/shared/types/uploading-file'
import {
UploadQueueStatus,
isAbortableUploadStatus,
isActiveUploadStatus,
isDismissibleUploadStatus,
isSkippedOrBlockedUploadStatus,
-} from '~~/shared/utils/upload-status'
+} from '@chronoframe/gallery/shared/utils/upload-status'
const props = defineProps<{
uploadingFile: UploadingFile
diff --git a/packages/console/app/components/ui/UploadQueuePanel.vue b/packages/console/app/components/ui/UploadQueuePanel.vue
index 745153cf..c9c196c1 100644
--- a/packages/console/app/components/ui/UploadQueuePanel.vue
+++ b/packages/console/app/components/ui/UploadQueuePanel.vue
@@ -1,13 +1,13 @@
<script lang="ts" setup>
import { motion, AnimatePresence } from 'motion-v'
-import type { UploadingFile } from '~~/shared/types/uploading-file'
+import type { UploadingFile } from '@chronoframe/gallery/shared/types/uploading-file'
import {
UploadQueueStatus,
isAbortableUploadStatus,
isActiveUploadStatus,
isQueuedUploadStatus,
isSkippedOrBlockedUploadStatus,
-} from '~~/shared/utils/upload-status'
+} from '@chronoframe/gallery/shared/utils/upload-status'
const props = defineProps<{
uploadingFiles: Map<string, UploadingFile>
diff --git a/packages/console/app/composables/useSettingsForm.ts b/packages/console/app/composables/useSettingsForm.ts
index 593134c7..ad29c4b1 100644
--- a/packages/console/app/composables/useSettingsForm.ts
+++ b/packages/console/app/composables/useSettingsForm.ts
@@ -2,7 +2,7 @@ import type { InjectionKey } from 'vue'
import type {
FieldDescriptor,
SettingsFieldsResponse,
-} from '~~/shared/types/settings'
+} from '@chronoframe/gallery/shared/types/settings'
export const settingsFieldCommitKey: InjectionKey<
(fieldKey: string, value: any) => void
diff --git a/packages/console/app/composables/useTours.ts b/packages/console/app/composables/useTours.ts
index b6d0bec1..4754069d 100644
--- a/packages/console/app/composables/useTours.ts
+++ b/packages/console/app/composables/useTours.ts
@@ -3,7 +3,7 @@ import {
type TourId,
type TourRecords,
type TourStatus,
-} from '~~/shared/types/tours'
+} from '@chronoframe/gallery/shared/types/tours'
export function useTours() {
const consoleApi = useConsoleApi()
const records = useState<TourRecords>(
diff --git a/packages/console/app/composables/useUpload.ts b/packages/console/app/composables/useUpload.ts
index 7b8a98a9..b244c1ee 100644
--- a/packages/console/app/composables/useUpload.ts
+++ b/packages/console/app/composables/useUpload.ts
@@ -1,9 +1,12 @@
-import { UPLOAD_CHUNK_SIZE } from '~~/shared/utils/upload'
+import { UPLOAD_CHUNK_SIZE } from '@chronoframe/gallery/shared/utils/upload'
import {
UploadTransportStatus,
isInFlightTransportStatus,
-} from '~~/shared/utils/upload-status'
-import type { UploadPlan, UploadPart } from '~~/shared/types/upload'
+} from '@chronoframe/gallery/shared/utils/upload-status'
+import type {
+ UploadPlan,
+ UploadPart,
+} from '@chronoframe/gallery/shared/types/upload'
export interface UploadProgress {
loaded: number
diff --git a/packages/console/app/pages/dashboard/albums.vue b/packages/console/app/pages/dashboard/albums.vue
index a5b6185e..6d51bb2d 100644
--- a/packages/console/app/pages/dashboard/albums.vue
+++ b/packages/console/app/pages/dashboard/albums.vue
@@ -7,7 +7,7 @@ import {
ALBUM_PASSWORD_MAX_LENGTH,
ALBUM_PASSWORD_MIN_LENGTH,
isValidAlbumPasswordLength,
-} from '~~/shared/utils/album'
+} from '@chronoframe/gallery/shared/utils/album'
definePageMeta({
layout: 'dashboard',
diff --git a/packages/console/app/pages/dashboard/index.vue b/packages/console/app/pages/dashboard/index.vue
index bedd1b5d..55640803 100644
--- a/packages/console/app/pages/dashboard/index.vue
+++ b/packages/console/app/pages/dashboard/index.vue
@@ -1,6 +1,6 @@
<script lang="ts" setup>
-import '@/assets/css/heatmap.css'
-import type { CalendarItem } from '~/components/ui/CalendarHeatmap/Heatmap'
+import '#gallery/assets/css/heatmap.css'
+import type { CalendarItem } from '#gallery/components/ui/CalendarHeatmap/Heatmap'
definePageMeta({
layout: 'dashboard',
diff --git a/packages/console/app/pages/dashboard/photos.vue b/packages/console/app/pages/dashboard/photos.vue
index 97ab7151..5e07be38 100644
--- a/packages/console/app/pages/dashboard/photos.vue
+++ b/packages/console/app/pages/dashboard/photos.vue
@@ -4,22 +4,22 @@ const consoleApi = useConsoleApi()
import type { FormSubmitEvent, TableColumn } from '@nuxt/ui'
import type { UploadPreparationResponse } from '@chronoframe/contracts/upload'
import type { Album, Photo } from '@chronoframe/contracts/resources'
-import type { UploadingFile } from '~~/shared/types/uploading-file'
+import type { UploadingFile } from '@chronoframe/gallery/shared/types/uploading-file'
import {
MAX_ALBUM_PHOTOS_PER_REQUEST,
type AddPhotosToAlbumResult,
-} from '~~/shared/utils/album'
-import { QueueWarningCode } from '~~/shared/utils/queue-warning'
+} from '@chronoframe/gallery/shared/utils/album'
+import { QueueWarningCode } from '@chronoframe/gallery/shared/utils/queue-warning'
import {
UploadQueueStatus,
UploadTransportStatus,
isAbortableUploadStatus,
isClearableUploadStatus,
isInFlightTransportStatus,
-} from '~~/shared/utils/upload-status'
+} from '@chronoframe/gallery/shared/utils/upload-status'
import { h, resolveComponent } from 'vue'
import { Icon, UBadge } from '#components'
-import ThumbImage from '~/components/ui/ThumbImage.vue'
+import ThumbImage from '#gallery/components/ui/ThumbImage.vue'
const UCheckbox = resolveComponent('UCheckbox')
const Rating = resolveComponent('Rating')
diff --git a/packages/console/app/pages/dashboard/queue.vue b/packages/console/app/pages/dashboard/queue.vue
index cccf879d..c04ea92a 100644
--- a/packages/console/app/pages/dashboard/queue.vue
+++ b/packages/console/app/pages/dashboard/queue.vue
@@ -3,7 +3,7 @@ const consoleApi = useConsoleApi()
import { h, resolveComponent } from 'vue'
import type { TableColumn } from '@nuxt/ui'
-import { QueueWarningCode } from '~~/shared/utils/queue-warning'
+import { QueueWarningCode } from '@chronoframe/gallery/shared/utils/queue-warning'
const UButton = resolveComponent('UButton')
diff --git a/packages/console/app/pages/dashboard/settings/storage.vue b/packages/console/app/pages/dashboard/settings/storage.vue
index 051c6df6..f1218ef1 100644
--- a/packages/console/app/pages/dashboard/settings/storage.vue
+++ b/packages/console/app/pages/dashboard/settings/storage.vue
@@ -2,7 +2,7 @@
const consoleApi = useConsoleApi()
import { z } from 'zod'
-import type { StorageConfig } from '~~/shared/types/storage'
+import type { StorageConfig } from '@chronoframe/gallery/shared/types/storage'
definePageMeta({
layout: 'dashboard',
diff --git a/packages/console/app/pages/dashboard/settings/system.vue b/packages/console/app/pages/dashboard/settings/system.vue
index 4fc2cacd..6b37c2eb 100644
--- a/packages/console/app/pages/dashboard/settings/system.vue
+++ b/packages/console/app/pages/dashboard/settings/system.vue
@@ -1,5 +1,5 @@
<script lang="ts" setup>
-import type { FieldDescriptor } from '~~/shared/types/settings'
+import type { FieldDescriptor } from '@chronoframe/gallery/shared/types/settings'
definePageMeta({
layout: 'dashboard',
diff --git a/packages/console/package.json b/packages/console/package.json
index aba573ce..b2b89119 100644
--- a/packages/console/package.json
+++ b/packages/console/package.json
@@ -6,5 +6,16 @@
"license": "MIT",
"exports": {
".": "./nuxt.config.ts"
+ },
+ "dependencies": {
+ "@chronoframe/gallery": "workspace:*",
+ "driver.js": "^1.9.0",
+ "es-toolkit": "^1.52.0",
+ "vue": "^3.5.43",
+ "@nuxt/ui": "^4.11.3",
+ "motion-v": "^2.6.0",
+ "@vueuse/core": "^14.4.0",
+ "@chronoframe/contracts": "workspace:*",
+ "zod": "^4.6.6"
}
}
diff --git a/packages/gallery/README.md b/packages/gallery/README.md
new file mode 100644
index 00000000..eb2ac6de
--- /dev/null
+++ b/packages/gallery/README.md
@@ -0,0 +1,11 @@
+# @chronoframe/gallery
+
+Nuxt layer for public gallery routes, albums and visitor grants, photo viewing,
+filters, maps and common UI. It owns public settings state, shared presentation
+utilities and translations. Console-only settings forms live in the console
+layer; gallery settings requests use only the public secret-filtered endpoint.
+
+The host supplies the session adapter and `runtimeConfig.public.gallery.apiBase`.
+The entry owns its photo query and chooses public or authenticated data; the
+viewer accepts that collection. This layer never imports console or server
+implementations. Shared source modules are available through `./shared/*`.
diff --git a/app/app.config.ts b/packages/gallery/app/app.config.ts
similarity index 100%
rename from app/app.config.ts
rename to packages/gallery/app/app.config.ts
diff --git a/app/assets/css/heatmap.css b/packages/gallery/app/assets/css/heatmap.css
similarity index 100%
rename from app/assets/css/heatmap.css
rename to packages/gallery/app/assets/css/heatmap.css
diff --git a/app/assets/css/tailwind.css b/packages/gallery/app/assets/css/tailwind.css
similarity index 97%
rename from app/assets/css/tailwind.css
rename to packages/gallery/app/assets/css/tailwind.css
index 247f3efe..30219b97 100644
--- a/app/assets/css/tailwind.css
+++ b/packages/gallery/app/assets/css/tailwind.css
@@ -1,5 +1,7 @@
@import 'tailwindcss';
@import '@nuxt/ui';
+@source '../../../../console/app';
+@source '../../';
:root {
/* New text-autospace property */
diff --git a/app/assets/images/noise.svg b/packages/gallery/app/assets/images/noise.svg
similarity index 100%
rename from app/assets/images/noise.svg
rename to packages/gallery/app/assets/images/noise.svg
diff --git a/app/assets/mapStyles/chronoframe_dark.json b/packages/gallery/app/assets/mapStyles/chronoframe_dark.json
similarity index 100%
rename from app/assets/mapStyles/chronoframe_dark.json
rename to packages/gallery/app/assets/mapStyles/chronoframe_dark.json
diff --git a/app/assets/mapStyles/chronoframe_light.json b/packages/gallery/app/assets/mapStyles/chronoframe_light.json
similarity index 100%
rename from app/assets/mapStyles/chronoframe_light.json
rename to packages/gallery/app/assets/mapStyles/chronoframe_light.json
diff --git a/app/components/AlbumProtectionWarning.vue b/packages/gallery/app/components/AlbumProtectionWarning.vue
similarity index 100%
rename from app/components/AlbumProtectionWarning.vue
rename to packages/gallery/app/components/AlbumProtectionWarning.vue
diff --git a/app/components/Histogram.vue b/packages/gallery/app/components/Histogram.vue
similarity index 93%
rename from app/components/Histogram.vue
rename to packages/gallery/app/components/Histogram.vue
index c7f63262..4a04aedd 100644
--- a/app/components/Histogram.vue
+++ b/packages/gallery/app/components/Histogram.vue
@@ -4,7 +4,7 @@ import {
calculateHistogramCompressed,
drawHistogramToCanvas,
type HistogramDataCompressed,
-} from '~/libs/histogram'
+} from '#gallery/libs/histogram'
const props = defineProps<{
thumbnailUrl: string
@@ -115,7 +115,9 @@ onUnmounted(cleanup)
name="tabler:loader"
class="text-xl animate-spin"
/>
- <span class="text-xs font-medium">{{ $t('ui.histogram.rendering') }}</span>
+ <span class="text-xs font-medium">{{
+ $t('ui.histogram.rendering')
+ }}</span>
</div>
</Transition>
<Transition name="fade">
@@ -127,7 +129,9 @@ onUnmounted(cleanup)
name="tabler:alert-triangle"
class="text-xl"
/>
- <span class="text-xs font-medium">{{ $t('ui.histogram.loadError') }}</span>
+ <span class="text-xs font-medium">{{
+ $t('ui.histogram.loadError')
+ }}</span>
</div>
</Transition>
<Transition name="fade">
diff --git a/app/components/OgImage/Home.takumi.vue b/packages/gallery/app/components/OgImage/Home.takumi.vue
similarity index 100%
rename from app/components/OgImage/Home.takumi.vue
rename to packages/gallery/app/components/OgImage/Home.takumi.vue
diff --git a/app/components/OgImage/Photo.takumi.vue b/packages/gallery/app/components/OgImage/Photo.takumi.vue
similarity index 83%
rename from app/components/OgImage/Photo.takumi.vue
rename to packages/gallery/app/components/OgImage/Photo.takumi.vue
index 38d4970e..b02375ce 100644
--- a/app/components/OgImage/Photo.takumi.vue
+++ b/packages/gallery/app/components/OgImage/Photo.takumi.vue
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { Icon as IconifyIcon, addIcon } from '@iconify/vue'
import { init as initIconBundle } from '#build/nuxt-icon-client-bundle'
-import { formatCameraInfo } from '~/utils/camera'
+import { formatCameraInfo } from '#gallery/utils/camera'
initIconBundle(addIcon)
@@ -12,7 +12,12 @@ interface PhotoProps {
locationFallbackOrder?: string
}
-const { photo, appTitle: appTitleProp, locationPreferredLevel, locationFallbackOrder } = defineProps<PhotoProps>()
+const {
+ photo,
+ appTitle: appTitleProp,
+ locationPreferredLevel,
+ locationFallbackOrder,
+} = defineProps<PhotoProps>()
const { $i18n } = useNuxtApp()
const locationLabel = useLocationLabel(() => ({
@@ -31,13 +36,19 @@ const resolvedAppTitle = computed(() => {
return 'ChronoFrame'
})
-const headline = computed(() => (photo ? $i18n.t('title.fallback.photo') : 'ChronoFrame'))
-const title = computed(() => (photo?.title || resolvedAppTitle.value).slice(0, 60))
-const description = computed(() => (photo ? photo.description || '' : resolvedAppTitle.value).slice(0, 200))
-const thumbnailUrl = computed(() =>
+const headline = computed(() =>
+ photo ? $i18n.t('title.fallback.photo') : 'ChronoFrame',
+)
+const title = computed(() =>
+ (photo?.title || resolvedAppTitle.value).slice(0, 60),
+)
+const description = computed(() =>
+ (photo ? photo.description || '' : resolvedAppTitle.value).slice(0, 200),
+)
+const thumbnailUrl = computed(() =>
photo?.thumbnailKey && photo.thumbnailUrl
- ? `/thumb/${encodeURIComponent(photo.thumbnailUrl)}`
- : undefined
+ ? `/thumb/${encodeURIComponent(photo.thumbnailUrl)}`
+ : undefined,
)
</script>
@@ -86,9 +97,7 @@ const thumbnailUrl = computed(() =>
v-if="locationLabel(photo)"
class="flex flex-row items-center gap-1"
>
- <span
- class="og-photo__icon og-photo__icon--meta text-neutral-300"
- >
+ <span class="og-photo__icon og-photo__icon--meta text-neutral-300">
<IconifyIcon
class="og-photo__svg og-photo__svg--meta"
icon="tabler:map-pin"
@@ -106,9 +115,7 @@ const thumbnailUrl = computed(() =>
v-if="photo.exif?.Model"
class="flex flex-row items-center gap-1"
>
- <span
- class="og-photo__icon og-photo__icon--meta text-neutral-300"
- >
+ <span class="og-photo__icon og-photo__icon--meta text-neutral-300">
<IconifyIcon
class="og-photo__svg og-photo__svg--meta"
icon="tabler:camera"
@@ -131,9 +138,7 @@ const thumbnailUrl = computed(() =>
<div
class="og-photo__exif-card rounded-3xl px-6 py-4 flex items-center gap-3"
>
- <span
- class="og-photo__icon og-photo__icon--exif text-amber-400"
- >
+ <span class="og-photo__icon og-photo__icon--exif text-amber-400">
<IconifyIcon
class="og-photo__svg og-photo__svg--exif"
icon="streamline:image-accessories-lenses-photos-camera-shutter-picture-photography-pictures-photo-lens"
@@ -150,9 +155,7 @@ const thumbnailUrl = computed(() =>
<div
class="og-photo__exif-card rounded-3xl px-6 py-4 flex items-center gap-3"
>
- <span
- class="og-photo__icon og-photo__icon--exif text-purple-400"
- >
+ <span class="og-photo__icon og-photo__icon--exif text-purple-400">
<IconifyIcon
class="og-photo__svg og-photo__svg--exif"
icon="tabler:aperture"
@@ -167,9 +170,7 @@ const thumbnailUrl = computed(() =>
<div
class="og-photo__exif-card rounded-3xl px-6 py-4 flex items-center gap-3"
>
- <span
- class="og-photo__icon og-photo__icon--exif text-emerald-400"
- >
+ <span class="og-photo__icon og-photo__icon--exif text-emerald-400">
<IconifyIcon
class="og-photo__svg og-photo__svg--exif"
icon="material-symbols:shutter-speed"
@@ -184,9 +185,7 @@ const thumbnailUrl = computed(() =>
<div
class="og-photo__exif-card rounded-3xl px-6 py-4 flex items-center gap-3"
>
- <span
- class="og-photo__icon og-photo__icon--exif text-sky-400"
- >
+ <span class="og-photo__icon og-photo__icon--exif text-sky-400">
<IconifyIcon
class="og-photo__svg og-photo__svg--exif"
icon="carbon:iso-outline"
@@ -205,7 +204,7 @@ const thumbnailUrl = computed(() =>
<style scoped>
.og-photo {
- font-family: "Rubik", "Noto Sans SC", sans-serif;
+ font-family: 'Rubik', 'Noto Sans SC', sans-serif;
}
.og-photo__gradient {
diff --git a/app/components/PhotosProvider.vue b/packages/gallery/app/components/PhotosProvider.vue
similarity index 100%
rename from app/components/PhotosProvider.vue
rename to packages/gallery/app/components/PhotosProvider.vue
diff --git a/app/components/album/Listing.vue b/packages/gallery/app/components/album/Listing.vue
similarity index 98%
rename from app/components/album/Listing.vue
rename to packages/gallery/app/components/album/Listing.vue
index 54720859..86ec4c3c 100644
--- a/app/components/album/Listing.vue
+++ b/packages/gallery/app/components/album/Listing.vue
@@ -1,7 +1,9 @@
<script lang="ts" setup>
+const galleryApi = useGalleryApi()
+
import { motion } from 'motion-v'
-import { getAlbumListState } from '~/utils/albumListState'
-import { sampleWaterfallPhotos } from '~/utils/sampleWaterfallPhotos'
+import { getAlbumListState } from '#gallery/utils/albumListState'
+import { sampleWaterfallPhotos } from '#gallery/utils/sampleWaterfallPhotos'
import type { Album } from '@chronoframe/contracts/resources'
interface AlbumWithPhotos extends Album {
photoIds?: string[]
@@ -14,7 +16,7 @@ const {
data: albums,
status,
refresh,
-} = useAsyncData<AlbumWithPhotos[]>('albums', () => $fetch('/api/albums'), {
+} = useAsyncData<AlbumWithPhotos[]>('albums', () => galleryApi('/api/albums'), {
watch: [],
})
diff --git a/app/components/debug/Control.vue b/packages/gallery/app/components/debug/Control.vue
similarity index 96%
rename from app/components/debug/Control.vue
rename to packages/gallery/app/components/debug/Control.vue
index b37bcd74..67c77516 100644
--- a/app/components/debug/Control.vue
+++ b/packages/gallery/app/components/debug/Control.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import type { DebugControl, DebugValue } from '~/types/debug'
+import type { DebugControl, DebugValue } from '#gallery/types/debug'
const props = defineProps<{ control: DebugControl }>()
const store = useDebugStore()
const value = computed(() =>
diff --git a/app/components/debug/Panel.vue b/packages/gallery/app/components/debug/Panel.vue
similarity index 99%
rename from app/components/debug/Panel.vue
rename to packages/gallery/app/components/debug/Panel.vue
index aae45ff1..2ad943ad 100644
--- a/app/components/debug/Panel.vue
+++ b/packages/gallery/app/components/debug/Panel.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import FloatingWindow from '~/components/ui/FloatingWindow/FloatingWindow.vue'
+import FloatingWindow from '#gallery/components/ui/FloatingWindow/FloatingWindow.vue'
const store = useDebugStore()
const route = useRoute()
const colorMode = useColorMode()
diff --git a/app/components/icon/TablerStar.vue b/packages/gallery/app/components/icon/TablerStar.vue
similarity index 100%
rename from app/components/icon/TablerStar.vue
rename to packages/gallery/app/components/icon/TablerStar.vue
diff --git a/app/components/icon/TablerStarFilled.vue b/packages/gallery/app/components/icon/TablerStarFilled.vue
similarity index 100%
rename from app/components/icon/TablerStarFilled.vue
rename to packages/gallery/app/components/icon/TablerStarFilled.vue
diff --git a/app/components/icon/TablerStarHalfFilled.vue b/packages/gallery/app/components/icon/TablerStarHalfFilled.vue
similarity index 100%
rename from app/components/icon/TablerStarHalfFilled.vue
rename to packages/gallery/app/components/icon/TablerStarHalfFilled.vue
diff --git a/app/components/loader/Avatar.vue b/packages/gallery/app/components/loader/Avatar.vue
similarity index 100%
rename from app/components/loader/Avatar.vue
rename to packages/gallery/app/components/loader/Avatar.vue
diff --git a/app/components/map/ClusterPin.vue b/packages/gallery/app/components/map/ClusterPin.vue
similarity index 96%
rename from app/components/map/ClusterPin.vue
rename to packages/gallery/app/components/map/ClusterPin.vue
index fab9f4b5..cac34eca 100644
--- a/app/components/map/ClusterPin.vue
+++ b/packages/gallery/app/components/map/ClusterPin.vue
@@ -2,7 +2,7 @@
import { motion } from 'motion-v'
import ThumbImage from '../ui/ThumbImage.vue'
import { twMerge } from 'tailwind-merge'
-import type { ClusterPoint } from '~~/shared/types/map'
+import type { ClusterPoint } from '@chronoframe/gallery/shared/types/map'
const props = withDefaults(
defineProps<{
@@ -77,7 +77,8 @@ const sizeDelta = computed(() => {
<ThumbImage
:src="representativePhoto.thumbnailUrl!"
:alt="
- representativePhoto.title || $t('map.cluster.altFallback', { id: representativePhoto.id })
+ representativePhoto.title ||
+ $t('map.cluster.altFallback', { id: representativePhoto.id })
"
:thumbhash="representativePhoto.thumbnailHash"
:threshold="0.1"
@@ -176,7 +177,10 @@ const sizeDelta = computed(() => {
>
<ThumbImage
:src="photo.thumbnailUrl!"
- :alt="photo.title || $t('map.photo.altFallback', { id: photo.id })"
+ :alt="
+ photo.title ||
+ $t('map.photo.altFallback', { id: photo.id })
+ "
:thumbhash="photo.thumbnailHash"
:threshold="0.1"
root-margin="200px"
diff --git a/app/components/map/LocationPicker.vue b/packages/gallery/app/components/map/LocationPicker.vue
similarity index 98%
rename from app/components/map/LocationPicker.vue
rename to packages/gallery/app/components/map/LocationPicker.vue
index 35943ce0..3760e312 100644
--- a/app/components/map/LocationPicker.vue
+++ b/packages/gallery/app/components/map/LocationPicker.vue
@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { onBeforeUnmount, ref, watch } from 'vue'
-import type { MapInstance } from '~~/shared/types/map'
+import type { MapInstance } from '@chronoframe/gallery/shared/types/map'
const props = withDefaults(
defineProps<{
diff --git a/app/components/map/PhotoPin.vue b/packages/gallery/app/components/map/PhotoPin.vue
similarity index 93%
rename from app/components/map/PhotoPin.vue
rename to packages/gallery/app/components/map/PhotoPin.vue
index 1616999e..92ab5e3e 100644
--- a/app/components/map/PhotoPin.vue
+++ b/packages/gallery/app/components/map/PhotoPin.vue
@@ -2,7 +2,7 @@
import { motion } from 'motion-v'
import ThumbImage from '../ui/ThumbImage.vue'
import { twMerge } from 'tailwind-merge'
-import type { ClusterPoint } from '~~/shared/types/map'
+import type { ClusterPoint } from '@chronoframe/gallery/shared/types/map'
const props = withDefaults(
defineProps<{
@@ -42,11 +42,17 @@ const parseExifNumber = (value: unknown): number | null => {
return null
}
- const fractionMatch = trimmed.match(/^(-?\d+(?:\.\d+)?)\s*\/\s*(-?\d+(?:\.\d+)?)$/)
+ const fractionMatch = trimmed.match(
+ /^(-?\d+(?:\.\d+)?)\s*\/\s*(-?\d+(?:\.\d+)?)$/,
+ )
if (fractionMatch) {
const numerator = Number(fractionMatch[1])
const denominator = Number(fractionMatch[2])
- if (!Number.isFinite(numerator) || !Number.isFinite(denominator) || denominator === 0) {
+ if (
+ !Number.isFinite(numerator) ||
+ !Number.isFinite(denominator) ||
+ denominator === 0
+ ) {
return null
}
return numerator / denominator
@@ -63,7 +69,8 @@ const parseExifNumber = (value: unknown): number | null => {
const focalLengthValue = computed(() => {
return parseExifNumber(
- marker.value.exif?.FocalLengthIn35mmFormat ?? marker.value.exif?.FocalLength,
+ marker.value.exif?.FocalLengthIn35mmFormat ??
+ marker.value.exif?.FocalLength,
)
})
@@ -77,7 +84,8 @@ const altitudeValue = computed(() => {
return null
}
- const isBelowSeaLevel = marker.value.exif?.GPSAltitudeRef === 'Below Sea Level'
+ const isBelowSeaLevel =
+ marker.value.exif?.GPSAltitudeRef === 'Below Sea Level'
return isBelowSeaLevel ? -Math.abs(altitude) : altitude
})
@@ -303,14 +311,18 @@ const onClick = () => {
<div class="absolute inset-0 overflow-hidden rounded-full">
<ThumbImage
:src="marker.thumbnailUrl!"
- :alt="marker.title || $t('map.photo.altFallback', { id: marker.id })"
+ :alt="
+ marker.title || $t('map.photo.altFallback', { id: marker.id })
+ "
:thumbhash="marker.thumbnailHash"
:threshold="0.1"
root-margin="100px"
class="h-full w-full object-cover opacity-50"
/>
<div
- :class="twMerge('absolute inset-0', analysisVisual.overlayClass)"
+ :class="
+ twMerge('absolute inset-0', analysisVisual.overlayClass)
+ "
/>
</div>
@@ -388,7 +400,10 @@ const onClick = () => {
<div class="relative h-36 overflow-hidden">
<ThumbImage
:src="marker.thumbnailUrl!"
- :alt="marker.title || $t('map.photo.altFallback', { id: marker.id })"
+ :alt="
+ marker.title ||
+ $t('map.photo.altFallback', { id: marker.id })
+ "
:thumbhash="marker.thumbnailHash"
:threshold="0.1"
root-margin="200px"
@@ -404,7 +419,10 @@ const onClick = () => {
class="flex items-center gap-2 text-neutral-900 dark:text-white group/link"
>
<h3 class="flex-1 text-lg font-semibold truncate">
- {{ marker.title || $t('map.photo.altFallback', { id: marker.id }) }}
+ {{
+ marker.title ||
+ $t('map.photo.altFallback', { id: marker.id })
+ }}
</h3>
<Icon
name="tabler:external-link"
@@ -415,7 +433,9 @@ const onClick = () => {
<!-- Metadata -->
<div class="space-y-1">
<div
- v-if="locationLabel(marker) || marker.exif?.DateTimeOriginal"
+ v-if="
+ locationLabel(marker) || marker.exif?.DateTimeOriginal
+ "
class="flex items-center gap-1 text-xs text-neutral-600 dark:text-muted font-medium mb-2"
>
<div v-if="locationLabel(marker)">
diff --git a/app/components/map/Provider.vue b/packages/gallery/app/components/map/Provider.vue
similarity index 89%
rename from app/components/map/Provider.vue
rename to packages/gallery/app/components/map/Provider.vue
index 0efb9701..bc705fb2 100644
--- a/app/components/map/Provider.vue
+++ b/packages/gallery/app/components/map/Provider.vue
@@ -1,12 +1,16 @@
<script lang="ts" setup>
import type { AttributionControlOptions, StyleSpecification } from 'maplibre-gl'
import { twMerge } from 'tailwind-merge'
-import type { MapboxMap, MapInstance, MaplibreMap } from '~~/shared/types/map'
-import { useMapSetupNotice } from '~/composables/useMapSetupNotice'
-import { isMapServiceConfigured } from '~~/shared/utils/map-service'
+import type {
+ MapboxMap,
+ MapInstance,
+ MaplibreMap,
+} from '@chronoframe/gallery/shared/types/map'
+import { useMapSetupNotice } from '#gallery/composables/useMapSetupNotice'
+import { isMapServiceConfigured } from '@chronoframe/gallery/shared/utils/map-service'
-import ChronoFrameLightStyle from '~/assets/mapStyles/chronoframe_light.json'
-import ChronoFrameDarkStyle from '~/assets/mapStyles/chronoframe_dark.json'
+import ChronoFrameLightStyle from '#gallery/assets/mapStyles/chronoframe_light.json'
+import ChronoFrameDarkStyle from '#gallery/assets/mapStyles/chronoframe_dark.json'
const props = withDefaults(
defineProps<{
diff --git a/app/components/map/ProviderMarker.vue b/packages/gallery/app/components/map/ProviderMarker.vue
similarity index 100%
rename from app/components/map/ProviderMarker.vue
rename to packages/gallery/app/components/map/ProviderMarker.vue
diff --git a/app/components/map/SetupNotice.vue b/packages/gallery/app/components/map/SetupNotice.vue
similarity index 94%
rename from app/components/map/SetupNotice.vue
rename to packages/gallery/app/components/map/SetupNotice.vue
index 2bc46e7d..723d7e69 100644
--- a/app/components/map/SetupNotice.vue
+++ b/packages/gallery/app/components/map/SetupNotice.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { useMapSetupNotice } from '~/composables/useMapSetupNotice'
+import { useMapSetupNotice } from '#gallery/composables/useMapSetupNotice'
const { isOpen, isAdmin, dismiss } = useMapSetupNotice()
diff --git a/app/components/masonry/Item.vue b/packages/gallery/app/components/masonry/Item.vue
similarity index 100%
rename from app/components/masonry/Item.vue
rename to packages/gallery/app/components/masonry/Item.vue
diff --git a/app/components/masonry/Root.vue b/packages/gallery/app/components/masonry/Root.vue
similarity index 100%
rename from app/components/masonry/Root.vue
rename to packages/gallery/app/components/masonry/Root.vue
diff --git a/app/components/masonry/item/Actions.vue b/packages/gallery/app/components/masonry/item/Actions.vue
similarity index 100%
rename from app/components/masonry/item/Actions.vue
rename to packages/gallery/app/components/masonry/item/Actions.vue
diff --git a/app/components/masonry/item/Header.vue b/packages/gallery/app/components/masonry/item/Header.vue
similarity index 100%
rename from app/components/masonry/item/Header.vue
rename to packages/gallery/app/components/masonry/item/Header.vue
diff --git a/app/components/masonry/item/HeaderFixed.vue b/packages/gallery/app/components/masonry/item/HeaderFixed.vue
similarity index 100%
rename from app/components/masonry/item/HeaderFixed.vue
rename to packages/gallery/app/components/masonry/item/HeaderFixed.vue
diff --git a/app/components/masonry/item/HeaderFooter.vue b/packages/gallery/app/components/masonry/item/HeaderFooter.vue
similarity index 100%
rename from app/components/masonry/item/HeaderFooter.vue
rename to packages/gallery/app/components/masonry/item/HeaderFooter.vue
diff --git a/app/components/masonry/item/HeaderIdentity.vue b/packages/gallery/app/components/masonry/item/HeaderIdentity.vue
similarity index 100%
rename from app/components/masonry/item/HeaderIdentity.vue
rename to packages/gallery/app/components/masonry/item/HeaderIdentity.vue
diff --git a/app/components/masonry/item/HeaderStats.vue b/packages/gallery/app/components/masonry/item/HeaderStats.vue
similarity index 100%
rename from app/components/masonry/item/HeaderStats.vue
rename to packages/gallery/app/components/masonry/item/HeaderStats.vue
diff --git a/app/components/masonry/item/Photo.vue b/packages/gallery/app/components/masonry/item/Photo.vue
similarity index 99%
rename from app/components/masonry/item/Photo.vue
rename to packages/gallery/app/components/masonry/item/Photo.vue
index 224cf95c..92872b1e 100644
--- a/app/components/masonry/item/Photo.vue
+++ b/packages/gallery/app/components/masonry/item/Photo.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { formatCameraInfo } from '~/utils/camera'
+import { formatCameraInfo } from '#gallery/utils/camera'
import { motion, useDomRef } from 'motion-v'
interface Props {
diff --git a/app/components/overlay/FilterPanel.vue b/packages/gallery/app/components/overlay/FilterPanel.vue
similarity index 100%
rename from app/components/overlay/FilterPanel.vue
rename to packages/gallery/app/components/overlay/FilterPanel.vue
diff --git a/app/components/overlay/SortPanel.vue b/packages/gallery/app/components/overlay/SortPanel.vue
similarity index 100%
rename from app/components/overlay/SortPanel.vue
rename to packages/gallery/app/components/overlay/SortPanel.vue
diff --git a/app/components/photo/GalleryThumbnail.vue b/packages/gallery/app/components/photo/GalleryThumbnail.vue
similarity index 100%
rename from app/components/photo/GalleryThumbnail.vue
rename to packages/gallery/app/components/photo/GalleryThumbnail.vue
diff --git a/app/components/photo/InfoPanel.vue b/packages/gallery/app/components/photo/InfoPanel.vue
similarity index 98%
rename from app/components/photo/InfoPanel.vue
rename to packages/gallery/app/components/photo/InfoPanel.vue
index d9fe3058..8d402cbc 100644
--- a/app/components/photo/InfoPanel.vue
+++ b/packages/gallery/app/components/photo/InfoPanel.vue
@@ -1,10 +1,10 @@
<script setup lang="ts">
import { computed } from 'vue'
-import { hasValidCoordinates } from '~~/shared/utils/location'
+import { hasValidCoordinates } from '@chronoframe/gallery/shared/utils/location'
import { motion } from 'motion-v'
import type { NeededExif } from '../../../shared/types/photo'
import type { KVData } from './KVRenderer.vue'
-import { formatCameraInfo, formatLensInfo } from '~/utils/camera'
+import { formatCameraInfo, formatLensInfo } from '#gallery/utils/camera'
interface Props {
currentPhoto: Photo
@@ -28,7 +28,7 @@ const { localizeExif } = useExifLocalization()
const props = defineProps<Props>()
// 获取照片所属的相册
-const { data: _albums } = useFetch<Album[]>(
+const { data: _albums } = useGalleryFetch<Album[]>(
() => `/api/photos/${props.currentPhoto.id}/albums`,
{
watch: [() => props.currentPhoto.id],
diff --git a/app/components/photo/KVRenderer.vue b/packages/gallery/app/components/photo/KVRenderer.vue
similarity index 100%
rename from app/components/photo/KVRenderer.vue
rename to packages/gallery/app/components/photo/KVRenderer.vue
diff --git a/app/components/photo/LivePhotoIndicator.vue b/packages/gallery/app/components/photo/LivePhotoIndicator.vue
similarity index 100%
rename from app/components/photo/LivePhotoIndicator.vue
rename to packages/gallery/app/components/photo/LivePhotoIndicator.vue
diff --git a/app/components/photo/LoadingIndicator.vue b/packages/gallery/app/components/photo/LoadingIndicator.vue
similarity index 100%
rename from app/components/photo/LoadingIndicator.vue
rename to packages/gallery/app/components/photo/LoadingIndicator.vue
diff --git a/app/components/photo/MiniMap.vue b/packages/gallery/app/components/photo/MiniMap.vue
similarity index 97%
rename from app/components/photo/MiniMap.vue
rename to packages/gallery/app/components/photo/MiniMap.vue
index 34bbf127..95fc4d8f 100644
--- a/app/components/photo/MiniMap.vue
+++ b/packages/gallery/app/components/photo/MiniMap.vue
@@ -1,6 +1,9 @@
<script lang="ts" setup>
import { motion } from 'motion-v'
-import { isMapboxMap, type MapInstance } from '~~/shared/types/map'
+import {
+ isMapboxMap,
+ type MapInstance,
+} from '@chronoframe/gallery/shared/types/map'
const props = defineProps<{
photo: Photo
diff --git a/app/components/photo/ProgressiveImage.vue b/packages/gallery/app/components/photo/ProgressiveImage.vue
similarity index 99%
rename from app/components/photo/ProgressiveImage.vue
rename to packages/gallery/app/components/photo/ProgressiveImage.vue
index a645399c..d5990ec9 100644
--- a/app/components/photo/ProgressiveImage.vue
+++ b/packages/gallery/app/components/photo/ProgressiveImage.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { LoadingState, WebGLImageViewer } from '@chronoframe/webgl-image'
import type { LoadingIndicatorRef } from './LoadingIndicator.vue'
-import type { ImageLoaderManager } from '~/libs/image-loader-manager'
+import type { ImageLoaderManager } from '#gallery/libs/image-loader-manager'
interface Props {
src: string
diff --git a/app/components/photo/ReactionConfetti.vue b/packages/gallery/app/components/photo/ReactionConfetti.vue
similarity index 100%
rename from app/components/photo/ReactionConfetti.vue
rename to packages/gallery/app/components/photo/ReactionConfetti.vue
diff --git a/app/components/photo/ReactionPicker.vue b/packages/gallery/app/components/photo/ReactionPicker.vue
similarity index 100%
rename from app/components/photo/ReactionPicker.vue
rename to packages/gallery/app/components/photo/ReactionPicker.vue
diff --git a/app/components/photo/ShareModal.vue b/packages/gallery/app/components/photo/ShareModal.vue
similarity index 100%
rename from app/components/photo/ShareModal.vue
rename to packages/gallery/app/components/photo/ShareModal.vue
diff --git a/app/components/photo/Viewer.vue b/packages/gallery/app/components/photo/Viewer.vue
similarity index 99%
rename from app/components/photo/Viewer.vue
rename to packages/gallery/app/components/photo/Viewer.vue
index def8f074..d542675c 100644
--- a/app/components/photo/Viewer.vue
+++ b/packages/gallery/app/components/photo/Viewer.vue
@@ -1,4 +1,6 @@
<script setup lang="ts">
+const galleryApi = useGalleryApi()
+
import { motion, AnimatePresence, useDomRef } from 'motion-v'
import { Swiper, SwiperSlide } from 'swiper/vue'
import { Navigation, Keyboard, Virtual } from 'swiper/modules'
@@ -67,7 +69,7 @@ const totalReactions = computed(() => {
// 加载照片表态数据
const loadPhotoReactions = async (photoId: string) => {
try {
- const data = (await $fetch(`/api/photos/${photoId}/reactions`)) as any
+ const data = (await galleryApi(`/api/photos/${photoId}/reactions`)) as any
selectedReaction.value = data.userReaction || null
reactionCounts.value = data.reactions || {}
} catch (error) {
@@ -440,11 +442,11 @@ const handleReactionSelect = async (reactionId: string, iconName: string) => {
try {
if (isRemovingCurrentReaction) {
- await $fetch(`/api/photos/${photoId}/reactions`, {
+ await galleryApi(`/api/photos/${photoId}/reactions`, {
method: 'DELETE',
})
} else {
- await $fetch(`/api/photos/${photoId}/reactions`, {
+ await galleryApi(`/api/photos/${photoId}/reactions`, {
method: 'POST',
body: { reactionType: reactionId },
})
@@ -475,7 +477,8 @@ const handleReactionSelect = async (reactionId: string, iconName: string) => {
toast.add({
icon: 'tabler:alert-circle',
title: $t('viewer.reaction.error.title'),
- description: error instanceof Error ? error.message : $t('common.unknownError'),
+ description:
+ error instanceof Error ? error.message : $t('common.unknownError'),
color: 'warning',
})
}
diff --git a/app/components/photo/reaction-definitions.ts b/packages/gallery/app/components/photo/reaction-definitions.ts
similarity index 100%
rename from app/components/photo/reaction-definitions.ts
rename to packages/gallery/app/components/photo/reaction-definitions.ts
diff --git a/app/components/ui/AuthForm.vue b/packages/gallery/app/components/ui/AuthForm.vue
similarity index 100%
rename from app/components/ui/AuthForm.vue
rename to packages/gallery/app/components/ui/AuthForm.vue
diff --git a/app/components/ui/CalendarHeatmap/CalendarHeatmap.vue b/packages/gallery/app/components/ui/CalendarHeatmap/CalendarHeatmap.vue
similarity index 100%
rename from app/components/ui/CalendarHeatmap/CalendarHeatmap.vue
rename to packages/gallery/app/components/ui/CalendarHeatmap/CalendarHeatmap.vue
diff --git a/app/components/ui/CalendarHeatmap/Heatmap.ts b/packages/gallery/app/components/ui/CalendarHeatmap/Heatmap.ts
similarity index 100%
rename from app/components/ui/CalendarHeatmap/Heatmap.ts
rename to packages/gallery/app/components/ui/CalendarHeatmap/Heatmap.ts
diff --git a/app/components/ui/DateRangeIndicator.vue b/packages/gallery/app/components/ui/DateRangeIndicator.vue
similarity index 100%
rename from app/components/ui/DateRangeIndicator.vue
rename to packages/gallery/app/components/ui/DateRangeIndicator.vue
diff --git a/app/components/ui/FloatingWindow/FloatingWindow.vue b/packages/gallery/app/components/ui/FloatingWindow/FloatingWindow.vue
similarity index 98%
rename from app/components/ui/FloatingWindow/FloatingWindow.vue
rename to packages/gallery/app/components/ui/FloatingWindow/FloatingWindow.vue
index 3d7abc46..9a5e5f34 100644
--- a/app/components/ui/FloatingWindow/FloatingWindow.vue
+++ b/packages/gallery/app/components/ui/FloatingWindow/FloatingWindow.vue
@@ -2,8 +2,8 @@
import {
constrainFloatingRect,
resizeFloatingRect,
-} from '~/utils/floatingWindow'
-import type { FloatingRect } from '~/utils/floatingWindow'
+} from '#gallery/utils/floatingWindow'
+import type { FloatingRect } from '#gallery/utils/floatingWindow'
const props = withDefaults(
defineProps<{
id?: string
diff --git a/app/components/ui/GlassButton.vue b/packages/gallery/app/components/ui/GlassButton.vue
similarity index 100%
rename from app/components/ui/GlassButton.vue
rename to packages/gallery/app/components/ui/GlassButton.vue
diff --git a/app/components/ui/Rating.vue b/packages/gallery/app/components/ui/Rating.vue
similarity index 92%
rename from app/components/ui/Rating.vue
rename to packages/gallery/app/components/ui/Rating.vue
index e3c2c360..f6adffc2 100644
--- a/app/components/ui/Rating.vue
+++ b/packages/gallery/app/components/ui/Rating.vue
@@ -1,7 +1,7 @@
<script lang="ts" setup>
-import TablerStar from '~/components/icon/TablerStar.vue'
-import TablerStarFilled from '~/components/icon/TablerStarFilled.vue'
-import TablerStarHalfFilled from '~/components/icon/TablerStarHalfFilled.vue'
+import TablerStar from '#gallery/components/icon/TablerStar.vue'
+import TablerStarFilled from '#gallery/components/icon/TablerStarFilled.vue'
+import TablerStarHalfFilled from '#gallery/components/icon/TablerStarHalfFilled.vue'
interface Props {
modelValue: number
diff --git a/app/components/ui/ThumbHash.vue b/packages/gallery/app/components/ui/ThumbHash.vue
similarity index 100%
rename from app/components/ui/ThumbHash.vue
rename to packages/gallery/app/components/ui/ThumbHash.vue
diff --git a/app/components/ui/ThumbImage.vue b/packages/gallery/app/components/ui/ThumbImage.vue
similarity index 100%
rename from app/components/ui/ThumbImage.vue
rename to packages/gallery/app/components/ui/ThumbImage.vue
diff --git a/app/composables/useDebugSection.ts b/packages/gallery/app/composables/useDebugSection.ts
similarity index 93%
rename from app/composables/useDebugSection.ts
rename to packages/gallery/app/composables/useDebugSection.ts
index fd715475..6502b062 100644
--- a/app/composables/useDebugSection.ts
+++ b/packages/gallery/app/composables/useDebugSection.ts
@@ -1,4 +1,4 @@
-import type { DebugSection, DebugValue } from '~/types/debug'
+import type { DebugSection, DebugValue } from '#gallery/types/debug'
/** Register route-specific controls; values survive navigation, controls do not. */
export function useDebugSection(section: MaybeRefOrGetter<DebugSection>) {
diff --git a/app/composables/useExifLocalization.ts b/packages/gallery/app/composables/useExifLocalization.ts
similarity index 87%
rename from app/composables/useExifLocalization.ts
rename to packages/gallery/app/composables/useExifLocalization.ts
index a0767b44..edef228a 100644
--- a/app/composables/useExifLocalization.ts
+++ b/packages/gallery/app/composables/useExifLocalization.ts
@@ -1,4 +1,4 @@
-import { translateExifValue } from '~/utils/exif-localization'
+import { translateExifValue } from '#gallery/utils/exif-localization'
/**
* EXIF 本地化的 Composable
diff --git a/packages/gallery/app/composables/useGalleryApi.ts b/packages/gallery/app/composables/useGalleryApi.ts
new file mode 100644
index 00000000..2b229292
--- /dev/null
+++ b/packages/gallery/app/composables/useGalleryApi.ts
@@ -0,0 +1,17 @@
+/** Public gallery API base is supplied by the consuming entry. */
+export function useGalleryApi() {
+ const fetcher = useRequestFetch()
+ const baseURL = useRuntimeConfig().public.gallery.apiBase
+ return ((
+ request: Parameters<typeof fetcher>[0],
+ options?: Parameters<typeof fetcher>[1],
+ ) => fetcher(request, { baseURL, ...options })) as typeof fetcher
+}
+export const useGalleryFetch = ((
+ request: Parameters<typeof useFetch>[0],
+ options?: Parameters<typeof useFetch>[1],
+) =>
+ useFetch(request, {
+ baseURL: useRuntimeConfig().public.gallery.apiBase,
+ ...options,
+ })) as typeof useFetch
diff --git a/packages/gallery/app/composables/useGalleryViewer.ts b/packages/gallery/app/composables/useGalleryViewer.ts
new file mode 100644
index 00000000..5813c352
--- /dev/null
+++ b/packages/gallery/app/composables/useGalleryViewer.ts
@@ -0,0 +1,67 @@
+import type { Photo } from '@chronoframe/contracts/resources'
+import type { Ref } from 'vue'
+
+/** Compose viewer navigation without owning the entry photo query or authentication. */
+export function useGalleryViewer(photos: Ref<Photo[]>) {
+ const router = useRouter()
+ const route = useRoute()
+ const { switchToIndex, closeViewer, clearReturnRoute } = useViewerState()
+ const {
+ currentPhotoIndex,
+ isViewerOpen,
+ returnRoute,
+ isDirectAccess,
+ scopedPhotos,
+ } = storeToRefs(useViewerState())
+
+ // The photo collection the viewer actually navigates: the scoped list (e.g. an
+ // album) when present, otherwise the global list.
+ const viewerPhotos = computed(() => scopedPhotos.value ?? photos.value)
+
+ const handleIndexChange = (newIndex: number) => {
+ switchToIndex(newIndex)
+ const photoId = viewerPhotos.value[newIndex]?.id
+ if (!photoId) return
+ if (
+ returnRoute.value?.startsWith('/albums/') &&
+ route.path === returnRoute.value
+ ) {
+ router.replace({
+ path: route.path,
+ query: { ...route.query, photo: photoId },
+ })
+ } else {
+ router.replace(`/${photoId}`)
+ }
+ }
+
+ const handleClose = () => {
+ closeViewer()
+
+ // 如果是直接访问详情页面,关闭时返回首页
+ if (isDirectAccess.value) {
+ isDirectAccess.value = false
+ router.replace('/')
+ } else if (returnRoute.value) {
+ // 如果有指定的返回路由,返回到该路由
+ const destination = returnRoute.value
+ clearReturnRoute()
+ router.replace(destination)
+ } else {
+ // 否则使用历史记录或默认返回首页
+ if (window.history.length > 1) {
+ router.back()
+ } else {
+ router.replace('/')
+ }
+ }
+ }
+
+ return {
+ viewerPhotos,
+ currentPhotoIndex,
+ isViewerOpen,
+ handleClose,
+ handleIndexChange,
+ }
+}
diff --git a/app/composables/useHomeView.ts b/packages/gallery/app/composables/useHomeView.ts
similarity index 100%
rename from app/composables/useHomeView.ts
rename to packages/gallery/app/composables/useHomeView.ts
diff --git a/app/composables/useImageLoader.ts b/packages/gallery/app/composables/useImageLoader.ts
similarity index 92%
rename from app/composables/useImageLoader.ts
rename to packages/gallery/app/composables/useImageLoader.ts
index ec6bbed9..a1313738 100644
--- a/app/composables/useImageLoader.ts
+++ b/packages/gallery/app/composables/useImageLoader.ts
@@ -1,5 +1,5 @@
-import type { LoadingIndicatorRef } from '~/components/photo/LoadingIndicator.vue'
-import { ImageLoaderManager } from '~/libs/image-loader-manager'
+import type { LoadingIndicatorRef } from '#gallery/components/photo/LoadingIndicator.vue'
+import { ImageLoaderManager } from '#gallery/libs/image-loader-manager'
export const useImageLoader = (
src: string,
diff --git a/app/composables/useInstanceOpenGraph.ts b/packages/gallery/app/composables/useInstanceOpenGraph.ts
similarity index 93%
rename from app/composables/useInstanceOpenGraph.ts
rename to packages/gallery/app/composables/useInstanceOpenGraph.ts
index 2354aa2b..1a764277 100644
--- a/app/composables/useInstanceOpenGraph.ts
+++ b/packages/gallery/app/composables/useInstanceOpenGraph.ts
@@ -1,5 +1,5 @@
import type { ComputedRef } from 'vue'
-import { defaultLocationFallback } from '~~/shared/utils/location'
+import { defaultLocationFallback } from '@chronoframe/gallery/shared/utils/location'
/**
* Share metadata for this ChronoFrame instance.
@@ -45,7 +45,7 @@ export async function useInstanceOpenGraph(photos: ComputedRef<Photo[]>) {
// Logged-in visitors load every photo, including hidden ones. The public
// preview must keep using the anonymous collection.
- const publicPhotoRequest = useFetch<Photo[]>('/api/photos/visible', {
+ const publicPhotoRequest = useGalleryFetch<Photo[]>('/api/photos/visible', {
key: 'og-public-photos',
immediate: loggedIn.value && isHome.value,
})
@@ -110,8 +110,12 @@ export async function useInstanceOpenGraph(photos: ComputedRef<Photo[]>) {
photo:
currentPhoto.value?.id === id ? currentPhoto.value : undefined,
appTitle: siteName.value,
- locationPreferredLevel: String(locationPreferredLevel.value || 'city'),
- locationFallbackOrder: String(locationFallbackOrder.value || defaultLocationFallback),
+ locationPreferredLevel: String(
+ locationPreferredLevel.value || 'city',
+ ),
+ locationFallbackOrder: String(
+ locationFallbackOrder.value || defaultLocationFallback,
+ ),
},
{ alt: shareTitle.value },
)
diff --git a/app/composables/useLivePhotoProcessor.ts b/packages/gallery/app/composables/useLivePhotoProcessor.ts
similarity index 100%
rename from app/composables/useLivePhotoProcessor.ts
rename to packages/gallery/app/composables/useLivePhotoProcessor.ts
diff --git a/app/composables/useLocalePreference.ts b/packages/gallery/app/composables/useLocalePreference.ts
similarity index 98%
rename from app/composables/useLocalePreference.ts
rename to packages/gallery/app/composables/useLocalePreference.ts
index 76f61ebd..01bc796b 100644
--- a/app/composables/useLocalePreference.ts
+++ b/packages/gallery/app/composables/useLocalePreference.ts
@@ -4,7 +4,7 @@ import i18nOptions, {
isAppLocaleCode,
locales,
type AppLocaleCode,
-} from '~~/i18n/i18n.options'
+} from '#gallery-i18n/i18n.options'
export type LocalePreference = AppLocaleCode | 'auto'
diff --git a/app/composables/useLocationLabel.ts b/packages/gallery/app/composables/useLocationLabel.ts
similarity index 83%
rename from app/composables/useLocationLabel.ts
rename to packages/gallery/app/composables/useLocationLabel.ts
index 71f42ee9..528b8067 100644
--- a/app/composables/useLocationLabel.ts
+++ b/packages/gallery/app/composables/useLocationLabel.ts
@@ -2,8 +2,8 @@ import { toValue, type MaybeRefOrGetter } from 'vue'
import {
resolveLocationLabel,
defaultLocationFallback,
-} from '../../shared/utils/location.ts'
-import type { NormalizedLocation } from '~~/shared/types/location'
+} from '@chronoframe/gallery/shared/utils/location'
+import type { NormalizedLocation } from '@chronoframe/gallery/shared/types/location'
export function useLocationLabel(
overrides: MaybeRefOrGetter<{
diff --git a/app/composables/useMapSetupNotice.ts b/packages/gallery/app/composables/useMapSetupNotice.ts
similarity index 100%
rename from app/composables/useMapSetupNotice.ts
rename to packages/gallery/app/composables/useMapSetupNotice.ts
diff --git a/app/composables/usePhotoFilters.ts b/packages/gallery/app/composables/usePhotoFilters.ts
similarity index 100%
rename from app/composables/usePhotoFilters.ts
rename to packages/gallery/app/composables/usePhotoFilters.ts
diff --git a/app/composables/usePhotoSort.ts b/packages/gallery/app/composables/usePhotoSort.ts
similarity index 98%
rename from app/composables/usePhotoSort.ts
rename to packages/gallery/app/composables/usePhotoSort.ts
index bd22da21..8a73b153 100644
--- a/app/composables/usePhotoSort.ts
+++ b/packages/gallery/app/composables/usePhotoSort.ts
@@ -149,7 +149,9 @@ export function usePhotoSort() {
// 获取当前排序的显示标签
const currentSortLabel = computed(
- () => currentSortOption.value?.labelI18n || 'ui.action.sort.options.dateTakenDesc',
+ () =>
+ currentSortOption.value?.labelI18n ||
+ 'ui.action.sort.options.dateTakenDesc',
)
// 获取当前排序的显示图标
diff --git a/app/composables/usePhotos.ts b/packages/gallery/app/composables/usePhotos.ts
similarity index 100%
rename from app/composables/usePhotos.ts
rename to packages/gallery/app/composables/usePhotos.ts
diff --git a/app/composables/useShiftRangeSelection.ts b/packages/gallery/app/composables/useShiftRangeSelection.ts
similarity index 100%
rename from app/composables/useShiftRangeSelection.ts
rename to packages/gallery/app/composables/useShiftRangeSelection.ts
diff --git a/app/composables/useWebGLWorkState.ts b/packages/gallery/app/composables/useWebGLWorkState.ts
similarity index 88%
rename from app/composables/useWebGLWorkState.ts
rename to packages/gallery/app/composables/useWebGLWorkState.ts
index 9f17ba65..747273cd 100644
--- a/app/composables/useWebGLWorkState.ts
+++ b/packages/gallery/app/composables/useWebGLWorkState.ts
@@ -1,4 +1,4 @@
-import type { LoadingIndicatorRef } from '~/components/photo/LoadingIndicator.vue'
+import type { LoadingIndicatorRef } from '#gallery/components/photo/LoadingIndicator.vue'
import { LoadingState } from '@chronoframe/webgl-image'
export const useWebGLWorkState = (
diff --git a/app/layouts/masonry.vue b/packages/gallery/app/layouts/masonry.vue
similarity index 100%
rename from app/layouts/masonry.vue
rename to packages/gallery/app/layouts/masonry.vue
diff --git a/app/libs/histogram.ts b/packages/gallery/app/libs/histogram.ts
similarity index 100%
rename from app/libs/histogram.ts
rename to packages/gallery/app/libs/histogram.ts
diff --git a/app/libs/image-loader-manager.ts b/packages/gallery/app/libs/image-loader-manager.ts
similarity index 100%
rename from app/libs/image-loader-manager.ts
rename to packages/gallery/app/libs/image-loader-manager.ts
diff --git a/app/libs/lru.ts b/packages/gallery/app/libs/lru.ts
similarity index 100%
rename from app/libs/lru.ts
rename to packages/gallery/app/libs/lru.ts
diff --git a/app/middleware/home-tag-redirect.ts b/packages/gallery/app/middleware/home-tag-redirect.ts
similarity index 100%
rename from app/middleware/home-tag-redirect.ts
rename to packages/gallery/app/middleware/home-tag-redirect.ts
diff --git a/app/pages/[...slug].vue b/packages/gallery/app/pages/[...slug].vue
similarity index 100%
rename from app/pages/[...slug].vue
rename to packages/gallery/app/pages/[...slug].vue
diff --git a/app/pages/albums/[albumId].vue b/packages/gallery/app/pages/albums/[albumId].vue
similarity index 99%
rename from app/pages/albums/[albumId].vue
rename to packages/gallery/app/pages/albums/[albumId].vue
index 8c817a82..fc4ab5f2 100644
--- a/app/pages/albums/[albumId].vue
+++ b/packages/gallery/app/pages/albums/[albumId].vue
@@ -1,4 +1,6 @@
<script lang="ts" setup>
+const galleryApi = useGalleryApi()
+
import { motion } from 'motion-v'
const route = useRoute()
@@ -17,7 +19,7 @@ const {
error,
pending,
refresh,
-} = await useFetch(() => `/api/albums/${albumId.value}`, {
+} = await useGalleryFetch(() => `/api/albums/${albumId.value}`, {
watch: [albumId],
})
@@ -38,7 +40,7 @@ const unlockAlbum = async () => {
unlockErrorMessageKey.value = null
unlockSucceeded.value = false
try {
- await $fetch(`/api/albums/${albumId.value}/unlock`, {
+ await galleryApi(`/api/albums/${albumId.value}/unlock`, {
method: 'POST',
body: { password: albumPassword.value },
})
diff --git a/app/pages/albums/index.vue b/packages/gallery/app/pages/albums/index.vue
similarity index 100%
rename from app/pages/albums/index.vue
rename to packages/gallery/app/pages/albums/index.vue
diff --git a/app/pages/globe.vue b/packages/gallery/app/pages/globe.vue
similarity index 93%
rename from app/pages/globe.vue
rename to packages/gallery/app/pages/globe.vue
index 7ecf1674..ff4482db 100644
--- a/app/pages/globe.vue
+++ b/packages/gallery/app/pages/globe.vue
@@ -1,7 +1,7 @@
<script lang="ts" setup>
-import { hasValidCoordinates } from '~~/shared/utils/location'
+import { hasValidCoordinates } from '@chronoframe/gallery/shared/utils/location'
import { motion } from 'motion-v'
-import { clusterMarkers, photosToMarkers } from '~/utils/clustering'
+import { clusterMarkers, photosToMarkers } from '#gallery/utils/clustering'
useHead({
title: () => $t('title.globe'),
@@ -14,8 +14,8 @@ const dayjs = useDayjs()
const { photos } = usePhotos()
const photosWithLocation = computed(() => {
- return photos.value.filter(
- (photo) => hasValidCoordinates(photo.latitude, photo.longitude),
+ return photos.value.filter((photo) =>
+ hasValidCoordinates(photo.latitude, photo.longitude),
)
})
@@ -51,7 +51,8 @@ const timelineRange = computed(() => {
}
const first = datedPhotosWithLocation.value[0]!
- const last = datedPhotosWithLocation.value[datedPhotosWithLocation.value.length - 1]!
+ const last =
+ datedPhotosWithLocation.value[datedPhotosWithLocation.value.length - 1]!
return {
min: first.timestamp,
max: last.timestamp,
@@ -234,32 +235,35 @@ const analysisMode = ref<'none' | 'focalLength' | 'shutterSpeed' | 'altitude'>(
)
const parameterAnnotationOpen = ref(false)
-const analysisModeOptions = computed(() => [
- {
- value: 'none',
- label: $t('globe.analysis.mode.none.label'),
- icon: 'tabler:circle-off',
- description: $t('globe.analysis.mode.none.description'),
- },
- {
- value: 'focalLength',
- label: $t('globe.analysis.mode.focalLength.label'),
- icon: 'tabler:zoom-scan',
- description: $t('globe.analysis.mode.focalLength.description'),
- },
- {
- value: 'shutterSpeed',
- label: $t('globe.analysis.mode.shutterSpeed.label'),
- icon: 'tabler:clock-hour-4',
- description: $t('globe.analysis.mode.shutterSpeed.description'),
- },
- {
- value: 'altitude',
- label: $t('globe.analysis.mode.altitude.label'),
- icon: 'tabler:mountain',
- description: $t('globe.analysis.mode.altitude.description'),
- },
-] as const)
+const analysisModeOptions = computed(
+ () =>
+ [
+ {
+ value: 'none',
+ label: $t('globe.analysis.mode.none.label'),
+ icon: 'tabler:circle-off',
+ description: $t('globe.analysis.mode.none.description'),
+ },
+ {
+ value: 'focalLength',
+ label: $t('globe.analysis.mode.focalLength.label'),
+ icon: 'tabler:zoom-scan',
+ description: $t('globe.analysis.mode.focalLength.description'),
+ },
+ {
+ value: 'shutterSpeed',
+ label: $t('globe.analysis.mode.shutterSpeed.label'),
+ icon: 'tabler:clock-hour-4',
+ description: $t('globe.analysis.mode.shutterSpeed.description'),
+ },
+ {
+ value: 'altitude',
+ label: $t('globe.analysis.mode.altitude.label'),
+ icon: 'tabler:mountain',
+ description: $t('globe.analysis.mode.altitude.description'),
+ },
+ ] as const,
+)
const analysisLegend = computed(() => {
if (analysisMode.value === 'focalLength') {
@@ -367,7 +371,9 @@ watch(filteredPhotosWithLocation, (currentPhotos) => {
return
}
- const exists = currentPhotos.some((photo) => photo.id === currentClusterPointId.value)
+ const exists = currentPhotos.some(
+ (photo) => photo.id === currentClusterPointId.value,
+ )
if (!exists) {
currentClusterPointId.value = null
}
@@ -698,7 +704,9 @@ onBeforeUnmount(() => {
>
<GlassButton
size="sm"
- :icon="isTimelinePlaying ? 'tabler:player-pause' : 'tabler:player-play'"
+ :icon="
+ isTimelinePlaying ? 'tabler:player-pause' : 'tabler:player-play'
+ "
:class="
!hasTimelineData || !isTimelineEnabled
? 'opacity-40 pointer-events-none'
@@ -711,7 +719,9 @@ onBeforeUnmount(() => {
<div class="flex items-center justify-between gap-2 text-[11px]">
<span class="font-medium">{{ $t('globe.timeline.title') }}</span>
<span class="text-neutral-600 dark:text-white/60">
- {{ filteredPhotosWithLocation.length }}/{{ photosWithLocation.length }}
+ {{ filteredPhotosWithLocation.length }}/{{
+ photosWithLocation.length
+ }}
</span>
</div>
<div
diff --git a/app/pages/index.vue b/packages/gallery/app/pages/index.vue
similarity index 100%
rename from app/pages/index.vue
rename to packages/gallery/app/pages/index.vue
diff --git a/app/pages/photos.vue b/packages/gallery/app/pages/photos.vue
similarity index 100%
rename from app/pages/photos.vue
rename to packages/gallery/app/pages/photos.vue
diff --git a/app/plugins/chrono-webgl-image.ts b/packages/gallery/app/plugins/chrono-webgl-image.ts
similarity index 100%
rename from app/plugins/chrono-webgl-image.ts
rename to packages/gallery/app/plugins/chrono-webgl-image.ts
diff --git a/app/plugins/vue-masonry-wall.ts b/packages/gallery/app/plugins/vue-masonry-wall.ts
similarity index 100%
rename from app/plugins/vue-masonry-wall.ts
rename to packages/gallery/app/plugins/vue-masonry-wall.ts
diff --git a/app/stores/debug.ts b/packages/gallery/app/stores/debug.ts
similarity index 96%
rename from app/stores/debug.ts
rename to packages/gallery/app/stores/debug.ts
index e641d394..4b5f7842 100644
--- a/app/stores/debug.ts
+++ b/packages/gallery/app/stores/debug.ts
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
-import type { DebugSection, DebugValue } from '~/types/debug'
+import type { DebugSection, DebugValue } from '#gallery/types/debug'
const storageKey = 'chronoframe:debug:v1'
export const useDebugStore = defineStore('debug', () => {
diff --git a/app/stores/settings.ts b/packages/gallery/app/stores/settings.ts
similarity index 96%
rename from app/stores/settings.ts
rename to packages/gallery/app/stores/settings.ts
index 94dfcb92..b0fc2384 100644
--- a/app/stores/settings.ts
+++ b/packages/gallery/app/stores/settings.ts
@@ -61,7 +61,7 @@ export const useSettingsStore = defineStore('settings', {
this.error = null
try {
- const response = await $fetch<PublicSettingsResponse>(
+ const response = await useGalleryApi()<PublicSettingsResponse>(
'/api/system/settings/all',
)
@@ -115,7 +115,7 @@ export const useSettingsStore = defineStore('settings', {
this.error = null
try {
- const response = await $fetch<PublicSettingsResponse>(
+ const response = await useGalleryApi()<PublicSettingsResponse>(
'/api/system/settings/all',
)
diff --git a/app/stores/viewer.ts b/packages/gallery/app/stores/viewer.ts
similarity index 100%
rename from app/stores/viewer.ts
rename to packages/gallery/app/stores/viewer.ts
diff --git a/app/types/debug.ts b/packages/gallery/app/types/debug.ts
similarity index 100%
rename from app/types/debug.ts
rename to packages/gallery/app/types/debug.ts
diff --git a/app/utils/albumListState.test.ts b/packages/gallery/app/utils/albumListState.test.ts
similarity index 100%
rename from app/utils/albumListState.test.ts
rename to packages/gallery/app/utils/albumListState.test.ts
diff --git a/app/utils/albumListState.ts b/packages/gallery/app/utils/albumListState.ts
similarity index 100%
rename from app/utils/albumListState.ts
rename to packages/gallery/app/utils/albumListState.ts
diff --git a/app/utils/avatar.ts b/packages/gallery/app/utils/avatar.ts
similarity index 100%
rename from app/utils/avatar.ts
rename to packages/gallery/app/utils/avatar.ts
diff --git a/app/utils/camera.ts b/packages/gallery/app/utils/camera.ts
similarity index 100%
rename from app/utils/camera.ts
rename to packages/gallery/app/utils/camera.ts
diff --git a/app/utils/clustering.ts b/packages/gallery/app/utils/clustering.ts
similarity index 94%
rename from app/utils/clustering.ts
rename to packages/gallery/app/utils/clustering.ts
index bcc25646..e17addd4 100644
--- a/app/utils/clustering.ts
+++ b/packages/gallery/app/utils/clustering.ts
@@ -1,5 +1,8 @@
-import { hasValidCoordinates } from '../../shared/utils/location.ts'
-import type { PhotoMarker, ClusterPoint } from '~~/shared/types/map'
+import { hasValidCoordinates } from '@chronoframe/gallery/shared/utils/location'
+import type {
+ PhotoMarker,
+ ClusterPoint,
+} from '@chronoframe/gallery/shared/types/map'
/**
* Simple clustering algorithm for small datasets
diff --git a/app/utils/exif-localization.ts b/packages/gallery/app/utils/exif-localization.ts
similarity index 94%
rename from app/utils/exif-localization.ts
rename to packages/gallery/app/utils/exif-localization.ts
index c1b861b1..8e9c605f 100644
--- a/app/utils/exif-localization.ts
+++ b/packages/gallery/app/utils/exif-localization.ts
@@ -1,4 +1,4 @@
-import type localeFile from '~/../i18n/locales/en.json'
+import type localeFile from '#gallery-i18n/locales/en.json'
export type ExifCategory = keyof typeof localeFile.exif.values
diff --git a/app/utils/floatingWindow.ts b/packages/gallery/app/utils/floatingWindow.ts
similarity index 100%
rename from app/utils/floatingWindow.ts
rename to packages/gallery/app/utils/floatingWindow.ts
diff --git a/app/utils/index.ts b/packages/gallery/app/utils/index.ts
similarity index 100%
rename from app/utils/index.ts
rename to packages/gallery/app/utils/index.ts
diff --git a/app/utils/open-graph.ts b/packages/gallery/app/utils/open-graph.ts
similarity index 100%
rename from app/utils/open-graph.ts
rename to packages/gallery/app/utils/open-graph.ts
diff --git a/app/utils/parseScriptTags.ts b/packages/gallery/app/utils/parseScriptTags.ts
similarity index 100%
rename from app/utils/parseScriptTags.ts
rename to packages/gallery/app/utils/parseScriptTags.ts
diff --git a/app/utils/sampleWaterfallPhotos.test.ts b/packages/gallery/app/utils/sampleWaterfallPhotos.test.ts
similarity index 100%
rename from app/utils/sampleWaterfallPhotos.test.ts
rename to packages/gallery/app/utils/sampleWaterfallPhotos.test.ts
diff --git a/app/utils/sampleWaterfallPhotos.ts b/packages/gallery/app/utils/sampleWaterfallPhotos.ts
similarity index 100%
rename from app/utils/sampleWaterfallPhotos.ts
rename to packages/gallery/app/utils/sampleWaterfallPhotos.ts
diff --git a/i18n/i18n.config.ts b/packages/gallery/i18n/i18n.config.ts
similarity index 100%
rename from i18n/i18n.config.ts
rename to packages/gallery/i18n/i18n.config.ts
diff --git a/i18n/i18n.options.ts b/packages/gallery/i18n/i18n.options.ts
similarity index 99%
rename from i18n/i18n.options.ts
rename to packages/gallery/i18n/i18n.options.ts
index 4ca967fb..6053a9dd 100644
--- a/i18n/i18n.options.ts
+++ b/packages/gallery/i18n/i18n.options.ts
@@ -77,7 +77,7 @@ export const dayjsLocales: DayjsLocale[] = [
'zh-hk',
'en',
'ja',
- 'ru'
+ 'ru',
]
export default {
diff --git a/i18n/localeDetector.ts b/packages/gallery/i18n/localeDetector.ts
similarity index 100%
rename from i18n/localeDetector.ts
rename to packages/gallery/i18n/localeDetector.ts
diff --git a/i18n/locales/en.json b/packages/gallery/i18n/locales/en.json
similarity index 100%
rename from i18n/locales/en.json
rename to packages/gallery/i18n/locales/en.json
diff --git a/i18n/locales/ja.json b/packages/gallery/i18n/locales/ja.json
similarity index 100%
rename from i18n/locales/ja.json
rename to packages/gallery/i18n/locales/ja.json
diff --git a/i18n/locales/ru.json b/packages/gallery/i18n/locales/ru.json
similarity index 100%
rename from i18n/locales/ru.json
rename to packages/gallery/i18n/locales/ru.json
diff --git a/i18n/locales/zh-Hans.json b/packages/gallery/i18n/locales/zh-Hans.json
similarity index 100%
rename from i18n/locales/zh-Hans.json
rename to packages/gallery/i18n/locales/zh-Hans.json
diff --git a/i18n/locales/zh-Hant-HK.json b/packages/gallery/i18n/locales/zh-Hant-HK.json
similarity index 100%
rename from i18n/locales/zh-Hant-HK.json
rename to packages/gallery/i18n/locales/zh-Hant-HK.json
diff --git a/i18n/locales/zh-Hant-TW.json b/packages/gallery/i18n/locales/zh-Hant-TW.json
similarity index 100%
rename from i18n/locales/zh-Hant-TW.json
rename to packages/gallery/i18n/locales/zh-Hant-TW.json
diff --git a/packages/gallery/nuxt.config.ts b/packages/gallery/nuxt.config.ts
new file mode 100644
index 00000000..72446b83
--- /dev/null
+++ b/packages/gallery/nuxt.config.ts
@@ -0,0 +1,23 @@
+import { fileURLToPath } from 'node:url'
+import i18n from './i18n/i18n.options'
+const resolve = (path: string) => fileURLToPath(new URL(path, import.meta.url))
+const app = resolve('./app/')
+export default defineNuxtConfig({
+ alias: { '#gallery': app, '#gallery-i18n': resolve('./i18n/') },
+ css: [app + 'assets/css/tailwind.css'],
+ components: [
+ { path: app + 'components/ui', pathPrefix: false },
+ { path: app + 'components' },
+ ],
+ pinia: { storesDirs: [app + 'stores/**'] },
+ i18n: {
+ ...i18n,
+ langDir: 'locales',
+ vueI18n: 'i18n.config.ts',
+ experimental: {
+ ...i18n.experimental,
+ localeDetector: 'localeDetector.ts',
+ },
+ },
+ runtimeConfig: { public: { gallery: { apiBase: '' } } },
+})
diff --git a/packages/gallery/package.json b/packages/gallery/package.json
new file mode 100644
index 00000000..383f2326
--- /dev/null
+++ b/packages/gallery/package.json
@@ -0,0 +1,32 @@
+{
+ "name": "@chronoframe/gallery",
+ "version": "0.0.0",
+ "private": true,
+ "type": "module",
+ "license": "MIT",
+ "exports": {
+ ".": "./nuxt.config.ts",
+ "./shared/*": "./shared/*.ts",
+ "./i18n/*": "./i18n/*.ts"
+ },
+ "dependencies": {
+ "@chronoframe/contracts": "workspace:*",
+ "tailwind-merge": "^3.7.0",
+ "@iconify/vue": "5.0.3",
+ "motion-v": "^2.6.0",
+ "vue": "^3.5.43",
+ "maplibre-gl": "^5.24.0",
+ "@nuxt/ui": "^4.11.3",
+ "@chronoframe/webgl-image": "workspace:*",
+ "swiper": "^12.2.0",
+ "zod": "^4.6.6",
+ "tippy.js": "^6.3.7",
+ "thumbhash": "^0.1.1",
+ "file-type": "^22.1.1",
+ "@yeger/vue-masonry-wall": "^6.1.4",
+ "pinia": "^3.0.4",
+ "@nuxtjs/i18n": "10.6.0",
+ "dayjs-nuxt": "2.1.11",
+ "vue-i18n": "^11.4.14"
+ }
+}
diff --git a/shared/types/auth.d.ts b/packages/gallery/shared/types/auth.d.ts
similarity index 100%
rename from shared/types/auth.d.ts
rename to packages/gallery/shared/types/auth.d.ts
diff --git a/shared/types/config.ts b/packages/gallery/shared/types/config.ts
similarity index 100%
rename from shared/types/config.ts
rename to packages/gallery/shared/types/config.ts
diff --git a/shared/types/global.d.ts b/packages/gallery/shared/types/global.d.ts
similarity index 100%
rename from shared/types/global.d.ts
rename to packages/gallery/shared/types/global.d.ts
diff --git a/shared/types/location.ts b/packages/gallery/shared/types/location.ts
similarity index 100%
rename from shared/types/location.ts
rename to packages/gallery/shared/types/location.ts
diff --git a/shared/types/map.ts b/packages/gallery/shared/types/map.ts
similarity index 100%
rename from shared/types/map.ts
rename to packages/gallery/shared/types/map.ts
diff --git a/shared/types/nuxt-icon.d.ts b/packages/gallery/shared/types/nuxt-icon.d.ts
similarity index 100%
rename from shared/types/nuxt-icon.d.ts
rename to packages/gallery/shared/types/nuxt-icon.d.ts
diff --git a/shared/types/photo.ts b/packages/gallery/shared/types/photo.ts
similarity index 100%
rename from shared/types/photo.ts
rename to packages/gallery/shared/types/photo.ts
diff --git a/shared/types/settings.ts b/packages/gallery/shared/types/settings.ts
similarity index 100%
rename from shared/types/settings.ts
rename to packages/gallery/shared/types/settings.ts
diff --git a/shared/types/storage.ts b/packages/gallery/shared/types/storage.ts
similarity index 100%
rename from shared/types/storage.ts
rename to packages/gallery/shared/types/storage.ts
diff --git a/shared/types/tours.ts b/packages/gallery/shared/types/tours.ts
similarity index 100%
rename from shared/types/tours.ts
rename to packages/gallery/shared/types/tours.ts
diff --git a/shared/types/upload.ts b/packages/gallery/shared/types/upload.ts
similarity index 100%
rename from shared/types/upload.ts
rename to packages/gallery/shared/types/upload.ts
diff --git a/shared/types/uploading-file.ts b/packages/gallery/shared/types/uploading-file.ts
similarity index 100%
rename from shared/types/uploading-file.ts
rename to packages/gallery/shared/types/uploading-file.ts
diff --git a/shared/utils/album.ts b/packages/gallery/shared/utils/album.ts
similarity index 100%
rename from shared/utils/album.ts
rename to packages/gallery/shared/utils/album.ts
diff --git a/shared/utils/avatar.ts b/packages/gallery/shared/utils/avatar.ts
similarity index 100%
rename from shared/utils/avatar.ts
rename to packages/gallery/shared/utils/avatar.ts
diff --git a/shared/utils/index.ts b/packages/gallery/shared/utils/index.ts
similarity index 100%
rename from shared/utils/index.ts
rename to packages/gallery/shared/utils/index.ts
diff --git a/shared/utils/location.ts b/packages/gallery/shared/utils/location.ts
similarity index 100%
rename from shared/utils/location.ts
rename to packages/gallery/shared/utils/location.ts
diff --git a/shared/utils/map-service.ts b/packages/gallery/shared/utils/map-service.ts
similarity index 100%
rename from shared/utils/map-service.ts
rename to packages/gallery/shared/utils/map-service.ts
diff --git a/shared/utils/queue-config.ts b/packages/gallery/shared/utils/queue-config.ts
similarity index 100%
rename from shared/utils/queue-config.ts
rename to packages/gallery/shared/utils/queue-config.ts
diff --git a/shared/utils/queue-warning.ts b/packages/gallery/shared/utils/queue-warning.ts
similarity index 100%
rename from shared/utils/queue-warning.ts
rename to packages/gallery/shared/utils/queue-warning.ts
diff --git a/shared/utils/u8array.ts b/packages/gallery/shared/utils/u8array.ts
similarity index 100%
rename from shared/utils/u8array.ts
rename to packages/gallery/shared/utils/u8array.ts
diff --git a/shared/utils/upload-status.ts b/packages/gallery/shared/utils/upload-status.ts
similarity index 100%
rename from shared/utils/upload-status.ts
rename to packages/gallery/shared/utils/upload-status.ts
diff --git a/shared/utils/upload.ts b/packages/gallery/shared/utils/upload.ts
similarity index 100%
rename from shared/utils/upload.ts
rename to packages/gallery/shared/utils/upload.ts
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 263ccf39..64e97382 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -8,79 +8,84 @@ overrides:
sharp: 0.35.5
importers:
-
.:
dependencies:
- '@aws-sdk/client-s3':
+ "@aws-sdk/client-s3":
specifier: ^3.1149.0
version: 3.1149.0
- '@aws-sdk/s3-request-presigner':
+ "@aws-sdk/s3-request-presigner":
specifier: ^3.1149.0
version: 3.1149.0
- '@chronoframe/contracts':
+ "@chronoframe/console":
+ specifier: workspace:*
+ version: link:packages/console
+ "@chronoframe/gallery":
+ specifier: workspace:*
+ version: link:packages/gallery
+ "@chronoframe/contracts":
specifier: workspace:*
version: link:packages/contracts
- '@chronoframe/core':
+ "@chronoframe/core":
specifier: workspace:*
version: link:packages/core
- '@chronoframe/database':
+ "@chronoframe/database":
specifier: workspace:*
version: link:packages/database
- '@chronoframe/geocoding':
+ "@chronoframe/geocoding":
specifier: workspace:*
version: link:packages/geocoding
- '@chronoframe/jobs':
+ "@chronoframe/jobs":
specifier: workspace:*
version: link:packages/jobs
- '@chronoframe/media':
+ "@chronoframe/media":
specifier: workspace:*
version: link:packages/media
- '@chronoframe/processing':
+ "@chronoframe/processing":
specifier: workspace:*
version: link:packages/processing
- '@chronoframe/storage':
+ "@chronoframe/storage":
specifier: workspace:*
version: link:packages/storage
- '@chronoframe/webgl-image':
+ "@chronoframe/webgl-image":
specifier: workspace:*
version: link:packages/webgl-image
- '@iconify/vue':
+ "@iconify/vue":
specifier: 5.0.3
- '@indoorequal/vue-maplibre-gl':
+ "@indoorequal/vue-maplibre-gl":
specifier: ^8.4.2
- '@nuxt/fonts':
+ "@nuxt/fonts":
specifier: 0.14.0
- '@nuxt/icon':
+ "@nuxt/icon":
specifier: 2.5.1
- '@nuxt/ui':
+ "@nuxt/ui":
specifier: ^4.11.3
version: 4.11.3(3ebf5098cfbfe964344b6efe7eae24df)
- '@nuxtjs/i18n':
+ "@nuxtjs/i18n":
specifier: 10.6.0
- '@pinia/nuxt':
+ "@pinia/nuxt":
specifier: ^0.11.3
- '@tailwindcss/vite':
+ "@tailwindcss/vite":
specifier: ^4.3.3
- '@takumi-rs/core':
+ "@takumi-rs/core":
specifier: 2.15.0
version: 2.15.0([email protected])
- '@unhead/vue':
+ "@unhead/vue":
specifier: ^2.1.17
- '@vingle/bmp-js':
+ "@vingle/bmp-js":
specifier: ^0.2.5
version: 0.2.5
- '@vueuse/nuxt':
+ "@vueuse/nuxt":
specifier: 14.4.0
- '@yeger/vue-masonry-wall':
+ "@yeger/vue-masonry-wall":
specifier: ^6.1.4
better-sqlite3:
@@ -177,43 +182,43 @@ importers:
specifier: ^4.6.6
version: 4.6.6
devDependencies:
- '@iconify-json/carbon':
+ "@iconify-json/carbon":
specifier: ^1.2.28
version: 1.2.28
- '@iconify-json/fluent-emoji-flat':
+ "@iconify-json/fluent-emoji-flat":
specifier: ^1.2.6
version: 1.2.6
- '@iconify-json/lucide':
+ "@iconify-json/lucide":
specifier: ^1.2.142
version: 1.2.142
- '@iconify-json/material-symbols':
+ "@iconify-json/material-symbols":
specifier: ^1.2.95
version: 1.2.95
- '@iconify-json/mdi':
+ "@iconify-json/mdi":
specifier: ^1.2.3
version: 1.2.3
- '@iconify-json/simple-icons':
+ "@iconify-json/simple-icons":
specifier: ^1.2.99
version: 1.2.99
- '@iconify-json/streamline':
+ "@iconify-json/streamline":
specifier: ^1.2.5
version: 1.2.5
- '@iconify-json/svg-spinners':
+ "@iconify-json/svg-spinners":
specifier: ^1.2.4
version: 1.2.4
- '@iconify-json/tabler':
+ "@iconify-json/tabler":
specifier: ^1.2.42
version: 1.2.42
- '@nuxt/test-utils':
+ "@nuxt/test-utils":
specifier: 4.3.3
- '@types/better-sqlite3':
+ "@types/better-sqlite3":
specifier: ^9.6.0
version: 9.6.0
- '@types/heic-convert':
+ "@types/heic-convert":
specifier: ^2.1.1
version: 2.1.1
- '@vueuse/core':
+ "@vueuse/core":
specifier: ^14.4.0
baseline-browser-mapping:
@@ -249,9 +254,35 @@ importers:
vitepress:
specifier: 2.0.0-alpha.20
-
- packages/console: {}
-
+ packages/console:
+ dependencies:
+ "@chronoframe/gallery":
+ specifier: workspace:*
+ version: link:../gallery
+ driver.js:
+ specifier: ^1.9.0
+ version: 1.9.0
+ es-toolkit:
+ specifier: ^1.52.0
+ version: 1.52.0
+ vue:
+ specifier: ^3.5.43
+ version: 3.5.43([email protected])
+ "@nuxt/ui":
+ specifier: ^4.11.3
+ version: 4.11.3(3ebf5098cfbfe964344b6efe7eae24df)
+ motion-v:
+ specifier: ^2.6.0
+ "@vueuse/core":
+ specifier: ^14.4.0
+ "@chronoframe/contracts":
+ specifier: workspace:*
+ version: link:../contracts
+ zod:
+ specifier: ^4.6.6
+ version: 4.6.6
packages/contracts:
dependencies:
zod:
@@ -261,26 +292,24 @@ importers:
typescript:
specifier: ^5.9.3
version: 5.9.3
-
packages/core:
dependencies:
- '@chronoframe/contracts':
+ "@chronoframe/contracts":
specifier: workspace:*
version: link:../contracts
devDependencies:
typescript:
specifier: ^5.9.3
version: 5.9.3
-
packages/database:
dependencies:
- '@chronoframe/contracts':
+ "@chronoframe/contracts":
specifier: workspace:*
version: link:../contracts
- '@chronoframe/core':
+ "@chronoframe/core":
specifier: workspace:*
version: link:../core
- '@chronoframe/jobs':
+ "@chronoframe/jobs":
specifier: workspace:*
version: link:../jobs
better-sqlite3:
@@ -290,51 +319,104 @@ importers:
specifier: ^0.45.4
version: 0.45.4(@cloudflare/[email protected])(@opentelemetry/[email protected])(@types/[email protected])([email protected])
devDependencies:
- '@types/better-sqlite3':
+ "@types/better-sqlite3":
specifier: ^9.6.0
version: 9.6.0
- '@types/node':
+ "@types/node":
specifier: ^22.20.5
version: 22.20.5
typescript:
specifier: ^5.9.3
version: 5.9.3
-
+ packages/gallery:
+ dependencies:
+ "@chronoframe/contracts":
+ specifier: workspace:*
+ version: link:../contracts
+ tailwind-merge:
+ specifier: ^3.7.0
+ version: 3.7.0
+ "@iconify/vue":
+ specifier: 5.0.3
+ motion-v:
+ specifier: ^2.6.0
+ vue:
+ specifier: ^3.5.43
+ version: 3.5.43([email protected])
+ maplibre-gl:
+ specifier: ^5.24.0
+ version: 5.24.0
+ "@nuxt/ui":
+ specifier: ^4.11.3
+ version: 4.11.3(3ebf5098cfbfe964344b6efe7eae24df)
+ "@chronoframe/webgl-image":
+ specifier: workspace:*
+ version: link:../webgl-image
+ swiper:
+ specifier: ^12.2.0
+ version: 12.2.0
+ zod:
+ specifier: ^4.6.6
+ version: 4.6.6
+ tippy.js:
+ specifier: ^6.3.7
+ version: 6.3.7
+ thumbhash:
+ specifier: ^0.1.1
+ version: 0.1.1
+ file-type:
+ specifier: ^22.1.1
+ version: 22.1.1
+ "@yeger/vue-masonry-wall":
+ specifier: ^6.1.4
+ pinia:
+ specifier: ^3.0.4
+ "@nuxtjs/i18n":
+ specifier: 10.6.0
+ dayjs-nuxt:
+ specifier: 2.1.11
+ version: 2.1.11([email protected])
+ vue-i18n:
+ specifier: ^11.4.14
packages/geocoding:
dependencies:
- '@chronoframe/contracts':
+ "@chronoframe/contracts":
specifier: workspace:*
version: link:../contracts
devDependencies:
- '@types/node':
+ "@types/node":
specifier: ^22.20.5
version: 22.20.5
typescript:
specifier: ^5.9.3
version: 5.9.3
-
packages/jobs:
dependencies:
- '@chronoframe/contracts':
+ "@chronoframe/contracts":
specifier: workspace:*
version: link:../contracts
- '@chronoframe/core':
+ "@chronoframe/core":
specifier: workspace:*
version: link:../core
devDependencies:
typescript:
specifier: ^5.9.3
version: 5.9.3
-
packages/media:
dependencies:
- '@chronoframe/contracts':
+ "@chronoframe/contracts":
specifier: workspace:*
version: link:../contracts
- '@chronoframe/storage':
+ "@chronoframe/storage":
specifier: workspace:*
version: link:../storage
- '@vingle/bmp-js':
+ "@vingle/bmp-js":
specifier: ^0.2.5
version: 0.2.5
es-toolkit:
@@ -353,67 +435,64 @@ importers:
specifier: ^0.1.1
version: 0.1.1
devDependencies:
- '@types/heic-convert':
+ "@types/heic-convert":
specifier: ^2.1.1
version: 2.1.1
- '@types/node':
+ "@types/node":
specifier: ^22.20.5
version: 22.20.5
typescript:
specifier: ^5.9.3
version: 5.9.3
-
packages/processing:
dependencies:
- '@chronoframe/contracts':
+ "@chronoframe/contracts":
specifier: workspace:*
version: link:../contracts
- '@chronoframe/geocoding':
+ "@chronoframe/geocoding":
specifier: workspace:*
version: link:../geocoding
- '@chronoframe/media':
+ "@chronoframe/media":
specifier: workspace:*
version: link:../media
- '@chronoframe/storage':
+ "@chronoframe/storage":
specifier: workspace:*
version: link:../storage
devDependencies:
- '@types/node':
+ "@types/node":
specifier: ^22.20.5
version: 22.20.5
typescript:
specifier: ^5.9.3
version: 5.9.3
-
packages/storage:
dependencies:
- '@aws-sdk/client-s3':
+ "@aws-sdk/client-s3":
specifier: ^3.1149.0
version: 3.1149.0
- '@aws-sdk/s3-request-presigner':
+ "@aws-sdk/s3-request-presigner":
specifier: ^3.1149.0
version: 3.1149.0
- '@chronoframe/contracts':
+ "@chronoframe/contracts":
specifier: workspace:*
version: link:../contracts
devDependencies:
- '@types/node':
+ "@types/node":
specifier: ^22.20.5
version: 22.20.5
typescript:
specifier: ^5.9.3
version: 5.9.3
-
packages/webgl-image:
dependencies:
vue:
specifier: ^3.5.43
version: 3.5.43([email protected])
devDependencies:
- '@types/node':
+ "@types/node":
specifier: ^22.20.5
version: 22.20.5
- '@vitejs/plugin-vue':
+ "@vitejs/plugin-vue":
specifier: ^6.0.10
typescript:
diff --git a/scripts/check-ui-boundaries.mjs b/scripts/check-ui-boundaries.mjs
new file mode 100644
index 00000000..a7c7e0bf
--- /dev/null
+++ b/scripts/check-ui-boundaries.mjs
@@ -0,0 +1,53 @@
+import { readdir, readFile } from 'node:fs/promises'
+import path from 'node:path'
+
+async function files(dir) {
+ const entries = await readdir(dir, { withFileTypes: true })
+ return (
+ await Promise.all(
+ entries.map((entry) =>
+ entry.isDirectory()
+ ? files(path.join(dir, entry.name))
+ : /\.(ts|vue)$/.test(entry.name) && !entry.name.endsWith('.test.ts')
+ ? [path.join(dir, entry.name)]
+ : [],
+ ),
+ )
+ ).flat()
+}
+const failures = []
+for (const name of ['console', 'gallery']) {
+ for (const file of await files(`packages/${name}/app`)) {
+ const source = await readFile(file, 'utf8')
+ for (const match of source.matchAll(
+ /(?:from\s*|import\s*(?:\(\s*)?)['"]([^'"]+)['"]/g,
+ )) {
+ const specifier = match[1]
+ if (
+ specifier.startsWith('.') &&
+ !path
+ .resolve(path.dirname(file), specifier)
+ .startsWith(path.resolve(`packages/${name}`) + path.sep)
+ )
+ failures.push(`${file}: escapes UI package: ${specifier}`)
+ if (
+ /^(?:~~?\/|@@?\/|@chronoframe\/(?:database|jobs|processing|storage|media|geocoding)(?:\/|$))/.test(
+ specifier,
+ ) ||
+ /(?:^|\/)server(?:\/|$)/.test(specifier) ||
+ (name === 'gallery' &&
+ /^(?:#console|@chronoframe\/console)(?:\/|$)/.test(specifier))
+ )
+ failures.push(`${file}: ${specifier}`)
+ }
+ if (
+ name === 'gallery' &&
+ /\/api\/system\/settings\/(?:fields|batch|storage-config)/.test(source)
+ )
+ failures.push(`${file}: portal-only configuration API`)
+ }
+}
+if (failures.length) throw new Error(failures.join('\n'))
+console.log(
+ 'UI boundaries passed: gallery is independent of console, entry aliases and server implementations; public configuration stays separate.',
+)
diff --git a/server/services/settings/contants.ts b/server/services/settings/contants.ts
index a8602e37..ba190119 100644
--- a/server/services/settings/contants.ts
+++ b/server/services/settings/contants.ts
@@ -1,6 +1,6 @@
import { tourIds } from '~~/shared/types/tours'
import type { SettingConfig } from '~~/shared/types/settings'
-import i18nOptions from '~~/i18n/i18n.options'
+import i18nOptions from '@chronoframe/gallery/i18n/i18n.options'
// 存储提供商的枚举值
export const STORAGE_PROVIDERS = ['local', 's3', 'openlist'] as const
diff --git a/server/services/settings/ui-config.ts b/server/services/settings/ui-config.ts
index 6f7db0f3..88b05425 100644
--- a/server/services/settings/ui-config.ts
+++ b/server/services/settings/ui-config.ts
@@ -1,4 +1,4 @@
-import i18nOptions from '~~/i18n/i18n.options'
+import i18nOptions from '@chronoframe/gallery/i18n/i18n.options'
import type { FieldUIConfig } from '~~/shared/types/settings'
/**
diff --git a/shared b/shared
new file mode 120000
index 00000000..c50f6420
--- /dev/null
+++ b/shared
@@ -0,0 +1 @@
+packages/gallery/shared
\ No newline at end of file
diff --git a/tests/avatar-input.test.ts b/tests/avatar-input.test.ts
index 39bd856a..669b6e39 100644
--- a/tests/avatar-input.test.ts
+++ b/tests/avatar-input.test.ts
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict'
import test from 'node:test'
-import { getAvatarInputType } from '../app/utils/avatar.ts'
+import { getAvatarInputType } from '../packages/gallery/app/utils/avatar.ts'
test('saved uploaded avatar paths do not require an absolute URL', () => {
assert.equal(
diff --git a/tests/location-label.test.ts b/tests/location-label.test.ts
index dcc6e147..8de5c2c2 100644
--- a/tests/location-label.test.ts
+++ b/tests/location-label.test.ts
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { ref } from 'vue'
-import { useLocationLabel } from '../app/composables/useLocationLabel.ts'
+import { useLocationLabel } from '../packages/gallery/app/composables/useLocationLabel.ts'
import type { NormalizedLocation } from '../shared/types/location.ts'
test('location label overrides survive isolated rendering and retain reactive defaults', () => {
diff --git a/tests/location-update.test.ts b/tests/location-update.test.ts
index 2225e30c..d9de7e0c 100644
--- a/tests/location-update.test.ts
+++ b/tests/location-update.test.ts
@@ -10,7 +10,7 @@ import {
updateGeocodedPhoto,
} from '../server/services/pipeline-queue/location-update.ts'
import type { LocationInfo } from '../server/services/location/geocoding.ts'
-import { photosToMarkers } from '../app/utils/clustering.ts'
+import { photosToMarkers } from '../packages/gallery/app/utils/clustering.ts'
const location: LocationInfo = {
latitude: 31,
diff --git a/tests/parse-script-tags.test.ts b/tests/parse-script-tags.test.ts
index e78a0e92..d84f86fb 100644
--- a/tests/parse-script-tags.test.ts
+++ b/tests/parse-script-tags.test.ts
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { createHead, renderSSRHead } from '@unhead/vue/server'
-import { parseScriptTags } from '../app/utils/parseScriptTags.ts'
+import { parseScriptTags } from '../packages/gallery/app/utils/parseScriptTags.ts'
test('preserves the Umami website ID alongside standard script attributes', () => {
assert.deepEqual(
diff --git a/tests/ui-api.test.ts b/tests/ui-api.test.ts
index 1e72a775..7731e43c 100644
--- a/tests/ui-api.test.ts
+++ b/tests/ui-api.test.ts
@@ -4,42 +4,47 @@ import test from 'node:test'
import vm from 'node:vm'
import ts from 'typescript'
-test('console API adapter delegates to request-scoped SSR fetch without requiring a factory', async () => {
- const calls: unknown[] = []
- const exports: Record<string, any> = {}
- const scopedFetch = async (request: unknown, options: unknown) => {
- calls.push({ request, options })
- return { authenticated: true }
- }
- const code = ts.transpileModule(
- readFileSync('packages/console/app/composables/useConsoleApi.ts', 'utf8'),
- { compilerOptions: { module: ts.ModuleKind.CommonJS } },
- ).outputText
- vm.runInNewContext(code, {
- exports,
- useRuntimeConfig: () => ({
- public: { console: { apiBase: 'https://portal.example.com' } },
- }),
- useRequestFetch: () => scopedFetch,
- useFetch: scopedFetch,
+for (const name of ['console', 'gallery'])
+ test(`${name} API adapter delegates to request-scoped SSR fetch without requiring a factory`, async () => {
+ const title = name[0]!.toUpperCase() + name.slice(1)
+ const calls: unknown[] = []
+ const exports: Record<string, any> = {}
+ const scopedFetch = async (request: unknown, options: unknown) => {
+ calls.push({ request, options })
+ return { authenticated: true }
+ }
+ const code = ts.transpileModule(
+ readFileSync(
+ `packages/${name}/app/composables/use${title}Api.ts`,
+ 'utf8',
+ ),
+ { compilerOptions: { module: ts.ModuleKind.CommonJS } },
+ ).outputText
+ vm.runInNewContext(code, {
+ exports,
+ useRuntimeConfig: () => ({
+ public: { [name]: { apiBase: 'https://portal.example.com' } },
+ }),
+ useRequestFetch: () => scopedFetch,
+ useFetch: scopedFetch,
+ })
+ assert.equal(
+ (await exports[`use${title}Api`]()('/api/photos', { method: 'GET' }))
+ .authenticated,
+ true,
+ )
+ await exports[`use${title}Fetch`]('/api/albums')
+ assert.equal(
+ JSON.stringify(calls),
+ JSON.stringify([
+ {
+ request: '/api/photos',
+ options: { baseURL: 'https://portal.example.com', method: 'GET' },
+ },
+ {
+ request: '/api/albums',
+ options: { baseURL: 'https://portal.example.com' },
+ },
+ ]),
+ )
})
- assert.equal(
- (await exports.useConsoleApi()('/api/photos', { method: 'GET' }))
- .authenticated,
- true,
- )
- await exports.useConsoleFetch('/api/albums')
- assert.equal(
- JSON.stringify(calls),
- JSON.stringify([
- {
- request: '/api/photos',
- options: { baseURL: 'https://portal.example.com', method: 'GET' },
- },
- {
- request: '/api/albums',
- options: { baseURL: 'https://portal.example.com' },
- },
- ]),
- )
-})