浏览代码

[edit][dom缓存]

zhangwei 2 年之前
父节点
当前提交
2b17af3d60
共有 3 个文件被更改,包括 7 次插入4 次删除
  1. 2 2
      src/uilts/help.js
  2. 3 1
      src/view/content/tool-box/full.vue
  3. 2 1
      src/view/content/tool-box/index.vue

+ 2 - 2
src/uilts/help.js

@@ -232,8 +232,8 @@ export function checkURL(URL) {
 
 let $_data = []
 export function $(key, cache = true) {
-  if (!key) {
-    return
+  if (!key || typeof(key) != 'string') {
+    return null
   }
   // 不使用缓存
   if (!cache) {

+ 3 - 1
src/view/content/tool-box/full.vue

@@ -17,6 +17,8 @@
 <script setup>
 import { onMounted, reactive, ref } from "vue";
 import { sendEventInfo } from "@/uilts/event";
+import { $ } from "@/uilts/help";
+
 let state = reactive({
     status: '固定', // 全屏
     iframe_url: '',
@@ -50,7 +52,7 @@ const clickFull = () => {
     }
 }
 onMounted(() => {
-    dom_fixed = document.querySelector('#denet-tool-box-fixed')
+    dom_fixed = $('#denet-tool-box-fixed')
 })
 
 const changeFull = () => {

+ 2 - 1
src/view/content/tool-box/index.vue

@@ -56,6 +56,7 @@ import { getChromeStorage, setChromeStorage, httpContentToBack, defineProps } fr
 import { guid } from "@/uilts/help";
 import { sendEventInfo } from "@/uilts/event";
 import { onMounted, reactive, ref } from "vue";
+import { $ } from "@/uilts/help";
 let dom_toolbox = ref(null)
 let dom_iframe = ref(null)
 let state = reactive({
@@ -124,7 +125,7 @@ onMounted(() => {
         }
     }
     try {
-        dom.fixed = document.querySelector('#denet-tool-box-fixed')
+        dom.fixed = $('#denet-tool-box-fixed')
         if (dom.fixed && dom.fixed.style.display == 'block') {
             if (dom.fixed.dataset.tweetId == state.tweetId) {
                 state.status = '固定右上角'