shumengya mail@smyhub.com
This commit is contained in:
3
mengyaconnect-frontend/.env.production
Normal file
3
mengyaconnect-frontend/.env.production
Normal file
@@ -0,0 +1,3 @@
|
||||
VITE_API_BASE=https://ssh.api.shumengya.top/api
|
||||
VITE_WS_URL=wss://ssh.api.shumengya.top/api/ws/ssh
|
||||
|
||||
13
mengyaconnect-frontend/index.html
Normal file
13
mengyaconnect-frontend/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>萌芽SSH</title>
|
||||
<meta name="description" content="柔和渐变风格的 Web SSH 连接面板,支持多窗口终端。" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1224
mengyaconnect-frontend/package-lock.json
generated
Normal file
1224
mengyaconnect-frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
20
mengyaconnect-frontend/package.json
Normal file
20
mengyaconnect-frontend/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "mengyaconnect-frontend",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
"@xterm/xterm": "^5.0.0",
|
||||
"vue": "^3.4.38"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.1.2",
|
||||
"vite": "^5.4.10"
|
||||
}
|
||||
}
|
||||
1902
mengyaconnect-frontend/src/App.vue
Normal file
1902
mengyaconnect-frontend/src/App.vue
Normal file
File diff suppressed because it is too large
Load Diff
33
mengyaconnect-frontend/src/api.js
Normal file
33
mengyaconnect-frontend/src/api.js
Normal file
@@ -0,0 +1,33 @@
|
||||
export function getApiBase() {
|
||||
const envBase = import.meta.env.VITE_API_BASE;
|
||||
if (envBase) {
|
||||
return String(envBase).replace(/\/+$/, "");
|
||||
}
|
||||
// 默认走同源 /api(更适合反向代理 + HTTPS)
|
||||
if (typeof window === "undefined") return "http://localhost:8080/api";
|
||||
return `${window.location.origin}/api`;
|
||||
}
|
||||
|
||||
export async function apiRequest(path, options = {}) {
|
||||
const base = getApiBase();
|
||||
const res = await fetch(`${base}${path}`, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...(options.headers || {}),
|
||||
},
|
||||
...options,
|
||||
});
|
||||
let body = null;
|
||||
try {
|
||||
body = await res.json();
|
||||
} catch {
|
||||
body = null;
|
||||
}
|
||||
if (!res.ok) {
|
||||
const message =
|
||||
(body && body.error) || `请求失败 (${res.status} ${res.statusText})`;
|
||||
throw new Error(message);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
5
mengyaconnect-frontend/src/main.js
Normal file
5
mengyaconnect-frontend/src/main.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import { createApp } from "vue";
|
||||
import "@xterm/xterm/css/xterm.css";
|
||||
import App from "./App.vue";
|
||||
|
||||
createApp(App).mount("#app");
|
||||
10
mengyaconnect-frontend/vite.config.js
Normal file
10
mengyaconnect-frontend/vite.config.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { defineConfig } from "vite";
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
server: {
|
||||
host: true,
|
||||
port: 5173,
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user