layout.ts
1 import { defineStore } from 'pinia' 2 3 export type RoutePath = '/' | '/chat' | '/agent' | '/setting' 4 5 const PATH_TO_SCREEN = { 6 '/': 0, 7 '/chat': 1, 8 '/agent': 2, 9 '/setting': 3 10 } as Record<RoutePath, number> 11 12 type ScreenKey = keyof typeof PATH_TO_SCREEN 13 type ScreenValue = (typeof PATH_TO_SCREEN)[ScreenKey] 14 15 type LoadingStatus = 'start' | 'stop' | false 16 17 export const getScreenFromPath = (path: string): ScreenValue => { 18 return PATH_TO_SCREEN[path as ScreenKey] ?? 0 19 } 20 21 export const useLayoutStore = defineStore('layoutStore', { 22 state: () => ({ 23 sidebar: true, 24 apiKeyShow: false, 25 mcpLoading: false as LoadingStatus, 26 screen: 0 // The selected screen is a list: 0,1,2,... 27 }) 28 })