-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollback.html
More file actions
47 lines (47 loc) · 1.47 KB
/
rollback.html
File metadata and controls
47 lines (47 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>rollback</title>
</head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/petite-vue/0.4.1/petite-vue.umd.min.js"></script>
<div id="app" @vue:mounted="onMounted">
<select v-model="currentItem">
<option value="">请选择回滚版本</option>
<option v-for="item in historyList" :key="item.id" :value="item">发版时间:{{ item.time }}</option>
</select>
<button @click="onRollback">回滚</button>
</div>
</body>
<script>
/** vue实例 */
PetiteVue.createApp({
historyList: [], // 构建记录列表
currentItem: undefined, // 当前选中的项目
onMounted() {
this.getHistory();
},
/** 获取构建记录列表 */
getHistory() {
fetch("/history").then(res => res.json()).then(res => {
if (res.code === 200) {
this.historyList = res.data.list;
}
});
},
/** 代码回滚 */
onRollback() {
if (!this.currentItem) return alert("请选择回滚目标版本!");
const isRollback = confirm(`确认项目回滚到${this.currentItem.time}版本!`);
if (isRollback) {
fetch(`/rollback?id=${this.currentItem.id}`).then(res => res.json()).then(res => {
if (res.code === 200) {
alert("快速回滚成功!");
}
});
}
},
}).mount("#app");
</script>
</html>