fix(web/sourceeditor): update el-checkbox usage; fix reactivity bugs;update isbooksource regex

This commit is contained in:
Xwite
2024-10-03 16:32:13 +08:00
parent 2295b8bded
commit 1ed7d74c97
7 changed files with 16 additions and 8 deletions

View File

@@ -56,7 +56,7 @@ const startDebug = async () => {
};
const isBookSource = computed(() => {
return /bookSource/.test(window.location.href);
return /bookSource/i.test(window.location.href);
});
</script>

View File

@@ -2,7 +2,7 @@
<el-checkbox
size="large"
border
:label="sourceUrl"
:value="sourceUrl"
:class="{
error: isSaveError,
edit: sourceUrl == currentSourceUrl,

View File

@@ -127,7 +127,7 @@ const importSourceFile = () => {
input.click();
};
const isBookSource = /bookSource/.test(window.location.href);
const isBookSource = /bookSource/i.test(window.location.href);
const outExport = () => {
const exportFile = document.createElement("a");
let sources =

View File

@@ -60,7 +60,12 @@
<script setup>
const store = useSourceStore();
defineProps(["config"]);
const currentSource = store.currentSource;
const currentSource = computed(() => store.currentSource);
/*
修改currentSource的属性 没有直接修改本身
const { currentSource } = storeToRefs(store);
*/
</script>
<style lang="scss" scoped>

View File

@@ -19,7 +19,10 @@ import { useSourceStore } from "@/store";
const store = useSourceStore();
const current_tab = store.currentTab;
const current_tab = computed({
get:() => store.currentTab,
set:(val) => store.currentTab = val
});
const tabData = ref([
["editTab", "编辑源"],

View File

@@ -166,7 +166,7 @@ const redo = () => {
};
const saveSource = () => {
let isBookSource = /bookSource/.test(location.href),
let isBookSource = /bookSource/i.test(location.href),
/** @type {import("@/source.js").Source} */
source = store.currentSource;
if (isInvaildSource(source)) {

View File

@@ -19,7 +19,7 @@ export const useSourceStore = defineStore("source", {
/** @type {import("@/source").Source[]} */
savedSources: [], // 批量保存到阅读app成功的源
/** @type {import("@/source").Source} */
currentSource: emptySource, // 当前编辑的源
currentSource: JSON.parse(JSON.stringify(emptySource)), // 当前编辑的源
currentTab: localStorage.getItem("tabName") || "editTab",
editTabSource: {}, // 生成序列化的json数据
isDebuging: false,
@@ -119,7 +119,7 @@ export const useSourceStore = defineStore("source", {
},
clearEdit() {
this.editTabSource = {};
this.currentSource = emptySource;
this.currentSource = JSON.parse(JSON.stringify(emptySource)); //复制一份新对象
},
// clear all source