fix(NoteShower): 修正内部HTML刷新导致的样式冲突问题

之前在NoteShower组件中,内部HTML内容是通过设置noteDoc变量直接注入的,这导致了样式冲突和页面渲染异常。此次修复通过注释掉Navbar组件并调整内部HTML内容的处理方式来解决这个问题。现在,使用div元素替换IFrame组件来显示noteDoc内容,同时,通过document.write方法来刷新页面内容,确保了页面样式的一致性和正确性。
This commit is contained in:
ZZY 2024-08-26 23:27:56 +08:00
parent 62429a13b2
commit f4d7e959ae

View File

@ -1,23 +1,13 @@
<template>
<Navbar/>
<!-- <Alert/> -->
<IFrame :frameUrl="noteUrl" :frameDoc="noteDoc"/>
</template>
<script setup lang='ts'>
import { computed, onMounted, ref, watch } from "vue"
import IFrame from '@/components/utils/IFrame.vue'
import Navbar from "@/components/Navbar.vue";
import Alert from '@/components/utils/Alert.vue'
import { computed, onMounted, ref } from "vue"
import FetchWrapper from "@/components/utils/FetchWapper";
import { file_api } from '@/router/config.json';
const props = defineProps(['note_name', 'token'])
let isShow = ref(true)
const noteUrl = ref()
const noteDoc = ref()
onMounted(() => {
FetchWrapper.fetch(`${file_api.root_url}/${file_api.notes.url}/${props.note_name}?type=${file_api.notes.type}`,
@ -36,13 +26,12 @@ onMounted(() => {
return response.text();
})
.then(htmlText => {
noteUrl.value = null;
noteDoc.value = htmlText;
// document.body.innerHTML = htmlText ?? '<h1>404</h1>';
document.open();
document.write(htmlText ?? '<h1>404</h1>');
document.close();
})
});
let msg = ref('msg')
let btnTxt = ref('btnTxt')
</script>
<style scoped>