- 端口修复

This commit is contained in:
Pine
2026-05-13 00:18:13 +08:00
parent 7794012299
commit 2bd68815fd
5 changed files with 15 additions and 19 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ pub fn run() {
// 等待 HTTP 服务器就绪后再打开窗口 // 等待 HTTP 服务器就绪后再打开窗口
for i in 0..50 { for i in 0..50 {
if let Ok(mut s) = std::net::TcpStream::connect_timeout( if let Ok(mut s) = std::net::TcpStream::connect_timeout(
&"127.0.0.1:8000".parse().unwrap(), &"127.0.0.1:10801".parse().unwrap(),
Duration::from_millis(500), Duration::from_millis(500),
) { ) {
// 发送一个简单的 HTTP 请求测试 // 发送一个简单的 HTTP 请求测试
+5 -5
View File
@@ -121,13 +121,13 @@ pub async fn start() {
let state = AppState::new(); let state = AppState::new();
let app = create_router(state); let app = create_router(state);
println!("🚀 大屏媒体轮播系统启动于 http://0.0.0.0:8000"); println!("🚀 大屏媒体轮播系统启动于 http://0.0.0.0:10801");
println!(" - 管理后台: http://localhost:8000/admin"); println!(" - 管理后台: http://localhost:10801/admin");
println!(" - 大屏展示: http://localhost:8000/screen"); println!(" - 大屏展示: http://localhost:10801/screen");
let listener = tokio::net::TcpListener::bind("0.0.0.0:8000") let listener = tokio::net::TcpListener::bind("0.0.0.0:10801")
.await .await
.expect("无法绑定 0.0.0.0:8000,请检查端口是否被占用"); .expect("无法绑定 0.0.0.0:10801,请检查端口是否被占用");
axum::serve(listener, app) axum::serve(listener, app)
.await .await
.expect("服务器启动失败"); .expect("服务器启动失败");
+1 -1
View File
@@ -4,7 +4,7 @@
"version": "0.1.0", "version": "0.1.0",
"identifier": "com.pine.dpm", "identifier": "com.pine.dpm",
"build": { "build": {
"beforeDevCommand": "TAURI_DEV_HOST=0.0.0.0 yarn dev", "beforeDevCommand": "yarn dev",
"devUrl": "http://localhost:1420", "devUrl": "http://localhost:1420",
"beforeBuildCommand": "yarn build", "beforeBuildCommand": "yarn build",
"frontendDist": "../dist" "frontendDist": "../dist"
+1 -1
View File
@@ -1,7 +1,7 @@
// API 基地址:Tauri 生产环境使用绝对路径,浏览器环境使用相对路径 // API 基地址:Tauri 生产环境使用绝对路径,浏览器环境使用相对路径
const BASE = window.location.protocol === 'http:' || window.location.protocol === 'https:' const BASE = window.location.protocol === 'http:' || window.location.protocol === 'https:'
? '' // 浏览器环境 — 同源请求 ? '' // 浏览器环境 — 同源请求
: 'http://localhost:8000'; // Tauri 生产环境 (tauri://) : 'http://localhost:10801'; // Tauri 生产环境 (tauri://)
async function request(url, options = {}) { async function request(url, options = {}) {
const res = await fetch(`${BASE}${url}`, { const res = await fetch(`${BASE}${url}`, {
+7 -11
View File
@@ -1,8 +1,6 @@
import { defineConfig } from "vite"; import { defineConfig } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/ // https://vite.dev/config/
export default defineConfig(async () => ({ export default defineConfig(async () => ({
plugins: [react()], plugins: [react()],
@@ -11,19 +9,17 @@ export default defineConfig(async () => ({
server: { server: {
port: 1420, port: 1420,
strictPort: true, strictPort: true,
host: host || "127.0.0.1", // 监听所有网络接口,局域网内其他设备可通过 http://<IP>:1420 访问
hmr: host host: true,
? { protocol: "ws", host, port: 1421 }
: undefined,
watch: { watch: {
ignored: ["**/src-tauri/**"], ignored: ["**/src-tauri/**"],
}, },
// 开发时代理 API 请求到 Python/Rust 后端 // 开发时代理 API 请求到 Rust 后端
proxy: { proxy: {
'/api': 'http://localhost:8000', '/api': 'http://localhost:10801',
'/file': 'http://localhost:8000', '/file': 'http://localhost:10801',
'/media': 'http://localhost:8000', '/media': 'http://localhost:10801',
'/upload': 'http://localhost:8000', '/upload': 'http://localhost:10801',
}, },
}, },
})); }));