feat(short-drama-agent-front): 新增全局主题和左右布局切换

This commit is contained in:
GJ committed 2026-11-06 22:07:42 +08:00
1 parent db9aea1694
commit 27ee9fd4ff
10 files changed
+709 -41

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
import { ref, watch } from 'vue'
/** 全局工作台主导航所在的一侧。 */
export type WorkspaceLayout = 'left' | 'right'
const storageKey = 'drama-studio-workspace-layout'
/**
* 读取工作台布局,缺少偏好或无法访问存储时使用左侧导航。
* @returns 已保存的主导航位置
*/
function readLayout(): WorkspaceLayout {
try {
if (localStorage.getItem(storageKey) === 'right') return 'right'
} catch {
/* 存储不可用时使用默认布局。 */
}
return 'left'
}
/**
* 保存工作台布局偏好,存储不可用时仍允许在当前页面切换。
* @returns 当前主导航位置
*/
export function useWorkspaceLayout() {
/** 侧栏和外观工具栏共用的布局偏好。 */
const layout = ref<WorkspaceLayout>(readLayout())
watch(layout, value => {
try {
localStorage.setItem(storageKey, value)
} catch {
/* 存储不可用时保留当前会话的选择。 */
}
})
return layout
}