From fb4c46279cca9690e4d65acb81de127c912b7474 Mon Sep 17 00:00:00 2001 From: johlanse Date: Fri, 29 Jul 2022 15:55:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=B8=80=E4=BA=9B=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/linux/index.md | 18 +++++++++++++++++- docs/problem.md | 15 ++++++++++++++- docs/windows/index.md | 2 ++ main.go | 5 ++--- model/user.go | 5 +++++ web/controller.go | 25 +++++++++++++++++++++++++ web/router.go | 2 ++ 7 files changed, 67 insertions(+), 5 deletions(-) diff --git a/docs/linux/index.md b/docs/linux/index.md index 2db3d38..2598f95 100644 --- a/docs/linux/index.md +++ b/docs/linux/index.md @@ -1,4 +1,4 @@ -## linux基本使用 +## 可执行文件运行 + 本地访问[Releases]([Release](https://github.com/johlanse/study_xxqg/releases)) ,查找对应版本并复制链接 + 使用wget下载对应版本压缩包 @@ -13,3 +13,19 @@ ``` docker run --name study_xxqg -d -p 8080:8080 -v /etc/study_xxqg/:/opt/config/ jolanse/study_xxqg ``` + +## docker-compose运行 + +```shell +wget https://raw.githubusercontent.com/johlanse/study_xxqg/main/docker-compose.yml +docker-compose up -d +``` + +## 二种运行方式的区别 + ++ #### 可执行文件运行 + + 可执行文件运行节省存储空间,拥有更低的占用,但是可能会存在浏览器依赖安装的问题,适合拥有一定linux基础的用户使用 + ,如果系统为debian11用户,可以参考DockerFile文件中的依赖安装语句执行即可,centos用户推荐使用docker. ++ #### docker运行 + docker运行不需要解决依赖问题,但是可能面临更高的运行占用,建议使用docker控制内存占用 \ No newline at end of file diff --git a/docs/problem.md b/docs/problem.md index 013f493..ef2ac87 100644 --- a/docs/problem.md +++ b/docs/problem.md @@ -6,6 +6,12 @@ 然后查看报错内容截图并在[github](https://github.com/johlanse/study_xxqg/issues) 提交issue ``` ++ ### windows下出现找不到浏览器的问题 + +```yaml + +自行安装chromium内核的浏览器,包括chrome,edge浏览器之类,然后在配置文件中配置 edge_path 配置项,配置时将路径中的 \ 换成 / 或者 \\ +``` + ### arm设备报错```could not download driver: could not check if driver is up2date: could not run driver: exit status 127``` @@ -29,12 +35,19 @@ nohup参考命令 - nohup ./study_xxqg > xxqg.log 2>&1 & echo $! >pid.pid + nohup ./study_xxqg > xxqg.log 2>&1 退出程序可以通过**cat pid.pid**查看程序pid,然后kill对应pid进行退出 ``` + ++ ### linux上退出后台正在执行的进程 + +```yaml +study_xxqg进程会在运行的时候将pid输出到目录下的pid.pid文件,使用kil -9 命令即可退出后台进程 +``` + + ### 刷文章或者视频无法加分 ```yaml 偶尔出现视频和文章无法加分的bug,可以进行等待一段时间后重启程序再次测试,目前尚不清楚造成原因 diff --git a/docs/windows/index.md b/docs/windows/index.md index f2a8043..4fb93d9 100644 --- a/docs/windows/index.md +++ b/docs/windows/index.md @@ -6,4 +6,6 @@ + 进入解压后的文件夹,双击运行```study_xxqg.exe```,第一次打开可能会出现闪退,发现文件夹下生成了config文件夹 + 打开config目录下的```confif.yml```文件,进行编辑,详情内容见[配置文件](../config.md) + 再次进行运行```study_xxqg.exe``` ++ 使用浏览器打开```http://127.0.0.1:8080``` + diff --git a/main.go b/main.go index 00b6b36..92af5d4 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ import ( easy "github.com/t-tomalak/logrus-easy-formatter" "github.com/huoxue1/study_xxqg/conf" - //"github.com/huoxue1/study_xxqg/gui" + // "github.com/huoxue1/study_xxqg/gui" "github.com/huoxue1/study_xxqg/lib" "github.com/huoxue1/study_xxqg/model" "github.com/huoxue1/study_xxqg/push" @@ -159,13 +159,12 @@ func main() { log.Infoln("已采用普通学习模式") do("normal") } else { - //gui.InitWindow() + // gui.InitWindow() select {} } } func do(m string) { - defer func() { err := recover() if err != nil { diff --git a/model/user.go b/model/user.go index c2df727..29378ba 100644 --- a/model/user.go +++ b/model/user.go @@ -148,6 +148,11 @@ func UserCount(uid string) int { return count } +// DeleteUser +/* @Description: + * @param uid + * @return error + */ func DeleteUser(uid string) error { ping() _, err := db.Exec("delete from user where uid = ?;", uid) diff --git a/web/controller.go b/web/controller.go index 3bda6e5..6394926 100644 --- a/web/controller.go +++ b/web/controller.go @@ -302,3 +302,28 @@ func generate() gin.HandlerFunc { proxy.ServeHTTP(ctx.Writer, ctx.Request) } } + +// 删除用户 +func deleteUser() gin.HandlerFunc { + return func(ctx *gin.Context) { + uid := ctx.Query("uid") + err := model.DeleteUser(uid) + if err != nil { + ctx.JSON(200, Resp{ + Code: 503, + Message: "", + Data: "", + Success: false, + Error: err.Error(), + }) + return + } + ctx.JSON(200, Resp{ + Code: 200, + Message: "删除成功", + Data: "", + Success: true, + Error: "", + }) + } +} diff --git a/web/router.go b/web/router.go index 0e77543..3415746 100644 --- a/web/router.go +++ b/web/router.go @@ -39,6 +39,8 @@ func RouterInit() *gin.Engine { user.GET("/", getUsers()) + user.DELETE("/", deleteUser()) + router.GET("/score", getScore()) router.POST("/study", study())