Add layout shells, desktop views, module-level page caches, and UI fixes for auth, home, wallet, transactions, address, and related pages. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import type { Component } from 'vue'
|
|
import { getConfigApp, isBoursecuProject } from '@/utils/config'
|
|
import type { HomeLayoutConfig, HomeLayoutId } from './types'
|
|
import { defaultHomeLayoutConfig } from './configs/default'
|
|
import { boursecuHomeLayoutConfig } from './configs/boursecu'
|
|
import HomeLayoutRenderer from './HomeLayoutRenderer.vue'
|
|
|
|
const HOME_LAYOUT_CONFIGS: Record<HomeLayoutId, HomeLayoutConfig> = {
|
|
default: defaultHomeLayoutConfig,
|
|
boursecu: boursecuHomeLayoutConfig,
|
|
}
|
|
|
|
const HOME_LAYOUT_COMPONENTS: Record<HomeLayoutId, Component> = {
|
|
default: HomeLayoutRenderer,
|
|
boursecu: HomeLayoutRenderer,
|
|
}
|
|
|
|
export const DEFAULT_HOME_LAYOUT_ID: HomeLayoutId = 'default'
|
|
|
|
export function isHomeLayoutId(value: unknown): value is HomeLayoutId {
|
|
return typeof value === 'string' && value in HOME_LAYOUT_CONFIGS
|
|
}
|
|
|
|
export function getHomeLayoutId(): HomeLayoutId {
|
|
const adminLayout = getConfigApp('home_layout')
|
|
if (isHomeLayoutId(adminLayout)) {
|
|
return adminLayout
|
|
}
|
|
|
|
if (isBoursecuProject()) {
|
|
return 'boursecu'
|
|
}
|
|
|
|
return DEFAULT_HOME_LAYOUT_ID
|
|
}
|
|
|
|
export function getHomeLayoutConfig(layoutId = getHomeLayoutId()): HomeLayoutConfig {
|
|
return HOME_LAYOUT_CONFIGS[layoutId] ?? HOME_LAYOUT_CONFIGS[DEFAULT_HOME_LAYOUT_ID]
|
|
}
|
|
|
|
export function resolveHomeLayoutComponent(layoutId = getHomeLayoutId()): Component {
|
|
return HOME_LAYOUT_COMPONENTS[layoutId] ?? HOME_LAYOUT_COMPONENTS[DEFAULT_HOME_LAYOUT_ID]
|
|
}
|
|
|
|
export function registerHomeLayoutConfig(layoutId: HomeLayoutId, config: HomeLayoutConfig) {
|
|
HOME_LAYOUT_CONFIGS[layoutId] = config
|
|
}
|