mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: webui Login Router
This commit is contained in:
parent
9471e63857
commit
54ab1dc091
@ -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`);
|
||||
})
|
||||
|
8
src/webui/src/api/Auth.ts
Normal file
8
src/webui/src/api/Auth.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
export const LoginHandler: RequestHandler = (req, res) => {
|
||||
|
||||
};
|
||||
export const LogoutHandler: RequestHandler = (req, res) => {
|
||||
|
||||
};
|
@ -1 +1,5 @@
|
||||
//获取日志
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
export const GetLogHandler: RequestHandler = (req, res) => {
|
||||
|
||||
};
|
||||
|
@ -1 +0,0 @@
|
||||
//待实现
|
@ -1,10 +1,8 @@
|
||||
//实现一个登录 仅需判断密码 没有用户名字段
|
||||
export class Auth {
|
||||
public static async checkAuth(token: string) {
|
||||
if (token == "123456") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
}
|
||||
export const GetQRcodeHandler: RequestHandler = (req, res) => {
|
||||
|
||||
};
|
||||
export const CheckLoginStatusHandler: RequestHandler = (req, res) => {
|
||||
|
||||
};
|
@ -1 +0,0 @@
|
||||
//待实现
|
@ -1 +1,8 @@
|
||||
// 挂载面板路由
|
||||
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 };
|
6
src/webui/src/router/index.ts
Normal file
6
src/webui/src/router/index.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { Router } from "express";
|
||||
import { AuthRouter } from "./api";
|
||||
const router = Router();
|
||||
router.use('/auth', AuthRouter);//挂载权限路由
|
||||
|
||||
export { router as APIRouter }
|
Loading…
x
Reference in New Issue
Block a user