4848 :show-progress =" true"
4949 @close =" toast.show = false" >
5050 </Toast >
51+
52+ <!-- 关于组件 -->
53+ <About v-if =" showAbout" @close =" closeAbout" />
5154 </div >
5255</template >
5356
5457<script setup lang="ts">
55- import { onMounted , ref } from ' vue'
58+ import { onMounted , onUnmounted , ref } from ' vue'
5659import { invoke } from ' @tauri-apps/api/core'
60+ import { listen , UnlistenFn } from ' @tauri-apps/api/event'
5761import AppHeader from ' ./components/AppHeader.vue'
5862import CodeEditor from ' ./components/CodeEditor.vue'
5963import OutputPanel from ' ./components/OutputPanel.vue'
6064import StatusBar from ' ./components/StatusBar.vue'
6165import Toast from ' ./components/Toast.vue'
66+ import About from ' ./components/About.vue'
6267
6368interface ExecutionResult
6469{
@@ -147,14 +152,20 @@ print(f"Squared: {squared}")`
147152}
148153
149154const code = ref (' ' )
150- const currentLanguage = ref (' python ' )
155+ const currentLanguage = ref (' python2 ' )
151156const output = ref (' ' )
152157const isRunning = ref (false )
153158const isSuccess = ref (false )
154159const lastExecutionTime = ref (0 )
155160const activeTab = ref (' output' )
156161const showSettings = ref (false )
157162const supportedLanguages = ref <Language []>([])
163+ const showAbout = ref (false )
164+ let unlistenFn: UnlistenFn | null = null
165+
166+ const closeAbout = () => {
167+ showAbout .value = false
168+ }
158169
159170const envInfo = ref <EnvInfo >({
160171 installed: false ,
@@ -285,10 +296,11 @@ const clearOutput = () => {
285296 showToast (' 输出已清空' , ' info' )
286297}
287298
288- window .addEventListener (" contextmenu" , (e ) => e .preventDefault (), false );
299+ window .addEventListener (' contextmenu' , (e ) => e .preventDefault (), false )
289300
290301onMounted (async () => {
291302 await getSupportedLanguages ()
303+ await refreshEnvInfo ()
292304
293305 // 设置初始代码模板
294306 if (supportedLanguages .value .length > 0 ) {
@@ -299,6 +311,15 @@ onMounted(async () => {
299311 code .value = codeTemplates .python
300312 }
301313
302- await refreshEnvInfo ()
314+ // 监听来自 Rust 的 show-about 事件
315+ unlistenFn = await listen (' show-about' , () => {
316+ showAbout .value = true
317+ })
318+ })
319+
320+ onUnmounted (() => {
321+ if (unlistenFn ) {
322+ unlistenFn ()
323+ }
303324})
304325 </script >
0 commit comments