Преглед на файлове

Merge commit '207390ea33756d97b2cc0ae826202a490bf63198'

future преди 1 година
родител
ревизия
89bdeb4c0e

+ 2 - 3
xs-app/components/read/chapterCatalog.vue

@@ -175,9 +175,8 @@ import { UserStatus } from '../../stores/userStatusManager';
 		}
 	}
 	
-	let font_color = ref(tools.getFontColorByMode(ReadSetting().data.readMode))
-	let db_color = ref(tools.getDbColorByMode(ReadSetting().data.readMode))
-	
+	let font_color = ref(tools.getFontColorByMode(ReadSetting().getReadSetting().readMode))
+	let db_color = ref(tools.getDbColorByMode(ReadSetting().getReadSetting().readMode))
 	let book_data:book_item_data = UserStatus().getUserSelectBook()
 	
 	function onClickSort(){

+ 2 - 2
xs-app/components/read/readPage.vue

@@ -36,9 +36,9 @@
 			
 	}
 	
-	watch(async () => ReadSetting().data.readMode, // 监听的数据源
+	watch(async () => ReadSetting().getReadSetting().readMode, // 监听的数据源
 		(newVal, oldVal) => {
-			 font_color.value = tools.getFontColorByMode(ReadSetting().data.readMode)
+			 font_color.value = tools.getFontColorByMode(ReadSetting().getReadSetting().readMode)
 		}
 	);
 	defineExpose({ showBottomLoading,showTopLoading });

+ 4 - 5
xs-app/components/read/settingMenu.vue

@@ -72,7 +72,7 @@
 		// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
 		menu.value.open(type)
 	})
-	let mode = ref(ReadSetting().getReadSetting().readMode)
+	let mode = ref(ReadSetting().data.readMode)
 	let startPosY = ref(-1)
 	function maskTouch(e){
 		if(Math.abs(e.changedTouches[0].pageY-startPosY.value)>10){
@@ -88,15 +88,14 @@
 	function showSettingFont(){
 		showSettingFontSizeMode.value = true
 	}
-	
 	let showFontSize = ref(config.read_config.fontSizeList[ReadSetting().getReadSetting().fontSizeIndex])
-	let bgColorIndex = ref(ReadSetting().getReadSetting().colorBgIndex)
-	let isAutoBuy = ref(ReadSetting().getReadSetting().autoBuyNextChpater)
+	let bgColorIndex = ref(ReadSetting().data.colorBgIndex)
+	let isAutoBuy = ref(ReadSetting().data.autoBuyNextChpater)
 	watch(
 	     () => ReadSetting().data.fontSizeIndex, // 监听的数据源
 	     (newVal, oldVal) => {
 	       // console.log(`Count changed from ${oldVal} to ${newVal}`);
-		   showFontSize.value = config.read_config.fontSizeList[ReadSetting().getReadSetting().fontSizeIndex]
+		   showFontSize.value = config.read_config.fontSizeList[ReadSetting().data.fontSizeIndex]
 	       // 可以在这里执行一些操作,比如更新其他状态或触发其他函数
 	     }
     );

+ 1 - 0
xs-app/config/config.ts

@@ -33,6 +33,7 @@ export class config {
 	public static storage_key = {
 		USER_DATA: "USER_DATA",
 		BOOKSHELF_LIST: "BOOKSHELF_LIST",
+		READ_SETTING: "READ_SETTING"
 	}
 	
 	/**

+ 2 - 2
xs-app/pages/readbook/read.vue

@@ -200,14 +200,14 @@
 	function onChangeFontSize(index:number){
 		let new_index = -1;
 		if(index>0){
-			new_index = ReadSetting().getReadSetting().fontSizeIndex + 1
+			new_index = ReadSetting().data.fontSizeIndex + 1
 			if(new_index>=config.read_config.fontSizeList.length){
 				
 			}else{
 				ReadSetting().changeFontSize(new_index)
 			}
 		}else{
-			new_index = ReadSetting().getReadSetting().fontSizeIndex - 1
+			new_index = ReadSetting().data.fontSizeIndex - 1
 			if(new_index<0){
 				
 			}else{

+ 18 - 5
xs-app/stores/readSetting.ts

@@ -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
 	}