Explorar o código

[edit][dom缓存]

zhangwei %!s(int64=2) %!d(string=hai) anos
pai
achega
2b17af3d60

+ 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 = '固定右上角'