Compare commits
5 Commits
catten-fro
...
catten-bac
Author | SHA1 | Date |
---|---|---|
|
490ec064a0 | 8 months ago |
|
21dd1911c4 | 8 months ago |
|
a277b698d4 | 8 months ago |
|
bf5b813c33 | 8 months ago |
|
2e7c6363fc | 8 months ago |
@ -0,0 +1,5 @@
|
|||||||
|
DB_NAME = "restaurant"
|
||||||
|
DB_USER = "root"
|
||||||
|
DB_PASSWORD = "123456"
|
||||||
|
DB_HOST = "localhost"
|
||||||
|
JWT_SECRET = "PJH"
|
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
|
|
||||||
}
|
|
@ -0,0 +1,59 @@
|
|||||||
|
var createError = require('http-errors');
|
||||||
|
var express = require('express');
|
||||||
|
var path = require('path');
|
||||||
|
var cookieParser = require('cookie-parser');
|
||||||
|
var logger = require('morgan');
|
||||||
|
const cors = require('cors');
|
||||||
|
|
||||||
|
//优先读取环境变量
|
||||||
|
require("dotenv").config()
|
||||||
|
|
||||||
|
//引入数据库连接
|
||||||
|
require("./dao/db")
|
||||||
|
|
||||||
|
//引入路由
|
||||||
|
const userRouter = require('./routes/user');
|
||||||
|
const inventoryRouter = require("./routes/inventory")
|
||||||
|
const orderRouter = require("./routes/order")
|
||||||
|
|
||||||
|
var app = express();
|
||||||
|
|
||||||
|
//配置cors
|
||||||
|
const corsOptions = {
|
||||||
|
allowedHeaders: ['Content-Type', 'Authorization'],
|
||||||
|
exposedHeaders: ['Authentication', 'X-Custom-Header'],
|
||||||
|
credentials: true,
|
||||||
|
}
|
||||||
|
//为所有源跨域
|
||||||
|
app.use(cors(corsOptions))
|
||||||
|
//使用各种中间件
|
||||||
|
app.use(logger('dev'));
|
||||||
|
app.use(express.json());
|
||||||
|
app.use(express.urlencoded({
|
||||||
|
extended: false
|
||||||
|
}));
|
||||||
|
app.use(cookieParser());
|
||||||
|
app.use(express.static(path.join(__dirname, 'public')));
|
||||||
|
|
||||||
|
//使用路由中间件
|
||||||
|
app.use('/user', userRouter);
|
||||||
|
app.use("/inventory", inventoryRouter)
|
||||||
|
app.use("/order", orderRouter)
|
||||||
|
|
||||||
|
// catch 404 and forward to error handler
|
||||||
|
app.use(function (req, res, next) {
|
||||||
|
next(createError(404));
|
||||||
|
});
|
||||||
|
|
||||||
|
// 错误捕获
|
||||||
|
app.use(function (err, req, res, next) {
|
||||||
|
// set locals, only providing error in development
|
||||||
|
res.locals.message = err.message;
|
||||||
|
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
||||||
|
|
||||||
|
// render the error page
|
||||||
|
res.status(err.status || 500);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = app;
|
@ -0,0 +1,91 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var app = require('../app');
|
||||||
|
var debug = require('debug')('backend:server');
|
||||||
|
var http = require('http');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get port from environment and store in Express.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var port = normalizePort(process.env.PORT || '3000');
|
||||||
|
app.set('port', port);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create HTTP server.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var server = http.createServer(app);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listen on provided port, on all network interfaces.
|
||||||
|
*/
|
||||||
|
|
||||||
|
server.listen(port);
|
||||||
|
server.on('error', onError);
|
||||||
|
server.on('listening', onListening);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize a port into a number, string, or false.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function normalizePort(val) {
|
||||||
|
var port = parseInt(val, 10);
|
||||||
|
|
||||||
|
if (isNaN(port)) {
|
||||||
|
// named pipe
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (port >= 0) {
|
||||||
|
// port number
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event listener for HTTP server "error" event.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function onError(error) {
|
||||||
|
if (error.syscall !== 'listen') {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bind = typeof port === 'string' ?
|
||||||
|
'Pipe ' + port :
|
||||||
|
'Port ' + port;
|
||||||
|
|
||||||
|
// handle specific listen errors with friendly messages
|
||||||
|
switch (error.code) {
|
||||||
|
case 'EACCES':
|
||||||
|
console.error(bind + ' requires elevated privileges');
|
||||||
|
process.exit(1);
|
||||||
|
break;
|
||||||
|
case 'EADDRINUSE':
|
||||||
|
console.error(bind + ' is already in use');
|
||||||
|
process.exit(1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event listener for HTTP server "listening" event.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function onListening() {
|
||||||
|
var addr = server.address();
|
||||||
|
var bind = typeof addr === 'string' ?
|
||||||
|
'pipe ' + addr :
|
||||||
|
'port ' + addr.port;
|
||||||
|
debug('Listening on ' + bind);
|
||||||
|
console.log("监听3000端口")
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
const sequelize = require("./dbConnect")
|
||||||
|
const userModel = require("./model/userModel")
|
||||||
|
const inventoryModel = require("./model/inventoryModel")
|
||||||
|
const md5 = require("md5")
|
||||||
|
|
||||||
|
const adminName = "root"
|
||||||
|
const adminPwd = "123456"
|
||||||
|
//将数据模型和表进行同步
|
||||||
|
async function test() {
|
||||||
|
await sequelize.sync({
|
||||||
|
alter: true
|
||||||
|
})
|
||||||
|
|
||||||
|
//将需要数据的表初始化
|
||||||
|
const userCount = await userModel.count()
|
||||||
|
if (!userCount) {
|
||||||
|
//需要初始化
|
||||||
|
await userModel.create({
|
||||||
|
username: adminName,
|
||||||
|
password: md5(adminPwd),
|
||||||
|
isAdmin: true
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log("用户数据初始化完毕")
|
||||||
|
}
|
||||||
|
|
||||||
|
const inventoryCount = await inventoryModel.count()
|
||||||
|
if (!inventoryCount) {
|
||||||
|
//需要初始化
|
||||||
|
await inventoryModel.bulkCreate([{
|
||||||
|
"dishName": "茶叶蛋",
|
||||||
|
"quantity": 25,
|
||||||
|
"price": 1,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dishName": "豆浆",
|
||||||
|
"quantity": 15,
|
||||||
|
"price": 2,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dishName": "油条",
|
||||||
|
"quantity": 20,
|
||||||
|
"price": 1.5,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dishName": "煎饼",
|
||||||
|
"quantity": 18,
|
||||||
|
"price": 4,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dishName": "火腿肠",
|
||||||
|
"quantity": 30,
|
||||||
|
"price": 1.5,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dishName": "豆沙包",
|
||||||
|
"quantity": 50,
|
||||||
|
"price": 2,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dishName": "肉包",
|
||||||
|
"quantity": 50,
|
||||||
|
"price": 2,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dishName": "馒头",
|
||||||
|
"quantity": 100,
|
||||||
|
"price": 1,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"dishName": "牛奶",
|
||||||
|
"quantity": 20,
|
||||||
|
"price": 3,
|
||||||
|
"description": null,
|
||||||
|
"imageUrl": null
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
console.log("库存数据初始化完毕")
|
||||||
|
}
|
||||||
|
|
||||||
|
// const expressCount = await expressModel.count()
|
||||||
|
|
||||||
|
|
||||||
|
console.log("数据库数据准备完成")
|
||||||
|
}
|
||||||
|
test()
|
@ -0,0 +1,12 @@
|
|||||||
|
const {
|
||||||
|
Sequelize
|
||||||
|
} = require("sequelize")
|
||||||
|
|
||||||
|
const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, process.env.DB_PASSWORD, {
|
||||||
|
host: process.env.DB_HOST,
|
||||||
|
dialect: "mysql",
|
||||||
|
logging: false
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = sequelize
|
@ -0,0 +1,34 @@
|
|||||||
|
const orderModel = require("./model/orderModel")
|
||||||
|
module.exports.getOrderDao = async function (id) {
|
||||||
|
if (id) {
|
||||||
|
console.log(id, "idDAO")
|
||||||
|
return await orderModel.findAll({
|
||||||
|
where: {
|
||||||
|
userId: id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return await orderModel.findAll()
|
||||||
|
}
|
||||||
|
module.exports.addOrderDao = async function (dishData) {
|
||||||
|
await orderModel.create(dishData)
|
||||||
|
return await orderModel.findAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
// module.exports.updateOrderDao = async function (dishData) {
|
||||||
|
// await orderModel.update(dishData, {
|
||||||
|
// where: {
|
||||||
|
// id: dishData.id
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// return await orderModel.findAll()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// module.exports.deleteOrderDao = async function (id) {
|
||||||
|
// await orderModel.destroy({
|
||||||
|
// where: {
|
||||||
|
// id
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// return await orderModel.findAll()
|
||||||
|
// }
|
@ -1,13 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Vite + Vue</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="app"></div>
|
|
||||||
<script type="module" src="/src/main.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -0,0 +1,35 @@
|
|||||||
|
const sequelize = require("../dbConnect")
|
||||||
|
const {
|
||||||
|
DataTypes
|
||||||
|
} = require("sequelize")
|
||||||
|
|
||||||
|
module.exports = sequelize.define("order", {
|
||||||
|
userId: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
orderDate: {
|
||||||
|
type: DataTypes.DATEONLY,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
dishName: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
quantity: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
totalAmount: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
freezeTableName: true,
|
||||||
|
createdAt: false,
|
||||||
|
updatedAt: false,
|
||||||
|
})
|
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,23 @@
|
|||||||
{
|
{
|
||||||
"name": "vite-project",
|
"name": "backend",
|
||||||
"private": true,
|
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"start": "nodemon -x npm run server",
|
||||||
"build": "vite build",
|
"server": "node ./bin/www"
|
||||||
"preview": "vite preview"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.7.9",
|
"cookie-parser": "~1.4.4",
|
||||||
"element-plus": "^2.9.1",
|
"cors": "^2.8.5",
|
||||||
"pinia": "^2.3.0",
|
"debug": "~2.6.9",
|
||||||
"vue": "^3.2.45"
|
"dotenv": "^16.4.5",
|
||||||
},
|
"express": "~4.16.1",
|
||||||
"devDependencies": {
|
"http-errors": "~1.6.3",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"jade": "~1.11.0",
|
||||||
"vite": "^4.1.0"
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
"md5": "^2.3.0",
|
||||||
|
"morgan": "~1.9.1",
|
||||||
|
"mysql2": "^3.11.4",
|
||||||
|
"sequelize": "^6.37.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
body {
|
||||||
|
padding: 50px;
|
||||||
|
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #00B7FF;
|
||||||
|
}
|
Before Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,40 @@
|
|||||||
|
const express = require("express")
|
||||||
|
const router = express.Router()
|
||||||
|
const {
|
||||||
|
getOrderServices,
|
||||||
|
addOrderServices,
|
||||||
|
updateOrderServices,
|
||||||
|
deleteOrderServices
|
||||||
|
} = require("../services/orderService")
|
||||||
|
|
||||||
|
const {
|
||||||
|
formatResponse
|
||||||
|
} = require("../utils/tools")
|
||||||
|
|
||||||
|
router.get("/", async function (req, res, next) {
|
||||||
|
const data = await getOrderServices()
|
||||||
|
res.send(formatResponse(0, "", data))
|
||||||
|
})
|
||||||
|
|
||||||
|
router.get("/:userId", async function (req, res, next) {
|
||||||
|
console.log("getID2", req.params.userId)
|
||||||
|
const data = await getOrderServices(req.params.userId)
|
||||||
|
res.send(formatResponse(0, "", data))
|
||||||
|
})
|
||||||
|
|
||||||
|
router.post("/", async function (req, res, next) {
|
||||||
|
const data = await addOrderServices(req.body)
|
||||||
|
res.send(formatResponse(0, "", data))
|
||||||
|
})
|
||||||
|
|
||||||
|
// router.put("/", async function (req, res, next) {
|
||||||
|
// const data = await updateOrderServices(req.body)
|
||||||
|
// res.send(formatResponse(0, "", data))
|
||||||
|
// })
|
||||||
|
|
||||||
|
// router.delete("/", async function (req, res, next) {
|
||||||
|
// const data = await deleteOrderServices(req.body)
|
||||||
|
// res.send(formatResponse(0, "", data))
|
||||||
|
// })
|
||||||
|
|
||||||
|
module.exports = router
|
@ -0,0 +1,28 @@
|
|||||||
|
const {
|
||||||
|
getOrderDao,
|
||||||
|
addOrderDao,
|
||||||
|
updateOrderDao,
|
||||||
|
deleteOrderDao
|
||||||
|
} = require("../dao/orderDao")
|
||||||
|
|
||||||
|
module.exports.getOrderServices = async function (id) {
|
||||||
|
|
||||||
|
return await getOrderDao(id)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.addOrderServices = async function (dishData) {
|
||||||
|
return await addOrderDao(dishData)
|
||||||
|
}
|
||||||
|
|
||||||
|
// module.exports.updateOrderServices = async function (expData) {
|
||||||
|
// //这里需要提供id
|
||||||
|
// return await updateOrderDao(expData)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// module.exports.deleteOrderServices = async function ({
|
||||||
|
// id
|
||||||
|
// }) {
|
||||||
|
// return await deleteOrderDao(
|
||||||
|
// id
|
||||||
|
// )
|
||||||
|
// }
|
@ -1,7 +0,0 @@
|
|||||||
<script setup>
|
|
||||||
import Inventory from './components/Inventory.vue'
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Inventory msg="Vite + Vue" />
|
|
||||||
</template>
|
|
Before Width: | Height: | Size: 496 B |
@ -1,48 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div id="inventoryContainer">
|
|
||||||
<h2>食品管理表</h2>
|
|
||||||
<el-table :data="inventoryStore.inventoryListGetter" border style="width: 100%; height: 100%;">
|
|
||||||
<el-table-column prop="id" label="序号" width="200" />
|
|
||||||
<el-table-column prop="dishName" label="食品名称" width="300" />
|
|
||||||
|
|
||||||
<el-table-column prop="price" label="价格">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input v-model="scope.row.price" style="width: 80px;"></el-input> 元
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="quantity" label="库存">
|
|
||||||
<template #default="scope">
|
|
||||||
剩余 <el-input v-model="scope.row.quantity" style="width: 80px;"></el-input>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
|
|
||||||
<el-table-column prop="quantity" label="确认修改" width="120">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button type="primary" @click="inventoryStore.updateInventoryList(scope.row)">确认修改</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { onBeforeMount, } from "vue"
|
|
||||||
import { useInventoryStore } from "../store/inventoryStore"
|
|
||||||
const inventoryStore = useInventoryStore()
|
|
||||||
onBeforeMount(async () => {
|
|
||||||
await inventoryStore.getInventoryList()
|
|
||||||
})
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
#inventoryContainer {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: start;
|
|
||||||
width: 90vw;
|
|
||||||
}
|
|
||||||
</style>
|
|
@ -1,12 +0,0 @@
|
|||||||
import {
|
|
||||||
createApp
|
|
||||||
} from 'vue'
|
|
||||||
import './style.css'
|
|
||||||
import App from './App.vue'
|
|
||||||
import ElementPlus from 'element-plus'
|
|
||||||
import 'element-plus/dist/index.css'
|
|
||||||
import {
|
|
||||||
createPinia
|
|
||||||
} from 'pinia'
|
|
||||||
const pinia = createPinia()
|
|
||||||
createApp(App).use(pinia).use(ElementPlus).mount('#app')
|
|
@ -1,61 +0,0 @@
|
|||||||
import {
|
|
||||||
defineStore
|
|
||||||
} from 'pinia';
|
|
||||||
import req from "../request"
|
|
||||||
import {
|
|
||||||
ElMessage
|
|
||||||
} from 'element-plus'
|
|
||||||
|
|
||||||
export const useInventoryStore = defineStore('inventoryStore', {
|
|
||||||
state: () => ({
|
|
||||||
inventoryList: [],
|
|
||||||
}),
|
|
||||||
getters: {
|
|
||||||
inventoryListGetter() {
|
|
||||||
return this.inventoryList
|
|
||||||
}
|
|
||||||
},
|
|
||||||
actions: {
|
|
||||||
getInventoryList() {
|
|
||||||
req({
|
|
||||||
method: "get",
|
|
||||||
url: "/inventory",
|
|
||||||
}).then(({
|
|
||||||
data
|
|
||||||
}) => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.setInventoryList(data.data)
|
|
||||||
ElMessage({
|
|
||||||
message: "获取成功",
|
|
||||||
type: "success"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
},
|
|
||||||
setInventoryList(data) {
|
|
||||||
this.inventoryList = data;
|
|
||||||
console.log(this.inventoryList, "inventoryStoreData")
|
|
||||||
},
|
|
||||||
updateInventoryList(data) {
|
|
||||||
req({
|
|
||||||
method: "put",
|
|
||||||
url: "/inventory",
|
|
||||||
data,
|
|
||||||
}).then(({
|
|
||||||
data
|
|
||||||
}) => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.setInventoryList(data.data, "changedInventory")
|
|
||||||
ElMessage({
|
|
||||||
message: "修改成功",
|
|
||||||
type: "success"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,95 +0,0 @@
|
|||||||
:root {
|
|
||||||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
||||||
line-height: 1.5;
|
|
||||||
font-weight: 400;
|
|
||||||
|
|
||||||
color-scheme: light dark;
|
|
||||||
color: rgba(255, 255, 255, 0.87);
|
|
||||||
background-color: #242424;
|
|
||||||
|
|
||||||
font-synthesis: none;
|
|
||||||
text-rendering: optimizeLegibility;
|
|
||||||
-webkit-font-smoothing: antialiased;
|
|
||||||
-moz-osx-font-smoothing: grayscale;
|
|
||||||
/* -webkit-text-size-adjust: 100%; */
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
font-weight: 500;
|
|
||||||
color: #646cff;
|
|
||||||
text-decoration: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
color: #535bf2;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
font-weight: 500;
|
|
||||||
color: #646cff;
|
|
||||||
text-decoration: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
color: #535bf2;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
display: flex;
|
|
||||||
place-items: center;
|
|
||||||
min-width: 320px;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
font-size: 3.2em;
|
|
||||||
line-height: 1.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
border-radius: 8px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
padding: 0.6em 1.2em;
|
|
||||||
font-size: 1em;
|
|
||||||
font-weight: 500;
|
|
||||||
font-family: inherit;
|
|
||||||
background-color: #1a1a1a;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: border-color 0.25s;
|
|
||||||
}
|
|
||||||
|
|
||||||
button:hover {
|
|
||||||
border-color: #646cff;
|
|
||||||
}
|
|
||||||
|
|
||||||
button:focus,
|
|
||||||
button:focus-visible {
|
|
||||||
outline: 4px auto -webkit-focus-ring-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
padding: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#app {
|
|
||||||
max-width: 1280px;
|
|
||||||
margin: 0 auto;
|
|
||||||
padding: 2rem;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: light) {
|
|
||||||
:root {
|
|
||||||
color: #213547;
|
|
||||||
background-color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
|
||||||
color: #747bff;
|
|
||||||
}
|
|
||||||
|
|
||||||
button {
|
|
||||||
background-color: #f9f9f9;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,37 @@
|
|||||||
|
const jwt = require("jsonwebtoken")
|
||||||
|
const md5 = require("md5")
|
||||||
|
|
||||||
|
module.exports.formatResponse = function (code, msg, data) {
|
||||||
|
return {
|
||||||
|
code,
|
||||||
|
msg,
|
||||||
|
data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.analysisToken = function (token) {
|
||||||
|
return jwt.verify(token.split(" ")[1], md5(process.env.JWT_SECRET))
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.getJwtToken = function (payload) {
|
||||||
|
let loginPeriod = 1; //默认记住一天
|
||||||
|
return jwt.sign(payload, md5(process.env.JWT_SECRET), {
|
||||||
|
expiresIn: 60 * 60 * 24 * loginPeriod
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.getRandomExpressId = function () {
|
||||||
|
return "SF" + Math.floor(Math.random() * 1000000000000)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.handleArrayDaoData = function (arr) {
|
||||||
|
const result = []
|
||||||
|
// for (const item of arr) {
|
||||||
|
// result.push(item.dataValues)
|
||||||
|
// }
|
||||||
|
//倒叙输出
|
||||||
|
for (let i = arr.length - 1; i >= 0; i--) {
|
||||||
|
result.push(arr[i].dataValues)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
@ -1,7 +0,0 @@
|
|||||||
import { defineConfig } from 'vite'
|
|
||||||
import vue from '@vitejs/plugin-vue'
|
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [vue()],
|
|
||||||
})
|
|
Loading…
Reference in new issue