11import type { UnlistenFn } from "@tauri-apps/api/event" ;
22import type { AssetItem , ConnectionBody , PermedAccount , PermedProtocol , TokenResponse } from "~/types" ;
33
4- import { K8S_NATIVE_VALUE , SFTP_FILE_EDITOR_VALUE , SFTP_FILE_MANAGER_VALUE } from "~/composables/useConnectMethods" ;
4+ import { K8S_NATIVE_VALUE , SFTP_FILE_EDITOR_VALUE , SFTP_FILE_MANAGER_VALUE , WEB_RDP_NATIVE_VALUE } from "~/composables/useConnectMethods" ;
55import { useSettingManager } from "~/composables/useSettingManager" ;
66import { useUserInfoStore } from "~/store/modules/userInfo" ;
77
@@ -25,9 +25,10 @@ let unlistenBuiltinSessionFailure: UnlistenFn | null = null;
2525const BUILTIN_CLIENT_METHOD = "builtin_client" ;
2626// 内置 Koko 界面,见 useConnectMethods 注入
2727const WEB_CLI_NATIVE_METHOD = "web_cli_native" ;
28- const NATIVE_KOKO_METHODS = new Set ( [
28+ const NATIVE_WORKSPACE_METHODS = new Set ( [
2929 BUILTIN_CLIENT_METHOD ,
3030 WEB_CLI_NATIVE_METHOD ,
31+ WEB_RDP_NATIVE_VALUE ,
3132 SFTP_FILE_MANAGER_VALUE ,
3233 SFTP_FILE_EDITOR_VALUE ,
3334 K8S_NATIVE_VALUE
@@ -397,15 +398,22 @@ export const useAssetAction = () => {
397398 } ;
398399
399400 const resolveServerConnectMethod = async ( body : ConnectionBody ) => {
400- // 服务端不认识本地注入的 method(builtin_client / web_cli_native),换成真实 koko web method
401- if ( ! NATIVE_KOKO_METHODS . has ( body . connect_method ) ) return body . connect_method ;
401+ // 服务端不认识本地注入的 method(builtin_client / web_cli_native / web_rdp_native ),换成真实 web method
402+ if ( ! NATIVE_WORKSPACE_METHODS . has ( body . connect_method ) ) return body . connect_method ;
402403
403404 try {
404405 const allMethods = await fetchConnectMethods ( ) ;
405406 const methods = allMethods [ body . protocol ] || [ ] ;
406407 const injected = methods . find ( ( item ) => item . value === body . connect_method ) ;
407408 if ( injected ?. origin_value ) return injected . origin_value ;
408409
410+ if ( body . connect_method === WEB_RDP_NATIVE_VALUE ) {
411+ const lionWeb = methods . find (
412+ ( item ) => item . type === "web" && [ "lion" , "tinker" ] . includes ( item . component ) && ! item . origin_value
413+ ) ;
414+ if ( lionWeb ) return lionWeb . value ;
415+ }
416+
409417 const kokoWeb = methods . find (
410418 ( item ) => item . type === "web" && [ "koko" , "default" ] . includes ( item . component ) && ! item . origin_value
411419 ) ;
@@ -415,6 +423,11 @@ export const useAssetAction = () => {
415423 return body . connect_method ;
416424 } ;
417425
426+ const resolveBuiltinComponent = ( body : ConnectionBody ) => {
427+ if ( body . connect_method === WEB_RDP_NATIVE_VALUE ) return "lion" ;
428+ return "koko" ;
429+ } ;
430+
418431 const getBuiltinConnectSession = (
419432 body : ConnectionBody ,
420433 meta : {
@@ -441,7 +454,7 @@ export const useAssetAction = () => {
441454 const payload = {
442455 token,
443456 ...token ,
444- connectMethod : { value : body . connect_method , component : "koko" }
457+ connectMethod : { value : body . connect_method , component : resolveBuiltinComponent ( body ) }
445458 } ;
446459 if ( meta . onSessionReady ) meta . onSessionReady ( payload ) ;
447460 else updateSessionPayload ( meta , payload ) ;
@@ -675,11 +688,11 @@ export const useAssetAction = () => {
675688 let tabId = ephemeral ?. tabId ;
676689
677690 // ponytail: 有 onSessionReady 时由调用方内嵌展示(如右侧 SFTP),不新开 workspace tab
678- if ( ! tabId && ephemeral ?. asset && NATIVE_KOKO_METHODS . has ( connectMethod ) && ! ephemeral ?. onSessionReady ) {
691+ if ( ! tabId && ephemeral ?. asset && NATIVE_WORKSPACE_METHODS . has ( connectMethod ) && ! ephemeral ?. onSessionReady ) {
679692 tabId = openSession ( ephemeral . asset , { protocol, account } ) . id ;
680693 }
681694
682- if ( NATIVE_KOKO_METHODS . has ( connectMethod ) ) {
695+ if ( NATIVE_WORKSPACE_METHODS . has ( connectMethod ) ) {
683696 getBuiltinConnectSession ( connectionBody , {
684697 tabId,
685698 assetId,
0 commit comments