Add env vars for default locale and map center
VITE_DEFAULT_LOCALE (fr/en/es) sets the initial language for the standalone app when no user preference is saved. VITE_DEFAULT_MAP_CENTER (lat,lng) configures the default map center point. Both fall back to sensible defaults (fr and France center) when not set. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8a3ff14568
commit
2ceedf8bbf
5 changed files with 40 additions and 3 deletions
|
|
@ -28,6 +28,12 @@ VITE_PUSH_NOTIFICATIONS_ENABLED=true
|
||||||
# Image Upload Configuration (pict-rs)
|
# Image Upload Configuration (pict-rs)
|
||||||
VITE_PICTRS_BASE_URL=https://img.mydomain.com
|
VITE_PICTRS_BASE_URL=https://img.mydomain.com
|
||||||
|
|
||||||
|
# Activities / Sortir Configuration
|
||||||
|
# Default language for the standalone activities app (fr, en, es)
|
||||||
|
VITE_DEFAULT_LOCALE=fr
|
||||||
|
# Default map center as "lat,lng" (defaults to France center if not set)
|
||||||
|
VITE_DEFAULT_MAP_CENTER=42.9667,1.6000
|
||||||
|
|
||||||
# Market Configuration
|
# Market Configuration
|
||||||
VITE_MARKET_NADDR=naddr1qqjxgdp4vv6rydej943n2dny956rwwf4943xzwfc95ekyd3evenrsvrrvc6r2qf8waehxw309akxucnfw3ejuct5d96xcctw9e5k7tmwdaehgunjv4kxz7f0v96xjmczyqrfrfkxv3m8t4elpe28x065z30zszaaqa4u0744qcmadsz3y50cjqcyqqq82scmcafla
|
VITE_MARKET_NADDR=naddr1qqjxgdp4vv6rydej943n2dny956rwwf4943xzwfc95ekyd3evenrsvrrvc6r2qf8waehxw309akxucnfw3ejuct5d96xcctw9e5k7tmwdaehgunjv4kxz7f0v96xjmczyqrfrfkxv3m8t4elpe28x065z30zszaaqa4u0744qcmadsz3y50cjqcyqqq82scmcafla
|
||||||
# OBSOLETE: Not used in codebase - market uses VITE_NOSTR_RELAYS instead
|
# OBSOLETE: Not used in codebase - market uses VITE_NOSTR_RELAYS instead
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
import type { AppConfig } from '@/core/types'
|
import type { AppConfig } from '@/core/types'
|
||||||
|
|
||||||
|
function parseMapCenter(envValue: string | undefined, fallback: { lat: number; lng: number }) {
|
||||||
|
if (!envValue) return fallback
|
||||||
|
const [lat, lng] = envValue.split(',').map(Number)
|
||||||
|
if (isNaN(lat) || isNaN(lng)) return fallback
|
||||||
|
return { lat, lng }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standalone activities app configuration.
|
* Standalone activities app configuration.
|
||||||
* Only enables base + activities modules.
|
* Only enables base + activities modules.
|
||||||
|
|
@ -36,7 +43,7 @@ export const appConfig: AppConfig = {
|
||||||
baseUrl: import.meta.env.VITE_LNBITS_BASE_URL || 'http://localhost:5000',
|
baseUrl: import.meta.env.VITE_LNBITS_BASE_URL || 'http://localhost:5000',
|
||||||
apiKey: import.meta.env.VITE_API_KEY || ''
|
apiKey: import.meta.env.VITE_API_KEY || ''
|
||||||
},
|
},
|
||||||
defaultMapCenter: { lat: 42.9667, lng: 1.6000 }, // Ariège, France
|
defaultMapCenter: parseMapCenter(import.meta.env.VITE_DEFAULT_MAP_CENTER, { lat: 42.9667, lng: 1.6000 }),
|
||||||
maxTicketsPerUser: 10,
|
maxTicketsPerUser: 10,
|
||||||
enableMap: true,
|
enableMap: true,
|
||||||
enablePrivateEvents: false
|
enablePrivateEvents: false
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import activitiesModule from '@/modules/activities'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
|
|
||||||
import '@/assets/index.css'
|
import '@/assets/index.css'
|
||||||
import { i18n } from '@/i18n'
|
import { i18n, changeLocale, type AvailableLocale } from '@/i18n'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the standalone activities app
|
* Initialize the standalone activities app
|
||||||
|
|
@ -59,6 +59,12 @@ export async function createAppInstance() {
|
||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
|
|
||||||
|
// Set default locale from env (user's saved preference takes priority via useStorage in i18n)
|
||||||
|
const defaultLocale = import.meta.env.VITE_DEFAULT_LOCALE as AvailableLocale | undefined
|
||||||
|
if (defaultLocale && !localStorage.getItem('user-locale')) {
|
||||||
|
await changeLocale(defaultLocale)
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize plugin manager
|
// Initialize plugin manager
|
||||||
pluginManager.init(app, router)
|
pluginManager.init(app, router)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
import type { AppConfig } from './core/types'
|
import type { AppConfig } from './core/types'
|
||||||
|
|
||||||
|
function parseMapCenter(envValue: string | undefined, fallback: { lat: number; lng: number }) {
|
||||||
|
if (!envValue) return fallback
|
||||||
|
const [lat, lng] = envValue.split(',').map(Number)
|
||||||
|
if (isNaN(lat) || isNaN(lng)) return fallback
|
||||||
|
return { lat, lng }
|
||||||
|
}
|
||||||
|
|
||||||
export const appConfig: AppConfig = {
|
export const appConfig: AppConfig = {
|
||||||
modules: {
|
modules: {
|
||||||
base: {
|
base: {
|
||||||
|
|
@ -84,7 +91,7 @@ export const appConfig: AppConfig = {
|
||||||
baseUrl: import.meta.env.VITE_LNBITS_BASE_URL || 'http://localhost:5000',
|
baseUrl: import.meta.env.VITE_LNBITS_BASE_URL || 'http://localhost:5000',
|
||||||
apiKey: import.meta.env.VITE_API_KEY || ''
|
apiKey: import.meta.env.VITE_API_KEY || ''
|
||||||
},
|
},
|
||||||
defaultMapCenter: { lat: 46.6034, lng: 1.8883 },
|
defaultMapCenter: parseMapCenter(import.meta.env.VITE_DEFAULT_MAP_CENTER, { lat: 46.6034, lng: 1.8883 }),
|
||||||
maxTicketsPerUser: 10,
|
maxTicketsPerUser: 10,
|
||||||
enableMap: true,
|
enableMap: true,
|
||||||
enablePrivateEvents: false
|
enablePrivateEvents: false
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,16 @@ import ActivityMap from '../components/ActivityMap.vue'
|
||||||
|
|
||||||
const { allActivities, isLoading, subscribe } = useActivities()
|
const { allActivities, isLoading, subscribe } = useActivities()
|
||||||
|
|
||||||
|
function parseMapCenter(): { lat: number; lng: number } | undefined {
|
||||||
|
const raw = import.meta.env.VITE_DEFAULT_MAP_CENTER
|
||||||
|
if (!raw) return undefined
|
||||||
|
const [lat, lng] = raw.split(',').map(Number)
|
||||||
|
if (isNaN(lat) || isNaN(lng)) return undefined
|
||||||
|
return { lat, lng }
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapCenter = parseMapCenter()
|
||||||
|
|
||||||
const geoActivities = computed(() =>
|
const geoActivities = computed(() =>
|
||||||
allActivities.value.filter(a => a.coordinates)
|
allActivities.value.filter(a => a.coordinates)
|
||||||
)
|
)
|
||||||
|
|
@ -33,6 +43,7 @@ onMounted(() => {
|
||||||
<ActivityMap
|
<ActivityMap
|
||||||
v-else
|
v-else
|
||||||
:activities="geoActivities"
|
:activities="geoActivities"
|
||||||
|
:center="mapCenter"
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue