mirror of
https://gitee.com/gokins/gokins.git
synced 2024-11-29 17:57:50 +08:00
解决前端导致卡顿问题+
This commit is contained in:
parent
e4c254a64c
commit
5267e70433
@ -37,5 +37,5 @@ func Init() {
|
||||
gpPlug.Any("/edit", core.GinHandler(server.PlugEdit))
|
||||
gpPlug.Any("/del", core.GinHandler(server.PlugDel))
|
||||
gpPlug.Any("/runs", core.GinHandler(server.PlugRuns))
|
||||
//gpPlug.Any("/log", core.GinHandler(server.PlugLog))
|
||||
gpPlug.Any("/log", core.GinHandler(server.PlugLog))
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
"gokins/models"
|
||||
"gokins/service/dbService"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -83,29 +82,35 @@ func PlugRuns(c *gin.Context, req *ruisUtil.Map) {
|
||||
res.Set("list", ls)
|
||||
res.Set("tid", mr.Tid)
|
||||
res.Set("end", mr.State >= 2)
|
||||
plugLog(req.GetString("pid"), mr, res)
|
||||
c.JSON(200, res)
|
||||
}
|
||||
func plugLog(pids string, mr *model.TModelRun, ret *ruisUtil.Map) {
|
||||
pid, err := strconv.ParseInt(pids, 10, 64)
|
||||
func PlugLog(c *gin.Context, req *ruisUtil.Map) {
|
||||
tid, err := req.GetInt("tid")
|
||||
if err != nil || tid <= 0 {
|
||||
c.String(500, "param err")
|
||||
return
|
||||
}
|
||||
pid, err := req.GetInt("pid")
|
||||
if err != nil || pid <= 0 {
|
||||
c.String(500, "param err")
|
||||
return
|
||||
}
|
||||
mr := dbService.GetModelRun(int(tid))
|
||||
if mr == nil {
|
||||
c.String(404, "not found")
|
||||
return
|
||||
}
|
||||
rn := dbService.FindPluginRun(mr.Tid, mr.Id, int(pid))
|
||||
if rn == nil {
|
||||
return
|
||||
}
|
||||
res := ruisUtil.NewMap()
|
||||
res.Set("id", rn.Id)
|
||||
res.Set("up", true)
|
||||
res.Set("text", "")
|
||||
if rn.State >= 2 {
|
||||
res.Set("up", false)
|
||||
}
|
||||
ret := ruisUtil.NewMap()
|
||||
ret.Set("id", rn.Id)
|
||||
ret.Set("text", "")
|
||||
logpth := fmt.Sprintf("%s/data/logs/%d/%d.log", comm.Dir, rn.Mid, rn.Id)
|
||||
outs, err := ioutil.ReadFile(logpth)
|
||||
if err == nil {
|
||||
res.Set("text", string(outs))
|
||||
ret.Set("text", string(outs))
|
||||
}
|
||||
ret.Set("log", res)
|
||||
c.JSON(200, ret)
|
||||
}
|
||||
|
@ -64,7 +64,7 @@
|
||||
data() {
|
||||
return {
|
||||
tid:'',
|
||||
running=false,
|
||||
running:false,
|
||||
loading: false,
|
||||
listdata: [],
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
//获取列表
|
||||
getList() {
|
||||
if(!this.running)return;
|
||||
this.$post('/plug/runs',{id:this.tid,pid:this.selid,first:this.running}).then((res) => {
|
||||
this.$post('/plug/runs',{id:this.tid,pid:this.selid,first:this.loading}).then((res) => {
|
||||
console.log(res);
|
||||
this.loading = false;
|
||||
this.getInfo(res.data.tid);
|
||||
@ -107,9 +107,7 @@
|
||||
this.running=false;
|
||||
}
|
||||
this.getList();
|
||||
if(res.data.log&&res.data.log.id){
|
||||
this.logs[res.data.log.id]=res.data.log;
|
||||
}
|
||||
this.getLog();
|
||||
}).catch(err=>{
|
||||
this.loading = false;
|
||||
this.$message({
|
||||
@ -133,6 +131,13 @@
|
||||
this.selid=e.Id;
|
||||
this.$forceUpdate();
|
||||
console.log('showLog:',this.mpdata[idx]);
|
||||
if(!this.running)this.getLog();
|
||||
},getLog(ls){
|
||||
if(this.selid==''||this.selid<=0)return;
|
||||
this.$post('/plug/log',{tid:this.tid,pid:this.selid}).then(res=>{
|
||||
this.logs[this.selid]=res.data;
|
||||
this.$forceUpdate();
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user