generated from template/vite-react-template
docs: 文档添加
This commit is contained in:
parent
f8876964b9
commit
4b4e596b0c
@ -17,7 +17,7 @@
|
||||
"build": "rimraf dist && bun run bun.config.mjs",
|
||||
"test": "tsx test/**/*.ts",
|
||||
"clean": "rm -rf dist",
|
||||
"pub": "npm run build && envision pack -p -u",
|
||||
"pub": "envision pack -p -u",
|
||||
"cmd": "tsx cmd/index.ts "
|
||||
},
|
||||
"keywords": [],
|
||||
|
@ -1 +1,14 @@
|
||||
import { proxyRoute, initProxy } from '@kevisual/local-proxy/proxy.ts';
|
||||
initProxy({
|
||||
pagesDir: './pages',
|
||||
watch: true,
|
||||
home: '/root/tickets',
|
||||
});
|
||||
import { app } from './app.ts';
|
||||
import './index.ts';
|
||||
|
||||
app.listen(3004, () => {
|
||||
console.log('Server is running on http://localhost:3004');
|
||||
});
|
||||
|
||||
app.onServerRequest(proxyRoute);
|
||||
|
@ -1,15 +1,2 @@
|
||||
import { proxyRoute, initProxy } from '@kevisual/local-proxy/proxy.ts';
|
||||
initProxy({
|
||||
pagesDir: './pages',
|
||||
watch: true,
|
||||
home: '/root/tickets',
|
||||
});
|
||||
import { app } from './app.ts';
|
||||
|
||||
import './app.ts';
|
||||
import './routes/ticket/list.ts';
|
||||
|
||||
app.listen(3004, () => {
|
||||
console.log('Server is running on http://localhost:3004');
|
||||
});
|
||||
|
||||
app.onServerRequest(proxyRoute);
|
||||
|
@ -23,29 +23,15 @@ app
|
||||
key: 'list',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
const searchForm = ctx.query?.data || {} as SearchTicketsParams;
|
||||
const {
|
||||
current = 1,
|
||||
pageSize = 10,
|
||||
search,
|
||||
status,
|
||||
type,
|
||||
sort = 'createdAt',
|
||||
order = 'desc',
|
||||
uid,
|
||||
startDate,
|
||||
endDate
|
||||
} = searchForm;
|
||||
const searchForm = ctx.query?.data || ({} as SearchTicketsParams);
|
||||
const { current = 1, pageSize = 10, search, status, type, sort = 'createdAt', order = 'desc', uid, startDate, endDate } = searchForm;
|
||||
|
||||
// 构建查询条件
|
||||
let where: any = {};
|
||||
|
||||
// 如果提供了搜索关键词,同时搜索标题和描述
|
||||
if (search) {
|
||||
where[Op.or] = [
|
||||
{ title: { [Op.like]: `%${search}%` } },
|
||||
{ description: { [Op.like]: `%${search}%` } }
|
||||
];
|
||||
where[Op.or] = [{ title: { [Op.like]: `%${search}%` } }, { description: { [Op.like]: `%${search}%` } }];
|
||||
}
|
||||
|
||||
// 添加其他过滤条件
|
||||
@ -93,14 +79,24 @@ app
|
||||
.define(async (ctx) => {
|
||||
const data = ctx.query?.data || {};
|
||||
const { id, ...updateData } = data;
|
||||
if (!id) {
|
||||
ctx.throw(400, 'ID is required for update');
|
||||
|
||||
let ticket: TicketModel;
|
||||
let isNew = false;
|
||||
if (id) {
|
||||
ticket = await TicketModel.findByPk(id);
|
||||
if (!ticket) {
|
||||
ctx.throw(404, 'Ticket not found');
|
||||
}
|
||||
} else {
|
||||
isNew = true;
|
||||
ticket = await TicketModel.create({ ...updateData });
|
||||
}
|
||||
const ticket = await TicketModel.findByPk(id);
|
||||
if (!ticket) {
|
||||
ctx.throw(404, 'Ticket not found');
|
||||
}
|
||||
await ticket.update(updateData);
|
||||
if (!isNew) {
|
||||
await ticket.update(updateData);
|
||||
}
|
||||
ctx.body = ticket;
|
||||
})
|
||||
.addTo(app);
|
||||
|
@ -39,10 +39,12 @@ TicketModel.init(
|
||||
type: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
defaultValue: 'rule',
|
||||
},
|
||||
title: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
defaultValue: '未命名票据',
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
@ -56,10 +58,11 @@ TicketModel.init(
|
||||
price: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
defaultValue: '0',
|
||||
},
|
||||
uid: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
allowNull: true,
|
||||
},
|
||||
createdAt: {
|
||||
type: DataTypes.DATE,
|
||||
@ -77,4 +80,4 @@ TicketModel.init(
|
||||
},
|
||||
);
|
||||
|
||||
await TicketModel.sync({ alter: true })
|
||||
await TicketModel.sync({ alter: true });
|
||||
|
@ -5,7 +5,7 @@
|
||||
<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 + React + TS</title>
|
||||
<title>工单系统</title>
|
||||
<link rel="stylesheet" href="/src/index.css" />
|
||||
<style>
|
||||
html,
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "vite-react",
|
||||
"name": "tickets",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
@ -11,7 +11,7 @@
|
||||
"postbuild2": "pnpm build:css",
|
||||
"postbuild": "rsync -av --delete ./dist/* ./backend/pages/root/tickets",
|
||||
"preview": "vite preview",
|
||||
"pub": "envision deploy ./dist -k vite-react -v 0.0.1",
|
||||
"pub": "envision deploy ./dist -k tickets -v 0.0.1 -u",
|
||||
"serve": "cd backend && bun --watch src/dev.ts"
|
||||
},
|
||||
"files": [
|
||||
@ -22,7 +22,7 @@
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^6.0.0",
|
||||
"@ant-design/v5-patch-for-react-19": "^1.0.3",
|
||||
"@kevisual/router": "0.0.22",
|
||||
"@kevisual/router": "0.0.23",
|
||||
"antd": "^5.26.1",
|
||||
"clsx": "^2.1.1",
|
||||
"dayjs": "^1.11.13",
|
||||
|
Loading…
x
Reference in New Issue
Block a user