2020-09-20 11:56:49 +08:00
|
|
|
|
Vue.component("http-pages-and-shutdown-box", {
|
2020-09-26 08:07:18 +08:00
|
|
|
|
props: ["v-pages", "v-shutdown-config", "v-is-location"],
|
2020-09-20 08:58:48 +08:00
|
|
|
|
data: function () {
|
|
|
|
|
|
let pages = []
|
|
|
|
|
|
if (this.vPages != null) {
|
|
|
|
|
|
pages = this.vPages
|
|
|
|
|
|
}
|
|
|
|
|
|
let shutdownConfig = {
|
2020-09-26 08:07:18 +08:00
|
|
|
|
isPrior: false,
|
2020-09-20 08:58:48 +08:00
|
|
|
|
isOn: false,
|
2023-08-10 14:07:46 +08:00
|
|
|
|
bodyType: "html",
|
2020-09-20 08:58:48 +08:00
|
|
|
|
url: "",
|
2021-10-10 10:35:14 +08:00
|
|
|
|
body: "",
|
2020-09-20 08:58:48 +08:00
|
|
|
|
status: 0
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.vShutdownConfig != null) {
|
2021-10-10 10:35:14 +08:00
|
|
|
|
if (this.vShutdownConfig.body == null) {
|
|
|
|
|
|
this.vShutdownConfig.body = ""
|
|
|
|
|
|
}
|
|
|
|
|
|
if (this.vShutdownConfig.bodyType == null) {
|
2023-08-10 14:07:46 +08:00
|
|
|
|
this.vShutdownConfig.bodyType = "html"
|
2021-10-10 10:35:14 +08:00
|
|
|
|
}
|
2020-09-20 08:58:48 +08:00
|
|
|
|
shutdownConfig = this.vShutdownConfig
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let shutdownStatus = ""
|
|
|
|
|
|
if (shutdownConfig.status > 0) {
|
|
|
|
|
|
shutdownStatus = shutdownConfig.status.toString()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
pages: pages,
|
|
|
|
|
|
shutdownConfig: shutdownConfig,
|
|
|
|
|
|
shutdownStatus: shutdownStatus
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
shutdownStatus: function (status) {
|
|
|
|
|
|
let statusInt = parseInt(status)
|
|
|
|
|
|
if (!isNaN(statusInt) && statusInt > 0 && statusInt < 1000) {
|
|
|
|
|
|
this.shutdownConfig.status = statusInt
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.shutdownConfig.status = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
addPage: function () {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
teaweb.popup("/servers/server/settings/pages/createPopup", {
|
2023-11-10 14:59:53 +08:00
|
|
|
|
height: "30em",
|
2020-09-20 08:58:48 +08:00
|
|
|
|
callback: function (resp) {
|
|
|
|
|
|
that.pages.push(resp.data.page)
|
2023-11-10 14:59:53 +08:00
|
|
|
|
that.notifyChange()
|
2020-09-20 08:58:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
updatePage: function (pageIndex, pageId) {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
teaweb.popup("/servers/server/settings/pages/updatePopup?pageId=" + pageId, {
|
2023-11-10 14:59:53 +08:00
|
|
|
|
height: "30em",
|
2020-09-20 08:58:48 +08:00
|
|
|
|
callback: function (resp) {
|
|
|
|
|
|
Vue.set(that.pages, pageIndex, resp.data.page)
|
2023-11-10 14:59:53 +08:00
|
|
|
|
that.notifyChange()
|
2020-09-20 08:58:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
removePage: function (pageIndex) {
|
|
|
|
|
|
let that = this
|
2023-11-10 14:59:53 +08:00
|
|
|
|
teaweb.confirm("确定要删除此自定义页面吗?", function () {
|
2020-09-20 08:58:48 +08:00
|
|
|
|
that.pages.$remove(pageIndex)
|
2023-11-10 14:59:53 +08:00
|
|
|
|
that.notifyChange()
|
2020-09-20 08:58:48 +08:00
|
|
|
|
})
|
2021-10-10 10:35:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
addShutdownHTMLTemplate: function () {
|
2023-11-10 14:59:53 +08:00
|
|
|
|
this.shutdownConfig.body = `<!DOCTYPE html>
|
2023-08-25 15:03:31 +08:00
|
|
|
|
<html lang="en">
|
2021-10-10 10:35:14 +08:00
|
|
|
|
<head>
|
|
|
|
|
|
\t<title>升级中</title>
|
|
|
|
|
|
\t<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
2023-08-25 15:03:31 +08:00
|
|
|
|
\t<style>
|
|
|
|
|
|
\t\taddress { line-height: 1.8; }
|
|
|
|
|
|
\t</style>
|
2021-10-10 10:35:14 +08:00
|
|
|
|
</head>
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
2021-12-02 14:45:51 +08:00
|
|
|
|
<h1>网站升级中</h1>
|
2021-10-10 10:35:14 +08:00
|
|
|
|
<p>为了给您提供更好的服务,我们正在升级网站,请稍后重新访问。</p>
|
|
|
|
|
|
|
2023-08-25 15:03:31 +08:00
|
|
|
|
<address>Connection: \${remoteAddr} (Client) -> \${serverAddr} (Server)</address>
|
|
|
|
|
|
<address>Request ID: \${requestId}</address>
|
2021-10-10 10:35:14 +08:00
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
|
</html>`
|
2023-11-10 14:59:53 +08:00
|
|
|
|
},
|
|
|
|
|
|
notifyChange: function () {
|
|
|
|
|
|
let parent = this.$el.parentNode
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
if (parent == null) {
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
if (parent.tagName == "FORM") {
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
parent = parent.parentNode
|
|
|
|
|
|
}
|
|
|
|
|
|
if (parent != null) {
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
Tea.runActionOn(parent)
|
|
|
|
|
|
}, 100)
|
|
|
|
|
|
}
|
2020-09-20 08:58:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
template: `<div>
|
|
|
|
|
|
<input type="hidden" name="pagesJSON" :value="JSON.stringify(pages)"/>
|
|
|
|
|
|
<input type="hidden" name="shutdownJSON" :value="JSON.stringify(shutdownConfig)"/>
|
2023-11-10 14:59:53 +08:00
|
|
|
|
<h4 style="margin-bottom: 0.5em">自定义页面</h4>
|
|
|
|
|
|
|
|
|
|
|
|
<p class="comment" style="padding-top: 0; margin-top: 0">根据响应状态码返回一些自定义页面,比如404,500等错误页面。</p>
|
|
|
|
|
|
|
|
|
|
|
|
<div v-if="pages.length > 0" style="max-width: 30em">
|
|
|
|
|
|
<table class="ui table selectable celled">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<th class="four wide">响应状态码</th>
|
|
|
|
|
|
<th>页面类型</th>
|
|
|
|
|
|
<th style="width: 6.5em">操作</th>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tr v-for="(page,index) in pages">
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<span v-if="page.status != null && page.status.length == 1">{{page.status[0]}}</span>
|
|
|
|
|
|
<span v-else>{{page.status}}</span>
|
|
|
|
|
|
</td>
|
2023-11-10 16:36:03 +08:00
|
|
|
|
<td style="word-break: break-all">
|
|
|
|
|
|
<div v-if="page.bodyType == 'url'">
|
|
|
|
|
|
{{page.url}}
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<grey-label>读取</grey-label>
|
|
|
|
|
|
<grey-label v-if="page.newStatus > 0">{{page.newStatus}}</grey-label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="page.bodyType == 'redirectURL'">
|
|
|
|
|
|
{{page.url}}
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<grey-label>跳转</grey-label>
|
|
|
|
|
|
<grey-label v-if="page.newStatus > 0">{{page.newStatus}}</grey-label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="page.bodyType == 'html'">
|
|
|
|
|
|
[HTML内容]
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<grey-label v-if="page.newStatus > 0">{{page.newStatus}}</grey-label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</td>
|
2023-11-10 14:59:53 +08:00
|
|
|
|
<td>
|
|
|
|
|
|
<a href="" title="修改" @click.prevent="updatePage(index, page.id)">修改</a>
|
|
|
|
|
|
<a href="" title="删除" @click.prevent="removePage(index)">删除</a>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="margin-top: 1em">
|
|
|
|
|
|
<button class="ui button small" type="button" @click.prevent="addPage()">+添加自定义页面</button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<h4 style="margin-top: 2em;">临时关闭页面</h4>
|
|
|
|
|
|
<p class="comment" style="margin-top: 0; padding-top: 0">开启临时关闭页面时,所有请求都会直接显示此页面。可用于临时升级网站或者禁止用户访问某个网页。</p>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<table class="ui table selectable definition">
|
|
|
|
|
|
<prior-checkbox :v-config="shutdownConfig" v-if="vIsLocation"></prior-checkbox>
|
|
|
|
|
|
<tbody v-show="!vIsLocation || shutdownConfig.isPrior">
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td class="title">启用临时关闭网站</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<div class="ui checkbox">
|
|
|
|
|
|
<input type="checkbox" value="1" v-model="shutdownConfig.isOn" />
|
|
|
|
|
|
<label></label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<p class="comment">选中后,表示临时关闭当前网站,并显示自定义内容。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
<tbody v-show="(!vIsLocation || shutdownConfig.isPrior) && shutdownConfig.isOn">
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td>显示内容类型 *</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<select class="ui dropdown auto-width" v-model="shutdownConfig.bodyType">
|
|
|
|
|
|
<option value="html">HTML</option>
|
|
|
|
|
|
<option value="url">读取URL</option>
|
2023-11-10 16:36:03 +08:00
|
|
|
|
<option value="redirectURL">跳转URL</option>
|
2023-11-10 14:59:53 +08:00
|
|
|
|
</select>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2023-11-10 16:36:03 +08:00
|
|
|
|
<tr v-if="shutdownConfig.bodyType == 'url'">
|
2023-11-10 14:59:53 +08:00
|
|
|
|
<td class="title">显示页面URL *</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<input type="text" v-model="shutdownConfig.url" placeholder="类似于 https://example.com/page.html"/>
|
|
|
|
|
|
<p class="comment">将从此URL中读取内容。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2023-11-10 16:36:03 +08:00
|
|
|
|
<tr v-if="shutdownConfig.bodyType == 'redirectURL'">
|
|
|
|
|
|
<td class="title">跳转到URL *</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<input type="text" v-model="shutdownConfig.url" placeholder="类似于 https://example.com/page.html"/>
|
|
|
|
|
|
<p class="comment">将会跳转到此URL。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2023-11-10 14:59:53 +08:00
|
|
|
|
<tr v-show="shutdownConfig.bodyType == 'html'">
|
|
|
|
|
|
<td>显示页面HTML *</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<textarea name="body" ref="shutdownHTMLBody" v-model="shutdownConfig.body"></textarea>
|
|
|
|
|
|
<p class="comment"><a href="" @click.prevent="addShutdownHTMLTemplate">[使用模板]</a>。填写页面的HTML内容,支持请求变量。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td>状态码</td>
|
|
|
|
|
|
<td><input type="text" size="3" maxlength="3" name="shutdownStatus" style="width:5.2em" placeholder="状态码" v-model="shutdownStatus"/></td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
</div>
|
2020-09-20 08:58:48 +08:00
|
|
|
|
<div class="ui margin"></div>
|
|
|
|
|
|
</div>`
|
|
|
|
|
|
})
|