|
@@ -2,36 +2,49 @@ import {defineStore} from 'pinia';
|
|
|
import {reactive} from 'vue';
|
|
|
import { read_setting_data } from '../data/data';
|
|
|
import { config } from '../config/config';
|
|
|
+import { util } from '../framework/util';
|
|
|
export const ReadSetting = defineStore('read-setting',()=>{
|
|
|
let data:read_setting_data = reactive(new read_setting_data())
|
|
|
async function updateReadSetting(d:read_setting_data){
|
|
|
data.fontSizeIndex=d.fontSizeIndex;
|
|
|
data.colorBgIndex = d.colorBgIndex;
|
|
|
data.autoBuyNextChpater = d.autoBuyNextChpater
|
|
|
+ util.setStorage(config.storage_key.READ_SETTING,JSON.stringify(data))
|
|
|
}
|
|
|
|
|
|
async function changeFontSize(index:number){
|
|
|
data.fontSizeIndex=index;
|
|
|
+ util.setStorage(config.storage_key.READ_SETTING,JSON.stringify(data))
|
|
|
}
|
|
|
|
|
|
async function changeBgColor(index:number){
|
|
|
data.colorBgIndex=index;
|
|
|
+ util.setStorage(config.storage_key.READ_SETTING,JSON.stringify(data))
|
|
|
}
|
|
|
|
|
|
async function changeAutoBuyNextChapter(isAuto:boolean){
|
|
|
data.autoBuyNextChpater = isAuto
|
|
|
+ util.setStorage(config.storage_key.READ_SETTING,JSON.stringify(data))
|
|
|
}
|
|
|
|
|
|
async function changeReadMode(mode:number){
|
|
|
data.readMode = mode
|
|
|
+ util.setStorage(config.storage_key.READ_SETTING,JSON.stringify(data))
|
|
|
}
|
|
|
|
|
|
function getReadSetting():read_setting_data{
|
|
|
- if(data==null||data.colorBgIndex==undefined){
|
|
|
- data.colorBgIndex = 0;
|
|
|
- data.fontSizeIndex = 0;
|
|
|
- data.readMode = config.read_config.readMode.Bright
|
|
|
- data.autoBuyNextChpater = false
|
|
|
+ if(data==null||data ==undefined||data.colorBgIndex==undefined){
|
|
|
+ // util.removeStorageForKey(config.storage_key.READ_SETTING)
|
|
|
+ let obj = util.getStorage(config.storage_key.READ_SETTING)
|
|
|
+ if(obj) {
|
|
|
+ Object.assign(data,JSON.parse(obj))
|
|
|
+ }else{
|
|
|
+ data.colorBgIndex = 0;
|
|
|
+ data.fontSizeIndex = 0;
|
|
|
+ data.readMode = config.read_config.readMode.Bright
|
|
|
+ data.autoBuyNextChpater = false
|
|
|
+ util.setStorage(config.storage_key.READ_SETTING,JSON.stringify(data))
|
|
|
+ }
|
|
|
}
|
|
|
return data
|
|
|
}
|