比較提交
4 次程式碼提交
3ae33607cc
...
master
作者 | SHA1 | 日期 | |
---|---|---|---|
dfc08cbe75 | |||
656427e444 | |||
225cfdbc54 | |||
670b4b5faa |
32
README.md
32
README.md
@@ -1,3 +1,35 @@
|
||||
# slader-legacy
|
||||
|
||||
Slader遗产
|
||||
|
||||
Demo:<https://slader-legacy.skyju.cc/>
|
||||
|
||||
```bash
|
||||
git clone https://git.sduonline.cn/juzheng/slader-legacy.git && cd slader-legacy/
|
||||
|
||||
# 安装全局依赖
|
||||
npm i typescript pnpm -g
|
||||
|
||||
# 启动后端
|
||||
cd slader-legacy-backend/
|
||||
# 下载 https://xinanwork.cowtransfer.com/s/1d682c4ca99640 的 slader.db 放在这个目录下
|
||||
cp .env.example .env
|
||||
vim .env # 编辑配置
|
||||
pnpm i
|
||||
pnpm run build
|
||||
pnpm start
|
||||
|
||||
# 启动前端
|
||||
cd slader-legacy-frontend/
|
||||
cp .env.example .env
|
||||
vim .env # 编辑配置
|
||||
pnpm i
|
||||
pnpm run build
|
||||
mv dist/* /path/to/your/www/
|
||||
|
||||
# nginx 路由配置示例
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
```
|
||||
|
||||
|
@@ -0,0 +1 @@
|
||||
SL_PORT=9696
|
@@ -4,7 +4,9 @@
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "tsc",
|
||||
"start": "node build/index.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
|
@@ -2,7 +2,7 @@ import {IExercise, ITextbook, IToc} from "./types"
|
||||
|
||||
export function fillIToc(single: any) {
|
||||
return <IToc>{
|
||||
section: single.section,
|
||||
section: single.section.replace(/\//g,'-'),
|
||||
count: single.count,
|
||||
pageBegin: single.pageBegin,
|
||||
pageEnd: single.pageEnd
|
||||
@@ -19,7 +19,7 @@ export function fillITextbook(single: any) {
|
||||
export function fillIExercise(single: any) {
|
||||
return <IExercise>{
|
||||
exercise: single.exercise,
|
||||
section: single.section,
|
||||
section: single.section.replace(/\//g,'-'),
|
||||
part: single.part,
|
||||
page: single.page,
|
||||
html: single.html
|
||||
|
@@ -24,13 +24,13 @@ textbookRouter.get('/:textbook/:section?/:exercise?',
|
||||
}),
|
||||
query('page').optional().isInt({min: 1}),
|
||||
param('section').optional().notEmpty().bail().custom((input, {req}) => {
|
||||
if (!textbookModel.existSection(req.params!.textbook, input)) {
|
||||
if (!textbookModel.existSection(req.params!.textbook, input.replace(/-/g, '/'))) {
|
||||
throw new Error('section not exist')
|
||||
}
|
||||
return true
|
||||
}),
|
||||
param('exercise').optional().notEmpty().bail().custom((input, {req}) => {
|
||||
if (!textbookModel.existExercise(req.params!.textbook, req.params!.section, input)) {
|
||||
if (!textbookModel.existExercise(req.params!.textbook, req.params!.section.replace(/-/g, '/'), input)) {
|
||||
throw new Error('exercise not exist')
|
||||
}
|
||||
return true
|
||||
@@ -40,9 +40,9 @@ textbookRouter.get('/:textbook/:section?/:exercise?',
|
||||
if (req.query.page) {
|
||||
res.json(await textbookService.getPage(req.params.textbook, Number(req.query.page)))
|
||||
} else if (req.params.exercise) {
|
||||
res.json(await textbookService.getExercise(req.params.textbook, req.params.section, req.params.exercise))
|
||||
res.json(await textbookService.getExercise(req.params.textbook, req.params.section.replace(/-/g, '/'), req.params.exercise))
|
||||
} else if (req.params.section) {
|
||||
res.json(await textbookService.getSection(req.params.textbook, req.params.section))
|
||||
res.json(await textbookService.getSection(req.params.textbook, req.params.section.replace(/-/g, '/')))
|
||||
} else {
|
||||
res.json(await textbookService.getTextbook(req.params.textbook))
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
VUE_APP_BASE_URL=http://localhost:9696/
|
@@ -3,9 +3,7 @@ node_modules
|
||||
/dist
|
||||
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
|
新增問題並參考
封鎖使用者