From c83b5ab6c066e582ea0b7e8bf54ad087e41c113f Mon Sep 17 00:00:00 2001 From: tone <3341154833@qq.com> Date: Sun, 13 Oct 2024 14:31:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=B7=B1=E8=89=B2=E6=A8=A1=E5=BC=8F=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tonecn/src/components/Console/FileOnline.vue | 83 +++++++++++++------- tonecn/src/views/Console/Login.vue | 4 +- 2 files changed, 55 insertions(+), 32 deletions(-) diff --git a/tonecn/src/components/Console/FileOnline.vue b/tonecn/src/components/Console/FileOnline.vue index a3f9d1c..2efa4e3 100644 --- a/tonecn/src/components/Console/FileOnline.vue +++ b/tonecn/src/components/Console/FileOnline.vue @@ -15,7 +15,8 @@ import 'ace-builds/src-noconflict/mode-typescript' import 'ace-builds/src-noconflict/mode-html' import 'ace-builds/src-noconflict/mode-css' import 'ace-builds/src-noconflict/mode-vue' -import 'ace-builds/src-noconflict/theme-chrome'; +import 'ace-builds/src-noconflict/theme-github'; +import 'ace-builds/src-noconflict/theme-github_dark' import modeJsonUrl from 'ace-builds/src-noconflict/mode-json?url'; ace.config.setModuleUrl('ace/mode/json', modeJsonUrl); import themeChromeUrl from 'ace-builds/src-noconflict/theme-chrome?url'; @@ -56,6 +57,24 @@ onMounted(async () => { await loadFullFileList(); loadFileListShow(); + + // aceEditor 深色模式监听 + // 监听主题变化 + window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', checkTheme); + // 初始检查 + checkTheme(); +}) + +const checkTheme = () => { + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + aceEditorTheme.value = 'github_dark' + } else { + aceEditorTheme.value = 'github' + } +}; + +onMounted(() => { + window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', checkTheme); }) // 当前目录 @@ -340,6 +359,7 @@ const saveAceEditorContent = async () => { saveAceEditorContentLoading.value = false; } } +const aceEditorTheme = ref('github'); \ No newline at end of file diff --git a/tonecn/src/views/Console/Login.vue b/tonecn/src/views/Console/Login.vue index 1017fb2..6b31eda 100644 --- a/tonecn/src/views/Console/Login.vue +++ b/tonecn/src/views/Console/Login.vue @@ -62,12 +62,12 @@ onMounted(async () => {
-

登录到控制台

+

登录到控制台

控制台是特恩(TONE)网页中的一个控制器界面,如果您是管理员,可通过登录后编辑本网页中的内容(资源、工具、日记等),详情请见《特恩(TONE)控制台使用协议》