mirror of
https://github.com/ngfchl/ptools
synced 2023-07-10 13:41:22 +08:00
1. 优化更新提示
This commit is contained in:
2
.idea/ptools.iml
generated
2
.idea/ptools.iml
generated
@@ -15,11 +15,13 @@
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/db" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.9 (pt_assist)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
||||
<option name="TEMPLATE_FOLDERS">
|
||||
<list>
|
||||
<option value="$MODULE_DIR$/templates" />
|
||||
|
||||
@@ -193,14 +193,6 @@ def do_update(request):
|
||||
result.append(i.decode('utf8'))
|
||||
print(result)
|
||||
# 更新数据库
|
||||
# with open('main_pt_site_site.sql', encoding='utf-8') as sql_file:
|
||||
# contents = sql_file.readlines()
|
||||
# print(contents[0])
|
||||
# with connection.cursor() as cursor:
|
||||
# for statement in contents:
|
||||
# cursor.execute(statement)
|
||||
# Site.objects.raw()
|
||||
# 更新数据库
|
||||
with open('./pt_site_site.json', 'r') as f:
|
||||
# print(f.readlines())
|
||||
data = json.load(f)
|
||||
|
||||
@@ -26,6 +26,13 @@
|
||||
</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">
|
||||
@@ -36,10 +43,10 @@
|
||||
<el-timeline-item
|
||||
v-for="(update_note, index) in local_logs"
|
||||
:key="index"
|
||||
{# :icon="activity.icon"#}
|
||||
{# :type="activity.type"#}
|
||||
icon="el-icon-refresh"
|
||||
type="success"
|
||||
color="#0bbd87"
|
||||
{# :size="activity.size"#}
|
||||
{# :size="activity.size" #}
|
||||
:timestamp="update_note.date">
|
||||
<el-card shadow="hover">
|
||||
<p v-for="content in update_note.data" v-html="content">
|
||||
@@ -59,10 +66,10 @@
|
||||
<el-timeline-item
|
||||
v-for="(update_note, index) in update_notes"
|
||||
:key="index"
|
||||
{# :icon="activity.icon"#}
|
||||
{# :type="activity.type"#}
|
||||
{# :icon="activity.icon" #}
|
||||
{# :type="activity.type" #}
|
||||
color="#0bbd87"
|
||||
{# :size="activity.size"#}
|
||||
{# :size="activity.size" #}
|
||||
:timestamp="update_note.date">
|
||||
<el-card shadow="hover">
|
||||
<p v-for="content in update_note.data" v-html="content">
|
||||
@@ -90,132 +97,107 @@
|
||||
// element: 指定用vue来管理页面中的哪个标签区域
|
||||
el: '#app',
|
||||
data: {
|
||||
update_notes: {{ update_notes|safe }},
|
||||
local_logs: {{ local_logs|safe }},
|
||||
update_notes: {{ update_notes | safe }},
|
||||
local_logs: {{ local_logs | safe }} ,
|
||||
local_log: [],
|
||||
update_log:[],
|
||||
update: false,
|
||||
local_log_width: 24
|
||||
},
|
||||
created() {
|
||||
this.update =
|
||||
{{ update }}
|
||||
local_log_width:24,
|
||||
},
|
||||
created()
|
||||
{
|
||||
this.update = {{ update }}
|
||||
|
||||
if (this.update) {
|
||||
this.local_log_width = 12
|
||||
if (this.update) {
|
||||
this.local_log_width = 12
|
||||
|
||||
}
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: "{{ update_tips }}",
|
||||
type: 'success'
|
||||
}
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: "{{ update_tips }}",
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
,
|
||||
methods: {
|
||||
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: '已取消重启'
|
||||
});
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
do_restart() {
|
||||
this.$confirm('此操作将重启容器,并更新软件, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
axios.get(
|
||||
"{% url "do_restart" %}"
|
||||
{#url + '/task/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)
|
||||
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
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: '已取消重启'
|
||||
type: 'success',
|
||||
message: res.data.msg
|
||||
});
|
||||
});
|
||||
},
|
||||
{#get_update() {#}
|
||||
{# axios.get(#}
|
||||
{# "{% url "do_get_update" %}"#}
|
||||
{# ).then(res => {#}
|
||||
{# if (res.data.code === 0) {#}
|
||||
{# console.log(res.data)#}
|
||||
{# this.update_notes = res.data.data.update_notes#}
|
||||
{#this.update_log = true#}
|
||||
{# this.local_log_width = 12#}
|
||||
{# this.$message({#}
|
||||
{# type: 'success',#}
|
||||
{# message: res.data.msg#}
|
||||
{# });#}
|
||||
{# } else {#}
|
||||
{# console.log(res)#}
|
||||
{# this.$message({#}
|
||||
{# type: 'warning',#}
|
||||
{# message: res.data.msg#}
|
||||
{# });#}
|
||||
{# }#}
|
||||
{# }).catch(res => {#}
|
||||
{# console.log(res)#}
|
||||
{# this.$message({#}
|
||||
{# type: 'info',#}
|
||||
{# message: '获取更新失败!'#}
|
||||
{# });#}
|
||||
{# });#}
|
||||
{#{},#}
|
||||
do_update() {
|
||||
this.$confirm('此操作会拉取软件更新软件,新版本不一定稳定,是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
axios.get(
|
||||
"{% url "do_update" %}"
|
||||
{#url + '/task/do_restart'#}
|
||||
).then(res => {
|
||||
if (res.data.code === 0) {
|
||||
console.log(res, 1)
|
||||
this.update_note = res.data.data
|
||||
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)
|
||||
} else {
|
||||
console.log(res, 2)
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: '已取消更新'
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user