LaiTool/src/stores/software.ts

65 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-07-13 15:44:13 +08:00
import { defineStore } from 'pinia'
2024-06-24 13:11:19 +08:00
// 系统相关设置
export const useSoftwareStore = defineStore('software', {
state: () => ({
2024-07-13 15:44:13 +08:00
spin: {
spinning: false,
tip: '加载中...'
},
2024-06-24 13:11:19 +08:00
softWare: {
2024-07-13 15:44:13 +08:00
theme: 'light', // 系统主题,亮或是暗
2024-06-24 13:11:19 +08:00
reverse_display_show: false, // 一键反推界面显示(简单的表格模式还是表格任务模式)
reverse_show_book_striped: false, // 是否显示斑马纹(反推界面)
2024-07-13 15:44:13 +08:00
reverse_data_table_size: 'small' // 反推界面表格大小
2024-06-24 13:11:19 +08:00
},
2024-08-03 12:46:12 +08:00
show_logger: false, // 是否显示日志
2024-07-13 15:44:13 +08:00
componentSize: [], // 组件尺寸(通用的选项)
SoftColor: null // 按钮颜色
2024-06-24 13:11:19 +08:00
}),
getters: {
// 获取一键反推界面显示数据
GetReverseDispalayShow(state) {
2024-07-13 15:44:13 +08:00
return state.softWare.reverse_display_show
}
2024-06-24 13:11:19 +08:00
},
actions: {
// 设置一键反推界面显示数据
SetReverseDispalayShow(value) {
2024-07-13 15:44:13 +08:00
this.softWare.reverse_display_show = value
2024-06-24 13:11:19 +08:00
},
// 设置反推界面时候小说信息显示斑马纹
SetReverseBookStripedShow(value) {
this.softWare.reverse_show_book_striped = value
},
// 修改软件主题
SetSoftware(value) {
2024-07-13 15:44:13 +08:00
this.softWare = Object.assign(this.softWare, value)
2024-06-24 13:11:19 +08:00
},
// 获取组件尺寸(判断当前是不是存在,不存在的话到主线程拿)
async GetComponentSize() {
debugger
if (this.componentSize.length == 0) {
2024-08-12 16:26:08 +08:00
//@ts-ignore
2024-07-13 15:44:13 +08:00
let res = await window.setting.GetComponentSize()
this.componentSize = res.data
2024-06-24 13:11:19 +08:00
}
2024-07-13 15:44:13 +08:00
return this.componentSize
2024-06-24 13:11:19 +08:00
},
//#region 保存到数据库的操作
// 将当前的software数据保存到数据库中
async SaveSoftware() {
// 保存数据
2024-08-12 16:26:08 +08:00
// @ts-ignore
2024-07-13 15:44:13 +08:00
return await window.setting.SaveSoftWareSetting(JSON.parse(JSON.stringify(this.softWare)))
2024-06-24 13:11:19 +08:00
}
//#endregion
}
2024-07-13 15:44:13 +08:00
})