Skip to content

Commit 9368add

Browse files
committed
perf: add lion connector
1 parent 660e13f commit 9368add

64 files changed

Lines changed: 8246 additions & 20 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.development

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ VITE_KOKO_HOST = 'http://localhost:5050'
77
# VITE_CHEN_WS = 'ws://localhost:9523'
88
# VITE_CHEN_HOST = 'http://localhost:9523'
99

10-
# VITE_LION_WS = 'ws://localhost:9529'
11-
# VITE_LION_HOST = 'http://localhost:9529'
10+
# VITE_LION_WS = 'ws://localhost:8081'
11+
# VITE_LION_HOST = 'http://localhost:8081'

.pnpm-store/v11/index.db

8 KB
Binary file not shown.

nuxt.config.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const jumpServerTarget = process.env.JMS_CORE_DEV_URL || "http://localhost:8080";
22
const kokoTarget = process.env.JMS_KOKO_DEV_URL || "http://localhost:5050";
3-
const lionTarget = process.env.JMS_LION_DEV_URL || "http://localhost:9529";
3+
const lionTarget = process.env.JMS_LION_DEV_URL || "http://localhost:8081";
44
const chenTarget = process.env.JMS_CHEN_DEV_URL || "http://localhost:9523";
55
const faceliveTarget = process.env.JMS_FACELIVE_DEV_URL || "http://localhost:5173";
66
const kaelTarget = process.env.JMS_KAEL_DEV_URL || "http://localhost:5172";
@@ -162,12 +162,35 @@ export default defineNuxtConfig({
162162
changeOrigin: true,
163163
configure: rewriteProxyOrigin(jumpServerTarget)
164164
},
165-
"/lion": {
165+
"/luna/lion/ws/": {
166+
target: lionTarget.replace(/^http/i, "ws"),
167+
secure: false,
168+
ws: true,
169+
changeOrigin: true,
170+
rewrite: (path) => path.replace(/^\/luna/, ""),
171+
configure: bindProxyErrorHandler("luna-lion-ws")
172+
},
173+
"/luna/lion/": {
174+
target: lionTarget,
175+
secure: false,
176+
ws: true,
177+
changeOrigin: true,
178+
rewrite: (path) => path.replace(/^\/luna/, ""),
179+
configure: bindProxyErrorHandler("luna-lion-http")
180+
},
181+
"/lion/ws/": {
182+
target: lionTarget.replace(/^http/i, "ws"),
183+
secure: false,
184+
ws: true,
185+
changeOrigin: true,
186+
configure: bindProxyErrorHandler("lion-ws")
187+
},
188+
"/lion/": {
166189
target: lionTarget,
167190
secure: false,
168191
ws: true,
169192
changeOrigin: true,
170-
rewrite: (path) => path.replace(/^\/lion\/monitor/, "/monitor")
193+
configure: bindProxyErrorHandler("lion-http")
171194
},
172195
"/chen": {
173196
target: chenTarget,

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"fflate": "^0.8.2",
7979
"guacamole-common-js-jumpserver": "1.1.0-c",
8080
"js-untar": "^2.0.0",
81+
"lucide-vue-next": "^0.525.0",
8182
"mitt": "^3.0.1",
8283
"nora-zmodemjs": "^1.1.1",
8384
"nuxt": "^4.4.6",

pnpm-lock.yaml

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<script setup lang="ts">
2+
import { message as lionMessages } from "@/lion/locales/modules";
3+
import { LanguageCode } from "@/lion/utils/config";
4+
import { withBasePath } from "@/lion/utils/base";
5+
6+
import "@/lion/styles/base.css";
7+
8+
const { mergeLocaleMessage } = useI18n();
9+
10+
const loaded = ref(false);
11+
const normalizedLangCode = LanguageCode.toLowerCase();
12+
13+
onMounted(async () => {
14+
for (const [code, value] of Object.entries(lionMessages)) {
15+
mergeLocaleMessage(code, value);
16+
}
17+
18+
try {
19+
const response = await fetch(`${withBasePath("/api/v1/settings/i18n/lion/")}?lang=${encodeURIComponent(normalizedLangCode)}&flat=0`, {
20+
credentials: "include"
21+
});
22+
23+
if (response.ok) {
24+
const translations = await response.json();
25+
for (const [key, value] of Object.entries(translations)) {
26+
mergeLocaleMessage(key, value as Record<string, any>);
27+
}
28+
}
29+
} catch (error) {
30+
console.error("load lion i18n failed", error);
31+
} finally {
32+
loaded.value = true;
33+
}
34+
});
35+
</script>
36+
37+
<template>
38+
<div v-if="loaded" class="h-full w-full overflow-hidden">
39+
<slot />
40+
</div>
41+
</template>

ui/composables/useAssetAction.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { UnlistenFn } from "@tauri-apps/api/event";
22
import 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";
55
import { useSettingManager } from "~/composables/useSettingManager";
66
import { useUserInfoStore } from "~/store/modules/userInfo";
77

@@ -25,9 +25,10 @@ let unlistenBuiltinSessionFailure: UnlistenFn | null = null;
2525
const BUILTIN_CLIENT_METHOD = "builtin_client";
2626
// 内置 Koko 界面,见 useConnectMethods 注入
2727
const 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,

ui/composables/useConnectMethods.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export {
88
K8S_NATIVE_VALUE,
99
SFTP_FILE_EDITOR_VALUE,
1010
SFTP_FILE_MANAGER_VALUE,
11-
WEB_CLI_NATIVE_VALUE
11+
WEB_CLI_NATIVE_VALUE,
12+
WEB_RDP_NATIVE_VALUE
1213
} from "~/shared/connectors/capabilities";
1314

1415
interface ConnectMethod {
@@ -69,6 +70,28 @@ const normalizeWebConnectMethods = (methods: ConnectMethodsResponse): ConnectMet
6970
}
7071
}
7172

73+
const lionWebIndex = renamed.findIndex(
74+
(method) => method.type === "web" && ["lion", "tinker"].includes(method.component)
75+
);
76+
77+
if (lionWebIndex !== -1) {
78+
const origin = renamed[lionWebIndex]!;
79+
const declaredMethods = COMPONENT_WORKSPACE_CAPABILITIES
80+
.filter((item) => item.component === "lion" && item.protocols.includes(key))
81+
.flatMap((item) =>
82+
item.connectMethods.map((methodValue) => ({
83+
...origin,
84+
value: methodValue,
85+
label: item.label,
86+
origin_value: origin.value
87+
}) as ConnectMethod)
88+
);
89+
90+
if (declaredMethods.length) {
91+
renamed.splice(lionWebIndex, 1, ...declaredMethods);
92+
}
93+
}
94+
7295
normalized[key] = renamed;
7396
});
7497

ui/layouts/lion.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<LionProvider>
3+
<slot />
4+
</LionProvider>
5+
</template>

ui/lion/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
# Lion connector (Phase 3)
1+
# Lion connector
2+
3+
Lion 是 RDP/VNC 远程桌面 connector,结构与 koko 对齐:
4+
5+
- `views/` — 独立页面(`/lion/connect``/lion/share``/lion/monitor`
6+
- `workspaces/` — 内嵌到 Luna workspace 的 session surface
7+
- `shared/connectors/capabilities.ts` — 声明 `web_rdp_native` 连接方式
8+
- `shared/connectors/registry.ts` — 解析到 `RemoteSessionSurface.vue`
9+
10+
开发代理见根目录 `nuxt.config.ts``/lion/``/lion/ws/` 转发到 `localhost:8081`。API/WS 固定走站点根路径 `/lion/*`(不带 `/luna` 前缀)。

0 commit comments

Comments
 (0)