diff --git a/src/webui/index.ts b/src/webui/index.ts index ccce84ea..0720b479 100644 --- a/src/webui/index.ts +++ b/src/webui/index.ts @@ -1,5 +1,6 @@ import express from 'express'; import { resolve } from 'node:path'; +import { APIRouter } from './src/router'; const app = express(); /** * 初始化并启动WebUI服务。 @@ -9,8 +10,16 @@ const app = express(); */ export async function InitWebUi() { app.use(express.json()); + // 初始服务 + app.all('/', (_req, res) => { + res.json({ + msg: 'NapCat WebAPI is now running!', + }); + }); // 配置静态文件服务,提供./static目录下的文件服务,访问路径为/webui app.use('/webui', express.static(resolve(__dirname, './static'))); + //挂载API接口 + app.all('/api', APIRouter); app.listen(6099, async () => { //console.log(`WebUi is running at IP:6099`); }) diff --git a/src/webui/src/api/Auth.ts b/src/webui/src/api/Auth.ts new file mode 100644 index 00000000..bd65e365 --- /dev/null +++ b/src/webui/src/api/Auth.ts @@ -0,0 +1,8 @@ +import { RequestHandler } from "express"; + +export const LoginHandler: RequestHandler = (req, res) => { + +}; +export const LogoutHandler: RequestHandler = (req, res) => { + +}; diff --git a/src/webui/src/api/LogConsole.ts b/src/webui/src/api/LogConsole.ts index 6dbfe325..9cf3044e 100644 --- a/src/webui/src/api/LogConsole.ts +++ b/src/webui/src/api/LogConsole.ts @@ -1 +1,5 @@ -//获取日志 \ No newline at end of file +import { RequestHandler } from "express"; + +export const GetLogHandler: RequestHandler = (req, res) => { + +}; diff --git a/src/webui/src/api/Login.ts b/src/webui/src/api/Login.ts deleted file mode 100644 index 09d171f2..00000000 --- a/src/webui/src/api/Login.ts +++ /dev/null @@ -1 +0,0 @@ -//待实现 \ No newline at end of file diff --git a/src/webui/src/api/QQLogin.ts b/src/webui/src/api/QQLogin.ts index 119ce3b9..6ad72d5f 100644 --- a/src/webui/src/api/QQLogin.ts +++ b/src/webui/src/api/QQLogin.ts @@ -1,10 +1,8 @@ -//实现一个登录 仅需判断密码 没有用户名字段 -export class Auth { - public static async checkAuth(token: string) { - if (token == "123456") { - return true; - } - return false; - } +import { RequestHandler } from "express"; -} \ No newline at end of file +export const GetQRcodeHandler: RequestHandler = (req, res) => { + +}; +export const CheckLoginStatusHandler: RequestHandler = (req, res) => { + +}; \ No newline at end of file diff --git a/src/webui/src/api/index.ts b/src/webui/src/api/index.ts deleted file mode 100644 index 09d171f2..00000000 --- a/src/webui/src/api/index.ts +++ /dev/null @@ -1 +0,0 @@ -//待实现 \ No newline at end of file diff --git a/src/webui/src/router/api.ts b/src/webui/src/router/api.ts index 43d57511..f1e1f1b1 100644 --- a/src/webui/src/router/api.ts +++ b/src/webui/src/router/api.ts @@ -1 +1,8 @@ -// 挂载面板路由 \ No newline at end of file +import { Router } from 'express'; +import { LoginHandler, LogoutHandler } from '../api/Auth'; + +const router = Router(); + +router.post('/login', LoginHandler); +router.post('/logout', LogoutHandler); +export { router as AuthRouter }; \ No newline at end of file diff --git a/src/webui/src/router/index.ts b/src/webui/src/router/index.ts new file mode 100644 index 00000000..e38e0b40 --- /dev/null +++ b/src/webui/src/router/index.ts @@ -0,0 +1,6 @@ +import { Router } from "express"; +import { AuthRouter } from "./api"; +const router = Router(); +router.use('/auth', AuthRouter);//挂载权限路由 + +export { router as APIRouter } \ No newline at end of file