mirror of
https://gitee.com/gokins/gokins.git
synced 2024-12-01 18:58:35 +08:00
commit
09d862df54
2
main.go
2
main.go
@ -47,7 +47,7 @@ func init() {
|
||||
}
|
||||
func main() {
|
||||
if upgrade {
|
||||
os.RemoveAll(comm.Dir + "/data")
|
||||
os.RemoveAll(comm.Dir + "/data/logs")
|
||||
if !ruisIo.PathExists(comm.Dir + "/db.dat") {
|
||||
println("未找到原有数据库")
|
||||
return
|
||||
|
@ -1,12 +1,13 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"gokins/comm"
|
||||
"gokins/model"
|
||||
"gokins/models"
|
||||
"gokins/service/dbService"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -88,9 +89,7 @@ func PlugRuns(c *gin.Context, req *ruisUtil.Map) {
|
||||
c.JSON(200, res)
|
||||
}
|
||||
func PlugLog(c *gin.Context, req *ruisUtil.Map) {
|
||||
if req.GetBool("first") == false {
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
pos, _ := req.GetInt("pos")
|
||||
tid, err := req.GetInt("tid")
|
||||
if err != nil || tid <= 0 {
|
||||
c.String(500, "param err")
|
||||
@ -111,13 +110,35 @@ func PlugLog(c *gin.Context, req *ruisUtil.Map) {
|
||||
c.String(404, "not found rn")
|
||||
return
|
||||
}
|
||||
|
||||
ln := pos
|
||||
bts := make([]byte, 1024)
|
||||
buf := &bytes.Buffer{}
|
||||
ret := ruisUtil.NewMap()
|
||||
ret.Set("id", rn.Id)
|
||||
ret.Set("text", "")
|
||||
logpth := fmt.Sprintf("%s/data/logs/%d/%d.log", comm.Dir, rn.Tid, rn.Id)
|
||||
outs, err := ioutil.ReadFile(logpth)
|
||||
fl, err := os.Open(logpth)
|
||||
if err == nil {
|
||||
ret.Set("text", string(outs))
|
||||
if pos > 0 {
|
||||
_, err = fl.Seek(pos, 0)
|
||||
if err != nil {
|
||||
c.String(500, "Seek err:"+err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
for {
|
||||
n, err := fl.Read(bts)
|
||||
if n > 0 {
|
||||
ln += int64(n)
|
||||
buf.Write(bts[:n])
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
ret.Set("text", buf.String())
|
||||
}
|
||||
ret.Set("pos", ln)
|
||||
c.JSON(200, ret)
|
||||
}
|
||||
|
@ -22,7 +22,7 @@
|
||||
<el-form-item prop="checkPass">
|
||||
<el-input type="password" v-model="ruleForm2.checkPass" auto-complete="off" placeholder="密码"></el-input>
|
||||
</el-form-item>
|
||||
<el-checkbox v-model="checked" checked class="remember">记住密码</el-checkbox>
|
||||
<!-- <el-checkbox v-model="checked" checked class="remember">记住密码</el-checkbox> -->
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit2" :loading="logining">登录</el-button>
|
||||
<!--<el-button @click.native.prevent="handleReset2">重置</el-button>-->
|
||||
|
@ -117,8 +117,8 @@
|
||||
//获取列表
|
||||
getList() {
|
||||
if(!this.running)return;
|
||||
let selid=this.selid;
|
||||
this.$post('/plug/runs',{id:this.tid,pid:selid,first:this.loading}).then((res) => {
|
||||
this.getLog(this.selid);
|
||||
this.$post('/plug/runs',{id:this.tid,first:this.loading}).then((res) => {
|
||||
console.log(res);
|
||||
this.loading = false;
|
||||
this.getInfo(res.data.tid);
|
||||
@ -129,7 +129,6 @@
|
||||
this.running=false;
|
||||
}
|
||||
this.getList();
|
||||
this.getLog(selid);
|
||||
}).catch(err=>{
|
||||
this.loading = false;
|
||||
this.$message({
|
||||
@ -156,10 +155,15 @@
|
||||
if(!this.running)this.getLog(this.selid);
|
||||
},getLog(selid){
|
||||
if(selid==''||selid<=0)return;
|
||||
if(this.logs[selid]&&!this.running)return;
|
||||
this.$post('/plug/log',{tid:this.tid,pid:selid}).then(res=>{
|
||||
let log=this.logs[selid];
|
||||
if(log&&!this.running)return;
|
||||
this.$post('/plug/log',{tid:this.tid,pid:selid,pos:log?log.pos:0}).then(res=>{
|
||||
res.data.tit=this.mpdata[selid].tit;
|
||||
this.logs[selid]=res.data;
|
||||
if(log&&res.data.pos>0){
|
||||
log.pos=res.data.pos;
|
||||
log.text+=res.data.text;
|
||||
}else
|
||||
this.logs[selid]=res.data;
|
||||
this.$forceUpdate();
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user