Files
legado/modules/web/src/components/SourceDebug.vue
Xwite 5efc367bc6 update vue3.3
web编辑 修正筛选删除导出逻辑
2023-05-14 19:36:52 +08:00

63 lines
1.2 KiB
Vue

<template>
<el-input
v-if="isBookSource"
id="debug-key"
v-model="searchKey"
placeholder="搜索书名、作者"
:prefix-icon="Search"
style="padding-bottom: 4px"
@keydown.enter="startDebug"
/>
<el-input
id="debug-text"
v-model="printDebug"
type="textarea"
readonly
rows="29"
placeholder="这里用于输出调试信息"
/>
</template>
<script setup>
import API from "@api";
import { Search } from "@element-plus/icons-vue";
const store = useSourceStore();
const printDebug = ref("");
const searchKey = ref("");
watch(
() => store.isDebuging,
() => {
if (store.isDebuging) startDebug();
}
);
const appendDebugMsg = (msg) => {
let debugDom = document.querySelector("#debug-text");
debugDom.scrollTop = debugDom.scrollHeight;
printDebug.value += msg + "\n";
};
const startDebug = async () => {
printDebug.value = "";
await API.saveSource(store.currentSource);
API.debug(
store.currentSourceUrl,
searchKey.value || store.searchKey,
appendDebugMsg,
store.debugFinish
);
};
const isBookSource = computed(() => {
return /bookSource/.test(window.location.href);
});
</script>
<style lang="scss" scoped>
:deep(#debug-text) {
height: calc(100vh - 45px - 36px - 5px);
}
</style>