feat(web):重构前端路由和配置管理
- 移除旧版全局变量定义,采用Vue Router管理页面跳转 - 新增配置文件统一管理游戏名称和注册码设置 -优化加载条逻辑,使用onMounted确保DOM元素正确获取 - 添加服务端配置接口,动态加载游戏配置信息 - 升级依赖包,引入vue-router支持单页应用 - 调整项目结构,分离服务器端代码至独立目录 - 配置Vite代理转发API请求到本地开发服务器 - 更新package.json脚本命令,支持前后端联合调试 - 引入pnpm workspace管理模式,提升多包协作效率
This commit is contained in:
27
server/index.js
Normal file
27
server/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import Koa from 'koa';
|
||||
import Router from 'koa-router';
|
||||
import config from "./config/index.js"
|
||||
|
||||
const app = new Koa();
|
||||
const router = new Router();
|
||||
|
||||
// 简单的路由示例
|
||||
router.get('/', (ctx) => {
|
||||
ctx.body = {message: 'Hello from Koa server!'};
|
||||
});
|
||||
|
||||
router.get('/api/test', (ctx) => {
|
||||
ctx.body = {message: 'This is a test API endpoint'};
|
||||
});
|
||||
|
||||
router.get('/api/config', (ctx) => {
|
||||
ctx.body = {data: config}
|
||||
})
|
||||
app.use(router.routes());
|
||||
app.use(router.allowedMethods());
|
||||
|
||||
const PORT = process.env.PORT || 3001;
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Koa server is running on port ${PORT}`);
|
||||
});
|
||||
Reference in New Issue
Block a user