Skip to content

Commit 7f47912

Browse files
committed
feat (core): 优化 execute_hook 返回
1 parent 8c336d8 commit 7f47912

3 files changed

Lines changed: 7 additions & 19 deletions

File tree

src-tauri/src/plugins/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ pub trait LanguagePlugin: Send + Sync {
214214
}
215215

216216
// 后执行钩子
217-
fn post_execute_hook(&self, _result: &mut ExecutionResult) -> Result<(), String> {
217+
fn post_execute_hook(&self, result: &mut ExecutionResult) -> Result<(), String> {
218+
if result.success && result.stdout.is_empty() && result.stderr.is_empty() {
219+
result.stdout = "代码执行成功 (无输出)".to_string();
220+
}
221+
218222
Ok(())
219223
}
220224
}

src-tauri/src/plugins/python3.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{ExecutionResult, LanguagePlugin, PluginConfig};
1+
use super::{LanguagePlugin, PluginConfig};
22

33
pub struct Python3Plugin;
44

@@ -39,20 +39,4 @@ impl LanguagePlugin for Python3Plugin {
3939
fn get_default_command(&self) -> String {
4040
self.get_config().unwrap().run_command.unwrap()
4141
}
42-
43-
fn post_execute_hook(&self, result: &mut ExecutionResult) -> Result<(), String> {
44-
// Python 特定的后处理
45-
if result.success && result.stdout.is_empty() && result.stderr.is_empty() {
46-
result.stdout = "代码执行成功 (无输出)".to_string();
47-
}
48-
49-
// 清理 Python 特定的错误信息
50-
if !result.stderr.is_empty() {
51-
result.stderr = result
52-
.stderr
53-
.replace("Traceback (most recent call last):", "Error:");
54-
}
55-
56-
Ok(())
57-
}
5842
}

src/components/setting/Language.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="-mt-2">
3-
<Tabs v-model="activeTab" type="card" size="md" position="left" :tabs="tabsData" @change="handleTabChange">
3+
<Tabs v-model="activeTab" type="card" size="md" position="left" :tab-button-class="['w-36']" :tabs="tabsData" @change="handleTabChange">
44
<template #[activeTab]="{ tab }">
55
<h3 class="text-lg font-semibold text-gray-900 dark:text-white mb-4 flex items-center">
66
<Settings2 class="w-5 h-5 mr-2"/>

0 commit comments

Comments
 (0)