From 399aa9e6c4389a4ae816b9d7db0149adce29b32e Mon Sep 17 00:00:00 2001 From: dribble-njr Date: Sat, 11 Jan 2025 20:17:27 +0800 Subject: [PATCH 1/3] fix: extension installation check --- .../EditorHeader/PostInfo.vue | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/CodemirrorEditor/EditorHeader/PostInfo.vue b/src/components/CodemirrorEditor/EditorHeader/PostInfo.vue index f1367220c..aea02e379 100644 --- a/src/components/CodemirrorEditor/EditorHeader/PostInfo.vue +++ b/src/components/CodemirrorEditor/EditorHeader/PostInfo.vue @@ -61,8 +61,30 @@ function onUpdate(val: boolean) { } } +function checkExtension() { + if (window.$syncer !== undefined) { + extensionInstalled.value = true + return + } + + // 如果插件还没加载,5秒内每 500ms 检查一次 + let count = 0 + const timer = setInterval(() => { + if (window.$syncer !== undefined) { + extensionInstalled.value = true + clearInterval(timer) + return + } + + count++ + if (count > 10) { // 5秒后还是没有检测到,就停止检查 + clearInterval(timer) + } + }, 500) +} + onMounted(() => { - extensionInstalled.value = window.$syncer !== undefined + checkExtension() }) From 38a6fee7fefefbbb61853ae2f9e6c58c1706f1a5 Mon Sep 17 00:00:00 2001 From: dribble-njr Date: Sat, 11 Jan 2025 22:02:21 +0800 Subject: [PATCH 2/3] perf: optimize post dialog --- .../EditorHeader/PostInfo.vue | 94 ++++++++++++++----- src/types/index.ts | 20 ++++ 2 files changed, 90 insertions(+), 24 deletions(-) diff --git a/src/components/CodemirrorEditor/EditorHeader/PostInfo.vue b/src/components/CodemirrorEditor/EditorHeader/PostInfo.vue index aea02e379..668ca302a 100644 --- a/src/components/CodemirrorEditor/EditorHeader/PostInfo.vue +++ b/src/components/CodemirrorEditor/EditorHeader/PostInfo.vue @@ -1,40 +1,55 @@ @@ -113,9 +131,7 @@ onMounted(() => { 请安装 文章同步助手 @@ -143,14 +159,44 @@ onMounted(() => {