Skip to content

Commit b58988f

Browse files
authored
Merge pull request #30 from qianmoQ/dev-25.0.1
fix (core): 修复编辑器修改后配置未更新
2 parents 4dd772a + df9113a commit b58988f

7 files changed

Lines changed: 158 additions & 43 deletions

File tree

docs/content/download.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: 下载 CodeForge
3+
4+
config:
5+
sidebar: false
6+
toc: false
7+
---
8+
9+
当前的 CodeForge 版本是 <img class="inline-flex" src="https://img.shields.io/github/v/release/devlive-community/codeforge.svg" />。有关详细信息,请参阅 [发行说明](/release/25.0.0.html)
10+
11+
<br />
12+
13+
::: grid
14+
- 适配 Windows
15+
- 适配 macOS
16+
:::
17+
18+
!btn[点我立即下载](https://github.com/devlive-community/codeforge/releases/){w-96 my-24 text-center text-white bg-green-500 hover:bg-green-600}

docs/content/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ hero:
1313
url: /download.html
1414
text: 立即下载
1515
secondaryCta:
16-
url: /<%= pageData.language %>/usage/href.html
16+
url: https://github.com/devlive-community/codeforge
1717
text: 了解更多
1818

1919
features:
@@ -47,13 +47,13 @@ stats:
4747
description: 我们取得的成就
4848
items:
4949
- label: GitHub Stars
50-
value: 0+
51-
- label: Gitee Stars
52-
value: 0+
53-
- label: 正常运行时间
54-
value: 99.99%
50+
value: 5+
51+
- label: 跨平台性(Windows、macOS)
52+
value: 3+
53+
- label: 支持的语言
54+
value: 5+
5555
- label: 客户满意度
56-
value: 0%
56+
value: 100%
5757

5858
cta:
5959
title: 准备好开始了吗?

docs/pageforge.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ repo:
1313
url: https://github.com/devlive-community/codeforge
1414
branch: dev
1515

16+
banner:
17+
content: 💗 <a href="https://github.com/devlive-community/codeforge" target="_blank">CodeForge <em>2025.0.0</em> 已经发布, 如果喜欢我们的软件,请点击这里支持我们</a> ❤️
18+
19+
feature:
20+
lucide:
21+
enable: true
22+
grid:
23+
enable: true
24+
share:
25+
enable: true
26+
options:
27+
qq: true
28+
wechat: true
29+
weibo: true
30+
sitemap:
31+
enable: true
32+
fontSize:
33+
enable: true
34+
button:
35+
enable: true
36+
1637
footer:
1738
copyright: © 2025 CodeForge All Rights Reserved.
1839
social:

src/App.vue

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</div>
2222
</div>
2323
<div class="flex-1 overflow-hidden">
24-
<CodeEditor v-model="code" class="h-full" :language="currentLanguage"/>
24+
<CodeEditor v-model="code" class="h-full" :language="currentLanguage" :editor-config="editorConfig" :key="editorConfigKey"/>
2525
</div>
2626
</div>
2727

@@ -44,7 +44,7 @@
4444
<About v-if="showAbout" @close="closeAbout"/>
4545

4646
<!-- 设置组件 -->
47-
<Settings v-if="showSettings" @close="closeSettings"/>
47+
<Settings v-if="showSettings" @close="closeSettings" @settings-changed="handleSettingsChanged"/>
4848

4949
<!-- 更新组件 -->
5050
<Update v-if="showUpdate" @close="closeUpdate"/>
@@ -55,7 +55,7 @@
5555
</template>
5656

5757
<script setup lang="ts">
58-
import { onMounted, onUnmounted } from 'vue'
58+
import { onMounted, onUnmounted, ref, watch } from 'vue'
5959
import AppHeader from './components/AppHeader.vue'
6060
import CodeEditor from './components/CodeEditor.vue'
6161
import OutputPanel from './components/OutputPanel.vue'
@@ -70,6 +70,7 @@ import { useCodeExecution } from './composables/useCodeExecution'
7070
import { useLanguageManager } from './composables/useLanguageManager'
7171
import { useEventManager } from './composables/useEventManager'
7272
import { useAppState } from './composables/useAppState'
73+
import { useEditorConfig } from './composables/useEditorConfig'
7374
import Update from './components/Update.vue'
7475
7576
const toast = useToast()
@@ -109,6 +110,34 @@ const {
109110
closeUpdate
110111
} = useAppState()
111112
113+
// 编辑器配置管理
114+
const {
115+
editorConfig,
116+
loadConfig: loadEditorConfig
117+
} = useEditorConfig()
118+
119+
// 强制刷新 CodeEditor 组件的 key
120+
const editorConfigKey = ref(0)
121+
122+
// 处理设置变更
123+
const handleSettingsChanged = (config: any) => {
124+
console.log('主组件接收到设置变更:', config)
125+
// 延迟一点点再刷新,减少闪烁
126+
setTimeout(() => {
127+
editorConfigKey.value++
128+
}, 50)
129+
}
130+
131+
// 监听编辑器配置变化
132+
watch(editorConfig, (newConfig) => {
133+
if (newConfig) {
134+
console.log('编辑器配置更新,刷新编辑器组件')
135+
setTimeout(() => {
136+
editorConfigKey.value++
137+
}, 50)
138+
}
139+
}, { deep: true })
140+
112141
const { initializeEventListeners, cleanupEventListeners } = useEventManager({
113142
showAbout,
114143
showSettings,
@@ -131,6 +160,7 @@ window.addEventListener('contextmenu', (e) => e.preventDefault(), false)
131160
132161
onMounted(async () => {
133162
await initialize()
163+
await loadEditorConfig()
134164
await initializeEventListeners()
135165
136166
// 触发 app-ready 事件,通知主进程

src/components/Settings.vue

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<!-- 编辑器配置 -->
1515
<template #editor>
16-
<Editor v-if="activeTab === 'editor'"/>
16+
<Editor v-if="activeTab === 'editor'" @settings-changed="handleEditorSettingsChanged" @error="handleEditorError"/>
1717
</template>
1818

1919
<!-- 语言配置 -->
@@ -25,38 +25,30 @@
2525
</template>
2626

2727
<script setup lang="ts">
28-
import { nextTick, onMounted, ref } from 'vue'
29-
import { BracesIcon, CodeIcon, ShieldIcon } from 'lucide-vue-next'
28+
import { onMounted } from 'vue'
3029
import Modal from '../ui/Modal.vue'
3130
import Tabs from '../ui/Tabs.vue'
3231
import General from './setting/General.vue'
3332
import Language from './setting/Language.vue'
3433
import Editor from './setting/Editor.vue'
35-
36-
const isVisible = ref(false)
37-
const activeTab = ref('general')
38-
const tabsData = [
39-
{ key: 'general', label: '通用', icon: ShieldIcon },
40-
{ key: 'editor', label: '编辑器', icon: CodeIcon },
41-
{ key: 'language', label: '语言', icon: BracesIcon }
42-
]
34+
import { useSettings } from '../composables/useSettings.ts'
4335
4436
const emit = defineEmits<{
4537
close: []
38+
'settings-changed': [config: any]
4639
}>()
4740
48-
const closeSettings = () => {
49-
isVisible.value = false
50-
setTimeout(() => {
51-
emit('close')
52-
}, 300)
53-
}
41+
const {
42+
isVisible,
43+
activeTab,
44+
tabsData,
45+
handleEditorSettingsChanged,
46+
handleEditorError,
47+
closeSettings,
48+
initialize
49+
} = useSettings(emit)
5450
5551
onMounted(async () => {
56-
// 延迟显示动画
57-
await nextTick()
58-
setTimeout(() => {
59-
isVisible.value = true
60-
}, 50)
52+
await initialize()
6153
})
6254
</script>

src/components/setting/Editor.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
<div class="flex gap-2">
88
<input v-model="editorConfig.indent_with_tab"
99
type="checkbox"
10-
placeholder="超时时间(秒),默认 30 秒"
11-
class="flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-transparent text-sm"/>
10+
class="px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-transparent text-sm"/>
1211
</div>
1312
</div>
1413

@@ -17,12 +16,12 @@
1716
缩进空格数
1817
</label>
1918
<div class="flex gap-2">
20-
<input v-model="editorConfig.tab_size"
19+
<input v-model.number="editorConfig.tab_size"
2120
type="number"
22-
:disabled="!editorConfig.indent_with_tab"
23-
placeholder="缩进空格数,默认 2 秒"
24-
class="flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-transparent text-sm"
25-
:class="[!editorConfig.indent_with_tab ? 'opacity-50 cursor-not-allowed' : '']"/>
21+
min="1"
22+
max="8"
23+
placeholder="缩进空格数,默认 2"
24+
class="flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-transparent text-sm"/>
2625
</div>
2726
</div>
2827

@@ -31,10 +30,7 @@
3130
编辑器主题
3231
</label>
3332
<div class="flex gap-2">
34-
<Select v-model="editorConfig.theme"
35-
class="w-1/4"
36-
placeholder="选择编辑器主题"
37-
:options="themeOptions"/>
33+
<Select v-model="editorConfig.theme" class="w-1/4" placeholder="选择编辑器主题" :options="themeOptions"/>
3834
</div>
3935
</div>
4036
</div>

src/composables/useSettings.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { nextTick, ref } from 'vue'
2+
import { BracesIcon, CodeIcon, ShieldIcon } from 'lucide-vue-next'
3+
4+
export function useSettings(emit: any)
5+
{
6+
// 状态管理
7+
const isVisible = ref(false)
8+
const activeTab = ref('general')
9+
10+
// 标签页配置
11+
const tabsData = [
12+
{ key: 'general', label: '通用', icon: ShieldIcon },
13+
{ key: 'editor', label: '编辑器', icon: CodeIcon },
14+
{ key: 'language', label: '语言', icon: BracesIcon }
15+
]
16+
17+
// 处理编辑器设置变更
18+
const handleEditorSettingsChanged = (config: any) => {
19+
console.log('设置模态框接收到编辑器配置变更:', config)
20+
// 向上传递事件到主组件
21+
emit('settings-changed', config)
22+
}
23+
24+
// 处理编辑器错误
25+
const handleEditorError = (message: string) => {
26+
console.error('编辑器设置错误:', message)
27+
}
28+
29+
// 关闭设置
30+
const closeSettings = () => {
31+
isVisible.value = false
32+
setTimeout(() => {
33+
emit('close')
34+
}, 300)
35+
}
36+
37+
// 初始化模态框
38+
const initialize = async () => {
39+
// 延迟显示动画
40+
await nextTick()
41+
setTimeout(() => {
42+
isVisible.value = true
43+
}, 50)
44+
}
45+
46+
return {
47+
// 状态
48+
isVisible,
49+
activeTab,
50+
tabsData,
51+
52+
// 方法
53+
handleEditorSettingsChanged,
54+
handleEditorError,
55+
closeSettings,
56+
initialize
57+
}
58+
}

0 commit comments

Comments
 (0)