File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,8 +20,11 @@ impl PluginManager {
2020 }
2121
2222 pub fn get_supported_languages ( & self ) -> Vec < serde_json:: Value > {
23- self . plugins
24- . iter ( )
23+ let mut plugins: Vec < _ > = self . plugins . iter ( ) . collect ( ) ;
24+ plugins. sort_by_key ( |( _, plugin) | plugin. get_order ( ) ) ;
25+
26+ plugins
27+ . into_iter ( )
2528 . map ( |( key, plugin) | {
2629 serde_json:: json!( {
2730 "name" : plugin. get_language_name( ) ,
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ pub struct LanguageInfo {
2727
2828// 语言插件接口
2929pub trait LanguagePlugin : Send + Sync {
30+ fn get_order ( & self ) -> i32 {
31+ 0
32+ }
3033 fn get_language_name ( & self ) -> & ' static str ;
3134 fn get_file_extension ( & self ) -> & ' static str ;
3235 fn get_commands ( & self ) -> Vec < & ' static str > ;
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ use super::{ExecutionResult, LanguagePlugin};
33pub struct Python2Plugin ;
44
55impl LanguagePlugin for Python2Plugin {
6+ fn get_order ( & self ) -> i32 {
7+ 1
8+ }
9+
610 fn get_language_name ( & self ) -> & ' static str {
711 "Python 2"
812 }
@@ -30,7 +34,7 @@ impl LanguagePlugin for Python2Plugin {
3034 fn pre_execute_hook ( & self , code : & str ) -> Result < String , String > {
3135 // 添加一些 Python 特定的预处理
3236 let processed_code = format ! (
33- "# CodeForge Python Execution\n # Generated at: {}\n \n {}" ,
37+ "# CodeForge Python 2 Execution\n # Generated at: {}\n \n {}" ,
3438 chrono:: Utc :: now( ) . format( "%Y-%m-%d %H:%M:%S UTC" ) ,
3539 code
3640 ) ;
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ use super::{ExecutionResult, LanguagePlugin};
33pub struct Python3Plugin ;
44
55impl LanguagePlugin for Python3Plugin {
6+ fn get_order ( & self ) -> i32 {
7+ 2
8+ }
9+
610 fn get_language_name ( & self ) -> & ' static str {
711 "Python 3"
812 }
@@ -30,7 +34,7 @@ impl LanguagePlugin for Python3Plugin {
3034 fn pre_execute_hook ( & self , code : & str ) -> Result < String , String > {
3135 // 添加一些 Python 特定的预处理
3236 let processed_code = format ! (
33- "# CodeForge Python Execution\n # Generated at: {}\n \n {}" ,
37+ "# CodeForge Python 3 Execution\n # Generated at: {}\n \n {}" ,
3438 chrono:: Utc :: now( ) . format( "%Y-%m-%d %H:%M:%S UTC" ) ,
3539 code
3640 ) ;
Original file line number Diff line number Diff line change 66 <component :is =" envInfo.installed ? CheckCircle : XCircle"
77 :class =" envInfo.installed ? 'text-green-300' : 'text-white'"
88 class =" w-4 h-4" />
9- <span >{{ envInfo.installed ? `${ envInfo.language }: ${ envInfo.version }` : `${ envInfo.language } 环境未安装` }}</span >
9+ <span >{{ envInfo.installed ? `${ envInfo.language }: ${ envInfo.version }` : `${ envInfo.language }: 环境未安装` }}</span >
1010 </div >
1111
1212 <div v-if =" executionTime > 0" class =" flex items-center space-x-2" >
You can’t perform that action at this time.
0 commit comments