数据共享-修改成 session local

永久和临时
This commit is contained in:
zdg 2024-09-02 11:14:47 +08:00
parent fa77c6cc6b
commit b5d41050ae
2 changed files with 42 additions and 19 deletions

View File

@ -8,25 +8,39 @@ Store.initRenderer()
// 默认共享数据 // 默认共享数据
const defaultData = { const defaultData = {
model: 'select', // 悬浮球-当前模式 session: { // 缓存(临时sessionStorage)
showBoardAll: false, // 全屏画板-是否显示 model: 'select', // 悬浮球-当前模式
isPdfWin: false, // pdf窗口是否打开 showBoardAll: false, // 全屏画板-是否显示
isToolWin: false, // 工具窗口是否打开 isPdfWin: false, // pdf窗口是否打开
curSubjectNode: { isToolWin: false, // 工具窗口是否打开
data: {}, // 当前教材节点 (包含当前教材 单元) curSubjectNode: {
querySearch: {} // 查询资源所需参数 data: {}, // 当前教材节点 (包含当前教材 单元)
} querySearch: {} // 查询资源所需参数
}
},
local: { // 本地(永久localStorage)
},
} }
// 初始化 // 初始化
export function initialize(){ export function initialize(){
const store = new Store({ // 缓存数据-sessionStore
name: 'cache-store', // 存储文件名 const sessionStore = new Store({
name: 'session-store', // 存储文件名
fileExtension: 'ini', // 文件后缀名 fileExtension: 'ini', // 文件后缀名
encryptionKey: 'Eihrjwi7h104h2Kub423' // 数据加密-防止用户直接改配置 encryptionKey: 'BvPLmgCC4DSIG0KkTec5' // 数据加密-防止用户直接改配置
}) })
store.clear() // 先清除-所有缓存数据 sessionStore.clear() // 先清除-所有缓存数据
store.set(defaultData) // 初始化-默认数据 sessionStore.set(defaultData.session) // 初始化-默认数据
return store
// 缓存数据-localStore
const localStore = new Store({
name: 'local-store', // 存储文件名
fileExtension: 'ini', // 文件后缀名
encryptionKey: '6CyoHQmUaPmLzvVsh' // 数据加密-防止用户直接改配置
})
localStore.set(defaultData.local) // 初始化-默认数据
return {sessionStore, localStore}
} }
export default { initialize } export default { initialize }

View File

@ -21,12 +21,21 @@ const toolState = useToolState() // 获取store状态
// 暴露Remote中的属性 // 暴露Remote中的属性
export const ipcMain = Remote?.ipcMain || {} export const ipcMain = Remote?.ipcMain || {}
// 暴露Store存储对象
export const store = Store ? new Store({ // 暴露sessionStore存储对象
name: 'cache-store', // 存储文件名 export const sessionStore = Store ? new Store({
fileExtension: 'ini', // 文件后缀名 name: 'session-store', // 存储文件名
encryptionKey: 'Eihrjwi7h104h2Kub423' // 数据加密-防止用户直接改配置 fileExtension: 'ini', // 文件后缀名
encryptionKey: 'BvPLmgCC4DSIG0KkTec5' // 数据加密-防止用户直接改配置
}) : {} }) : {}
// 暴露localStore存储对象
export const localStore = Store ? new Store({
name: 'local-store', // 存储文件名
fileExtension: 'ini', // 文件后缀名
encryptionKey: '6CyoHQmUaPmLzvVsh' // 数据加密-防止用户直接改配置
}) : {}
/** /**
* 获取静态资源开发和生产环境 * 获取静态资源开发和生产环境
* @param {*} url * @param {*} url