51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { defineStore } from 'pinia'
|
|||
|
|
import { ref } from 'vue'
|
||
|
|
|
||
|
|
export const useBaseLayoutStore = defineStore(
|
||
|
|
'baseLayout',
|
||
|
|
() => {
|
||
|
|
/** 顶部导航栏标题 */
|
||
|
|
const topbarTitle = ref<string>('')
|
||
|
|
/** 当前选中的游戏 ID */
|
||
|
|
const activeGameId = ref<string>('basketball')
|
||
|
|
/** 当前选中的游戏图标 */
|
||
|
|
const activeGameIcon = ref<string>('🏀')
|
||
|
|
/** 当前选中的游戏名称 */
|
||
|
|
const activeGameName = ref<string>('篮球对决')
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 设置顶部导航栏标题
|
||
|
|
* @param title - 标题文本
|
||
|
|
*/
|
||
|
|
const setTopbarTitle = (title: string): void => {
|
||
|
|
topbarTitle.value = title
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 更新当前选中的游戏信息
|
||
|
|
* @param id - 游戏 ID
|
||
|
|
* @param icon - 游戏图标
|
||
|
|
* @param name - 游戏名称
|
||
|
|
*/
|
||
|
|
const setActiveGame = (id: string, icon: string, name: string): void => {
|
||
|
|
activeGameId.value = id
|
||
|
|
activeGameIcon.value = icon
|
||
|
|
activeGameName.value = name
|
||
|
|
}
|
||
|
|
|
||
|
|
return {
|
||
|
|
topbarTitle,
|
||
|
|
activeGameId,
|
||
|
|
activeGameIcon,
|
||
|
|
activeGameName,
|
||
|
|
setTopbarTitle,
|
||
|
|
setActiveGame
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
persist: {
|
||
|
|
pick: ['activeGameId', 'activeGameIcon', 'activeGameName']
|
||
|
|
}
|
||
|
|
}
|
||
|
|
)
|