mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
1. 优化更新页面
This commit is contained in:
@@ -205,14 +205,17 @@ def do_update(request):
|
||||
site_obj = Site.objects.update_or_create(defaults=site_rules, url=site_rules.get('url'))
|
||||
print(site_obj[0].name + (' 规则新增成功!' if site_obj[1] else '规则更新成功!'))
|
||||
print('更新完毕,开始重启')
|
||||
do_restart(request)
|
||||
print(request.GET.get('restart'))
|
||||
flag = request.GET.get('restart') == 'true'
|
||||
if flag:
|
||||
do_restart(request)
|
||||
# cid = socket.gethostname()
|
||||
# reboot = subprocess.Popen('docker restart {}'.format(cid), shell=True, stdout=subprocess.PIPE, )
|
||||
# out = reboot.stdout.readline().decode('utf8')
|
||||
# client.api.inspect_container(cid)
|
||||
# StartedAt = client.api.inspect_container(cid).get('State').get('StartedAt')
|
||||
return JsonResponse(data=CommonResponse.error(
|
||||
msg='更新成功,重启指令发送成功,容器重启中 ...'
|
||||
msg='更新成功,重启指令发送成功,容器重启中 ...' if flag else '更新成功,未映射docker路径请手动重启容器 ...'
|
||||
).to_dict(), safe=False)
|
||||
except Exception as e:
|
||||
return JsonResponse(data=CommonResponse.error(
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<el-col :span="24">
|
||||
<el-card class="timeline">
|
||||
<div slot="header" class="clearfix">
|
||||
<span><i class="fab fa-stripe-s"></i>PTools更新日志
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="float-wrap clearfix">
|
||||
<div style="text-align: center">
|
||||
<div>v2022.08.13</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<transition name="el-zoom-in-top">
|
||||
<div class="block" v-if="timeline">
|
||||
<el-timeline>
|
||||
<el-timeline-item timestamp="2022.08.13" placement="top" color="#0bbd89">
|
||||
<ol>
|
||||
<li>
|
||||
<h4 style="color: red">正式命名为PTools,感谢群友</h4>
|
||||
</li>
|
||||
<li><h4>支持铂金家</h4></li>
|
||||
<li><h4>提供了通用配置,可自行添加站点(网站细节不同,不保证能用)</h4></li>
|
||||
<li><h4>支持数据导入导出</h4></li>
|
||||
<li><h4>提供docker,支持映射数据库文件</h4></li>
|
||||
</ol>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item timestamp="2022.08.12" placement="top" color="#0bbd89">
|
||||
<ol>
|
||||
<li><h4>增加时魔</h4></li>
|
||||
<li>优化签到信息显示</li>
|
||||
<li>优化个人数据通知</li>
|
||||
</ol>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item timestamp="2022.08.10" placement="top" color="#0bbd88">
|
||||
<ol>
|
||||
<li><h4>增加HD天空验证码签到功能开关</h4></li>
|
||||
</ol>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item timestamp="2022.08.08" placement="top" color="#0bbd88">
|
||||
<ol>
|
||||
<li><h4>增加HD天空验证码签到功能</h4></li>
|
||||
<li><h4>打包第二版docker进行测试,无数据备份</h4></li>
|
||||
</ol>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item timestamp="2022.08.07" placement="top" color="#0bbd87">
|
||||
<ol>
|
||||
<li><h4>实现企业微信通知,需要自行抓取个人公网IP</h4></li>
|
||||
</ol>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item timestamp="2022.08.05" placement="top" color="#0bbd86">
|
||||
<ol>
|
||||
<li><h4>实现签到、拉取个人数据以及拉取首页促销种子的自动化</h4></li>
|
||||
<li><h4>打包第一版docker进行测试,无数据备份</h4></li>
|
||||
</ol>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item timestamp="2022.08.03" placement="top" color="#0bbd85">
|
||||
<ol>
|
||||
<li>优化代码,降低数据库读写频次</li>
|
||||
</ol>
|
||||
</el-timeline-item>
|
||||
<el-timeline-item timestamp="2022.07.31" placement="top" color="#0bbd84">
|
||||
<ol>
|
||||
<li>开启多线程模式,大幅降低等待时间</li>
|
||||
</ol>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</div>
|
||||
</transition>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,255 +0,0 @@
|
||||
{% load static %}
|
||||
|
||||
<!-- 引入样式 -->
|
||||
|
||||
<link rel="stylesheet" href="{% static 'admin/simpleui-x/elementui/theme-chalk/index.css' %}">
|
||||
<!-- 引入组件库 -->
|
||||
|
||||
<div id="app">
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>
|
||||
<el-button type="primary">更新提示</el-button>
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="友情提示"
|
||||
width="200"
|
||||
trigger="hover"
|
||||
content="如果遇到无法更新的情况,您可以选择重建容器或者进入容器命令行到项目根目录执行`git pull`命令!">
|
||||
<el-link slot="reference"
|
||||
type="success">{{ update_tips }} + <span>容器已运行:{{ delta }}</span></el-link>
|
||||
</el-popover>
|
||||
</span>
|
||||
<span style="float: right;margin-top: -10px">
|
||||
{# <el-button type="primary" @click="do_refresh">刷新页面</el-button>#}
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
{# title="友情提示"#}
|
||||
width="200"
|
||||
trigger="hover"
|
||||
content="此操作会覆盖已支持站点在本地数据库中的规则,不支持的站点无操作">
|
||||
<el-button slot="reference" type="success" @click="do_update_xpath">规则更新</el-button>
|
||||
</el-popover>
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
width="200"
|
||||
trigger="hover"
|
||||
content="此操作只更新代码,不更新规则,代码更新要生效必须重启!">
|
||||
<el-button slot="reference" type="success" @click="do_update" v-if="update">代码更新</el-button>
|
||||
</el-popover>
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
width="200"
|
||||
trigger="hover"
|
||||
content="只有在容器中部署才能使用本操作,其他环境部署无效">
|
||||
<el-button slot="reference" type="danger" @click="do_restart" v-if="{{ restart }}">重启容器</el-button>
|
||||
</el-popover>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
<div class="text item">
|
||||
<el-row>
|
||||
<el-card class="box-card">
|
||||
<ul v-for="o in update_log" :key="o" class="text item">
|
||||
<li v-html="o"></li>
|
||||
</ul>
|
||||
</el-card>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="local_log_width">
|
||||
<el-card class="box-card" shadow="hover">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>本地日志</span>
|
||||
</div>
|
||||
<el-timeline>
|
||||
<el-timeline-item
|
||||
v-for="(update_note, index) in local_logs"
|
||||
:key="index"
|
||||
icon="el-icon-refresh"
|
||||
type="success"
|
||||
color="#0bbd87"
|
||||
{# :size="activity.size" #}
|
||||
:timestamp="update_note.date">
|
||||
<el-card shadow="hover">
|
||||
<p v-for="content in update_note.data" v-html="content">
|
||||
</p>
|
||||
</el-card>
|
||||
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="update">
|
||||
<el-card class="box-card" shadow="hover">
|
||||
<div slot="header" class="clearfix">
|
||||
<span>更新日志</span>
|
||||
</div>
|
||||
<el-timeline>
|
||||
<el-timeline-item
|
||||
v-for="(update_note, index) in update_notes"
|
||||
:key="index"
|
||||
{# :icon="activity.icon" #}
|
||||
{# :type="activity.type" #}
|
||||
color="#0bbd87"
|
||||
{# :size="activity.size" #}
|
||||
:timestamp="update_note.date">
|
||||
<el-card shadow="hover">
|
||||
<p v-for="content in update_note.data" v-html="content">
|
||||
</p>
|
||||
</el-card>
|
||||
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<script src="{% static 'admin/simpleui-x/js/vue.min.js' %}"></script>
|
||||
<script src="{% static 'admin/simpleui-x/elementui/index.js' %}"></script>
|
||||
<script src="{% static 'admin/simpleui-x/js/axios.min.js' %}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// 配置对象 options
|
||||
const vm = new Vue({
|
||||
// 配置选项(option)
|
||||
// element: 指定用vue来管理页面中的哪个标签区域
|
||||
el: '#app',
|
||||
data: {
|
||||
update_notes: {{ update_notes | safe }},
|
||||
local_logs: {{ local_logs | safe }},
|
||||
local_log: [],
|
||||
update_log: [],
|
||||
update: {{ update }},
|
||||
local_log_width: 24,
|
||||
},
|
||||
created() {
|
||||
if (this.update) {
|
||||
this.local_log_width = 12
|
||||
}
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: "{{ update_tips }}",
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
,
|
||||
methods: {
|
||||
do_update_xpath() {
|
||||
this.$confirm('此操作将覆盖本地规则,请提前备份,是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
axios.get(
|
||||
"{% url "do_update_xpath" %}"
|
||||
).then(res => {
|
||||
if (res.data.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: res.data.msg
|
||||
});
|
||||
this.update_log = res.data.data.update_log
|
||||
} else {
|
||||
console.log(res)
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: res.data.msg
|
||||
});
|
||||
}
|
||||
}).catch(res => {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: "更新失败!"
|
||||
});
|
||||
})
|
||||
}).catch(res => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消更新'
|
||||
});
|
||||
});
|
||||
},
|
||||
do_restart() {
|
||||
this.$confirm('此操作将重启容器,并更新软件, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
axios.get(
|
||||
"{% url "do_restart" %}"
|
||||
).then(res => {
|
||||
if (res.data.code === 0) {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: res.data.msg
|
||||
});
|
||||
} else {
|
||||
console.log(res)
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: res.data.msg
|
||||
});
|
||||
}
|
||||
}).catch(res => {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: "重启失败!"
|
||||
});
|
||||
})
|
||||
|
||||
}).catch(res => {
|
||||
{#console.log(res)#}
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消重启'
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
do_update() {
|
||||
this.$confirm('此操作会拉取软件更新软件,新版本不一定稳定,是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
axios.get(
|
||||
"{% url "do_update" %}"
|
||||
).then(res => {
|
||||
if (res.data.code === 0) {
|
||||
console.log(res, 1)
|
||||
this.update_log = res.data.data.result
|
||||
{#console.log('规则更新记录', res.data.data.xpath_update)#}
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: res.data.msg
|
||||
});
|
||||
} else {
|
||||
console.log(res, 2)
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: res.data.msg
|
||||
});
|
||||
}
|
||||
}).catch(res => {
|
||||
console.log(res, 3)
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: "更新失败!"
|
||||
});
|
||||
})
|
||||
|
||||
}).catch(res => {
|
||||
console.log(res)
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '已取消更新'
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -23,8 +23,34 @@
|
||||
</el-popover>
|
||||
</span>
|
||||
<span style="float: right;margin-top: -10px">
|
||||
<el-button slot="reference" type="danger" @click="do_update" v-if="{{ update }}">重启更新</el-button>
|
||||
<el-button slot="reference" type="danger" @click="do_restart" v-else>重启</el-button>
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="友情提示"
|
||||
width="300"
|
||||
trigger="hover"
|
||||
content="更新之前会自动备份数据库,更新完毕后会自动重启容器!">
|
||||
<el-button slot="reference" type="danger" @click="do_update({{ restart }})"
|
||||
v-if="update && restart"
|
||||
>重启更新</el-button>
|
||||
</el-popover>
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="友情提示"
|
||||
width="300"
|
||||
trigger="hover"
|
||||
content="没啥特殊功能,就是重启下容器!">
|
||||
<el-button slot="reference" type="danger" @click="do_restart" v-if="!update && restart">重启</el-button>
|
||||
</el-popover>
|
||||
<el-popover
|
||||
placement="top-start"
|
||||
title="友情提示"
|
||||
width="300"
|
||||
trigger="hover"
|
||||
content="未映射docker路径,更新完毕后请手动重启容器!">
|
||||
<el-button slot="reference" type="danger" @click="do_update({{ restart }})"
|
||||
v-if="update && !restart"
|
||||
>更新</el-button>
|
||||
</el-popover>
|
||||
</span>
|
||||
</div>
|
||||
<div class="text item">
|
||||
@@ -95,7 +121,7 @@
|
||||
update_notes: {{ update_notes | safe }},
|
||||
local_logs: {{ local_logs | safe }},
|
||||
{#local_log: [],#}
|
||||
{#update_log: [],#}
|
||||
restart: {{ restart }},
|
||||
update: {{ update }},
|
||||
local_log_width: 24,
|
||||
},
|
||||
@@ -148,14 +174,19 @@
|
||||
});
|
||||
},
|
||||
|
||||
do_update() {
|
||||
do_update(restart) {
|
||||
console.log(restart)
|
||||
this.$confirm('此操作会拉取软件更新软件,并重启容器,是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
axios.get(
|
||||
"{% url "do_update" %}"
|
||||
"{% url "do_update" %}", {
|
||||
params: {
|
||||
restart: restart
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
if (res.data.code === 0) {
|
||||
console.log(res, 1)
|
||||
|
||||
Reference in New Issue
Block a user