|
25 | 25 | </template> |
26 | 26 |
|
27 | 27 | <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' |
30 | 29 | import Modal from '../ui/Modal.vue' |
31 | 30 | import Tabs from '../ui/Tabs.vue' |
32 | 31 | import General from './setting/General.vue' |
33 | 32 | import Language from './setting/Language.vue' |
34 | 33 | 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' |
43 | 35 |
|
44 | 36 | const emit = defineEmits<{ |
45 | 37 | close: [] |
46 | 38 | 'settings-changed': [config: any] |
47 | 39 | }>() |
48 | 40 |
|
49 | | -// 处理编辑器设置变更 |
50 | | -const handleEditorSettingsChanged = (config: any) => { |
51 | | - console.log('设置模态框接收到编辑器配置变更:', config) |
52 | | - // 向上传递事件到主组件 |
53 | | - emit('settings-changed', config) |
54 | | -} |
55 | | -
|
56 | | -// 处理编辑器错误 |
57 | | -const handleEditorError = (message: string) => { |
58 | | - console.error('编辑器设置错误:', message) |
59 | | -} |
60 | | -
|
61 | | -const closeSettings = () => { |
62 | | - isVisible.value = false |
63 | | - setTimeout(() => { |
64 | | - emit('close') |
65 | | - }, 300) |
66 | | -} |
| 41 | +const { |
| 42 | + isVisible, |
| 43 | + activeTab, |
| 44 | + tabsData, |
| 45 | + handleEditorSettingsChanged, |
| 46 | + handleEditorError, |
| 47 | + closeSettings, |
| 48 | + initialize |
| 49 | +} = useSettings(emit) |
67 | 50 |
|
68 | 51 | onMounted(async () => { |
69 | | - // 延迟显示动画 |
70 | | - await nextTick() |
71 | | - setTimeout(() => { |
72 | | - isVisible.value = true |
73 | | - }, 50) |
| 52 | + await initialize() |
74 | 53 | }) |
75 | 54 | </script> |
0 commit comments