refactor(modules/web): arrange storeToRefs destruct

This commit is contained in:
Xwite
2024-10-02 18:19:25 +08:00
parent 320bd3d075
commit 01b031806b
10 changed files with 56 additions and 44 deletions

View File

@@ -132,21 +132,21 @@ const {
readSettingsVisible,
miniInterface,
showContent,
config,
readingBook,
bookProgress,
theme,
isNight,
} = storeToRefs(store);
const chapterPos = computed({
get: () => readingBook.value.chapterPos,
set: (value) => (readingBook.value.chapterPos = value),
get: () => store.readingBook.chapterPos,
set: (value) => (store.readingBook.chapterPos = value),
});
const chapterIndex = computed({
get: () => readingBook.value.index,
set: (value) => (readingBook.value.index = value),
get: () => store.readingBook.index,
set: (value) => (store.readingBook.index = value),
});
const theme = computed(() => config.value.theme);
const infiniteLoading = computed(() => config.value.infiniteLoading);
const infiniteLoading = computed(() => store.config.infiniteLoading);
// 字体
const fontFamily = computed(() => {
@@ -208,7 +208,6 @@ const rightBarTheme = computed(() => {
display: miniInterface.value && !showToolBar.value ? "none" : "block",
};
});
const isNight = computed(() => theme.value == 6);
/**
* pc移动端判断 最大阅读宽度修正

View File

@@ -84,9 +84,7 @@ import { Search } from "@element-plus/icons-vue";
import API from "@api";
const store = useBookStore();
const { connectStatus, connectType, newConnect, shelf, isDark } = storeToRefs(store);
const isNight = computed(() => isDark.value);
const isNight = computed(() => store.isNight);
const readingRecent = ref({
name: "尚无阅读记录",
@@ -101,8 +99,9 @@ const { showLoading, closeLoading, loadingWrapper, isLoading } = useLoading(
"正在获取书籍信息"
);
// 书架书籍和在线书籍搜索
const books = shallowRef([]);
const shelf = computed(() => store.shelf);
const search = ref("");
const isSearching = ref(false);
watchEffect(() => {
@@ -119,7 +118,7 @@ watchEffect(() => {
);
});
});
//搜索在线书籍
const searchBook = () => {
if (search.value == "") return;
books.value = [];
@@ -150,6 +149,10 @@ const searchBook = () => {
);
};
//连接状态
const connectStatus = computed(() => store.connectStatus);
const connectType = computed(() => store.connectType);
const newConnect = computed(() => store.newConnect);
const setIP = () => {
ElMessageBox.prompt(
"请输入 IP 和端口 ( 如127.0.0.1:9527 或者通过内网穿透的地址)",