diff --git a/package.json b/package.json index 5165198b..f1736c9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moviepilot", - "version": "2.1.2", + "version": "2.1.4", "private": true, "bin": "dist/service.js", "scripts": { @@ -32,6 +32,7 @@ "apexcharts-clevision": "^3.28.5", "axios": "1.6.8", "colorthief": "^2.4.0", + "copy-to-clipboard": "^3.3.3", "dayjs": "^1.11.10", "express": "^4.18.2", "express-http-proxy": "^2.0.0", diff --git a/src/@core/components/ThemeSwitcher.vue b/src/@core/components/ThemeSwitcher.vue index e8f3af18..f35d4fa3 100644 --- a/src/@core/components/ThemeSwitcher.vue +++ b/src/@core/components/ThemeSwitcher.vue @@ -115,7 +115,7 @@ function changeTheme(theme: string) { // 保存主题到服务端 try { api.post('/user/config/Layout', { - theme: nextTheme + theme: nextTheme, }) } catch (e) { console.error('保存主题到服务端失败') @@ -176,7 +176,7 @@ async function saveCustomCSS() { }, }) - if (result.success) $toast.success('自定义CSS保存成功!') + if (result.success) $toast.success('自定义CSS保存成功,请刷新页面生效!') } catch (e) { console.error('保存自定义 CSS 到服务端失败') } diff --git a/src/@core/utils/navigator.ts b/src/@core/utils/navigator.ts index f60a0841..fc0c0891 100644 --- a/src/@core/utils/navigator.ts +++ b/src/@core/utils/navigator.ts @@ -1,3 +1,5 @@ +import copy from 'copy-to-clipboard' + // 请求和获取剪贴板内容 export async function getClipboardContent() { if (navigator.clipboard && window.isSecureContext) { @@ -13,20 +15,10 @@ export async function getClipboardContent() { } } -// 将内容复制到剪贴板,兼容非安全域场景 +// 将内容复制到剪贴板 export async function copyToClipboard(content: string) { - if (navigator.clipboard && window.isSecureContext) { - await navigator.clipboard.writeText(content) - } else { - const input = document.createElement('textarea') - input.value = content - document.body.appendChild(input) - // 阻止事件冒泡到其他元素,确保 focusin 事件只在 textarea 元素上处理,不会影响其他元素 - input.addEventListener('focusin', e => e.stopPropagation()) - input.select() - document.execCommand('copy') - document.body.removeChild(input) - } + const success = copy(content) + return success } // VAPID公钥转Uint8Array diff --git a/src/components/cards/CustomRuleCard.vue b/src/components/cards/CustomRuleCard.vue index cd6c95e0..2c80b155 100644 --- a/src/components/cards/CustomRuleCard.vue +++ b/src/components/cards/CustomRuleCard.vue @@ -98,8 +98,8 @@ function onClose() {
-
{{ props.rule.id }}
-
{{ props.rule.name }}
+
{{ props.rule.name }}
+
{{ props.rule.id }}
@@ -174,9 +174,9 @@ function onClose() { diff --git a/src/components/cards/FilterRuleGroupCard.vue b/src/components/cards/FilterRuleGroupCard.vue index 949a6a99..9bec8a4d 100644 --- a/src/components/cards/FilterRuleGroupCard.vue +++ b/src/components/cards/FilterRuleGroupCard.vue @@ -101,7 +101,7 @@ function filterCardClose(pri: string) { } // 分享规则 -function shareRules() { +async function shareRules() { if (filterRuleCards.value.length === 0) return const value = filterRuleCards.value @@ -110,8 +110,10 @@ function shareRules() { .join('>') try { - copyToClipboard(value) - $toast.success('优先级规则已复制到剪贴板') + let success + success = copyToClipboard(value) + if (await success) $toast.success('优先级规则已复制到剪贴板!') + else $toast.error('优先级规则复制失败:可能是浏览器不支持或被用户阻止!') } catch (error) { $toast.error('优先级规则复制失败!') console.error(error) diff --git a/src/components/cards/PluginAppCard.vue b/src/components/cards/PluginAppCard.vue index ab7572c1..22550530 100644 --- a/src/components/cards/PluginAppCard.vue +++ b/src/components/cards/PluginAppCard.vue @@ -149,80 +149,82 @@ const dropdownItems = ref([ diff --git a/src/components/cards/PluginCard.vue b/src/components/cards/PluginCard.vue index 6dcf9749..c33cc2c9 100644 --- a/src/components/cards/PluginCard.vue +++ b/src/components/cards/PluginCard.vue @@ -390,130 +390,146 @@ watch(