feat(server): 集成静态文件服务并优化开发环境配置
- 添加 koa-static 中间件以支持静态资源访问 - 更新 package.json 引入 nodemon 用于服务热重载- 调整项目结构,将前端代码移至 module/web 目录下 - 修改图片引用路径适配新目录结构 - 更新主入口文件引入路由模块的方式- 配置 Vite 构建工具替换原有构建方式- 移除 Turbo依赖并使用 concurrently 管理多进程开发任务- 更新根目录 package.json 的脚本命令指向新的开发启动逻辑
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import Koa from 'koa';
|
import Koa from 'koa';
|
||||||
import Router from 'koa-router';
|
import Router from 'koa-router';
|
||||||
import config from "./config/index.js"
|
import config from "./config/index.js"
|
||||||
|
import koaStatic from 'koa-static';
|
||||||
|
|
||||||
const app = new Koa();
|
const app = new Koa();
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
@@ -19,9 +20,10 @@ router.get('/api/config', (ctx) => {
|
|||||||
})
|
})
|
||||||
app.use(router.routes());
|
app.use(router.routes());
|
||||||
app.use(router.allowedMethods());
|
app.use(router.allowedMethods());
|
||||||
|
app.use(koaStatic('/www'))
|
||||||
|
|
||||||
const PORT = process.env.PORT || 3001;
|
const PORT = process.env.PORT || 3001;
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log(`Koa server is running on port ${PORT}`);
|
console.log(`Koa server is running on port ${PORT}`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node index.js",
|
"start": "node index.js",
|
||||||
"dev": "node index.js"
|
"dev": "nodemon index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"koa": "^2.15.0",
|
"koa": "^2.15.0",
|
||||||
"koa-router": "^12.0.0"
|
"koa-router": "^12.0.0",
|
||||||
|
"koa-static": "^5.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body oncontextmenu="return false" ondragstart="return false">
|
<body oncontextmenu="return false" ondragstart="return false">
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.js"></script>
|
<script type="module" src="/module/web/src/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,8 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "web",
|
"name": "chuanqi-web",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"version": "0.0.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "cd ../.. && pnpm dev",
|
"dev": "vite",
|
||||||
"build": "cd ../.. && pnpm build"
|
"build": "vite build",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^1.12.2",
|
||||||
|
"vue": "^3.5.21",
|
||||||
|
"vue-router": "^4.5.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
|
"vite": "^7.1.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,18 +73,6 @@ $directions: (
|
|||||||
.w50v{width: 50vw!important;}
|
.w50v{width: 50vw!important;}
|
||||||
.h50v{height: 50vh!important;}
|
.h50v{height: 50vh!important;}
|
||||||
|
|
||||||
.no-devices{
|
|
||||||
background-image: url("../assets/no-devices.png");
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: 50% 38.2%; /* 纵轴38.2% */
|
|
||||||
background-size: auto 40%;
|
|
||||||
text-align: center;
|
|
||||||
color: #888;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center; /* 水平居中 */
|
|
||||||
padding-top: calc( 45% + 16px);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Chrome, Edge, Safari, Opera */
|
/* Chrome, Edge, Safari, Opera */
|
||||||
input[type="number"]::-webkit-inner-spin-button,
|
input[type="number"]::-webkit-inner-spin-button,
|
||||||
input[type="number"]::-webkit-outer-spin-button {
|
input[type="number"]::-webkit-outer-spin-button {
|
||||||
|
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 496 B |
@@ -1,7 +1,7 @@
|
|||||||
import {createApp} from 'vue'
|
import {createApp} from 'vue'
|
||||||
import './style.css'
|
import './style.css'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import router from './router'
|
import router from './router/index.js'
|
||||||
|
|
||||||
// window.external?.OpenGameWindowNew(window.location.href, '', '', '', false);
|
// window.external?.OpenGameWindowNew(window.location.href, '', '', '', false);
|
||||||
document.onkeydown = document.onkeyup = document.onkeypress = function (e) {
|
document.onkeydown = document.onkeyup = document.onkeypress = function (e) {
|
||||||
@@ -31,7 +31,7 @@ function handleLogin() {
|
|||||||
<a id="submitButton" class="button fit" @click="handleLogin">登 录</a>
|
<a id="submitButton" class="button fit" @click="handleLogin">登 录</a>
|
||||||
<div style="display:flex;justify-content:center;gap:8px;font-size:12px">
|
<div style="display:flex;justify-content:center;gap:8px;font-size:12px">
|
||||||
<div style="display:flex;align-items:center;flex-direction:column;gap:4px;cursor:pointer" id="linuxdoConnect">
|
<div style="display:flex;align-items:center;flex-direction:column;gap:4px;cursor:pointer" id="linuxdoConnect">
|
||||||
<img src="/static/img/linuxdo_logo.png" style="width:60px;height:60px" alt="Linux.Do登录"/>
|
<img src="/img/linuxdo_logo.png" style="width:60px;height:60px" alt="Linux.Do登录"/>
|
||||||
<div>Linux.do</div>
|
<div>Linux.do</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -46,7 +46,7 @@ function handleLogin() {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.gamebg {
|
.gamebg {
|
||||||
background-image: url("/static/img/login_bg.jpg");
|
background-image: url("/img/login_bg.jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
36
package.json
36
package.json
@@ -1,30 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "chuanqi-web",
|
"name": "chuanqi-qycq-web",
|
||||||
"private": true,
|
"version": "1.0.0",
|
||||||
"version": "0.0.0",
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "node scripts/dev.js",
|
||||||
"dev:server": "pnpm --filter chuanqi-server dev",
|
"build": "pnpm -r run build"
|
||||||
"start:server": "pnpm --filter chuanqi-server start",
|
|
||||||
"build": "vite build",
|
|
||||||
"preview": "vite preview",
|
|
||||||
"turbo": "turbo run dev"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"axios": "^1.12.2",
|
|
||||||
"vue": "^3.5.21",
|
|
||||||
"vue-router": "^4.5.1"
|
|
||||||
},
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "Kubbo",
|
||||||
|
"license": "ISC",
|
||||||
|
"packageManager": "pnpm@10.18.2",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"concurrently": "^9.2.1"
|
||||||
"turbo": "^2.5.8",
|
}
|
||||||
"vite": "^7.1.7"
|
|
||||||
},
|
|
||||||
"pnpm": {
|
|
||||||
"workspace": [
|
|
||||||
"server"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"packageManager": "pnpm@10.18.2"
|
|
||||||
}
|
}
|
||||||
|
|||||||
6
scripts/dev.js
Normal file
6
scripts/dev.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import concurrently from 'concurrently';
|
||||||
|
const scope = [
|
||||||
|
{"name": "WEB", "command": "pnpm --filter ./module/web dev"},
|
||||||
|
{"name": "HTTP", "command": "pnpm --filter ./module/server dev"}
|
||||||
|
]
|
||||||
|
concurrently(scope, {"prefix": "[{name}]", "killOthers": ["failure", "success"], prefixColors: 'auto'})
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
{
|
|
||||||
"$schema": "https://turbo.build/schema.json",
|
|
||||||
"tasks": {
|
|
||||||
"dev": {
|
|
||||||
"cache": false,
|
|
||||||
"persistent": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user