找不到匹配的域名时可以指定默认域名、指定不匹配时的处理动作

This commit is contained in:
刘祥超
2020-11-18 12:17:50 +08:00
parent 850d343809
commit db770ab2a8
7 changed files with 157 additions and 30 deletions

View File

@@ -9,13 +9,55 @@
<td colspan="2">HTTP/HTTPS通用设置</td>
</tr>
<tr>
<td class="title">是否严格匹配域名</td>
<td class="title color-border">是否严格匹配域名</td>
<td>
<div class="ui checkbox">
<input type="checkbox" name="matchDomainStrictly" value="1" v-model="globalConfig.httpAll.matchDomainStrictly"/>
<label></label>
</div>
<p class="comment">如果选择了严格匹配域名,则没有在Edge里绑定过的域名访问时都会返回404</p>
<p class="comment">如果选择了严格匹配域名,找不到匹配的域名时会采取对应的动作</p>
</td>
</tr>
<tr>
<td class="color-border">默认域名</td>
<td>
<input type="text" name="defaultDomain" v-model="globalConfig.httpAll.defaultDomain" maxlength="100"/>
<p class="comment">当找不到匹配的域名时,自动使用此域名。</p>
</td>
</tr>
<tr>
<td class="color-border">允许不匹配的域名</td>
<td>
<values-box :name="'allowMismatchDomains'" :values="globalConfig.httpAll.allowMismatchDomains" :size="40" :maxlength="100" :placeholder="'域名'"></values-box>
<p class="comment">允许这些域名即时不匹配也可以访问。</p>
</td>
</tr>
<tr>
<td class="color-border">域名不匹配时的动作</td>
<td>
<div class="ui checkbox radio">
<input type="radio" name="domainMismatchAction" value="close" v-model="domainMismatchAction"/>
<label>断开连接</label>
</div>
&nbsp;
<div class="ui checkbox radio">
<input type="radio" name="domainMismatchAction" value="page" v-model="domainMismatchAction"/>
<label>显示提示页面</label>
</div>
<p class="comment" v-if="domainMismatchAction == 'close'">当找不到要访问的域名时关闭客户端连接。</p>
<p class="comment" v-if="domainMismatchAction == 'page'">当找不到访问的域名时显示一个提示页面。</p>
</td>
</tr>
<tr v-if="domainMismatchAction == 'page'">
<td class="color-border">响应代码</td>
<td>
<input type="text" name="domainMismatchActionPageStatusCode" v-model="domainMismatchActionPageOptions.statusCode" style="width:4em" maxlength="3"/>
</td>
</tr>
<tr v-if="domainMismatchAction == 'page'">
<td class="color-border">域名不匹配时的动作页面</td>
<td>
<textarea name="domainMismatchActionPageContentHTML" v-model="domainMismatchActionPageOptions.contentHTML" rows="3"></textarea>
</td>
</tr>
</table>

View File

@@ -1,3 +1,32 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功")
/**
* 域名不匹配动作
*/
this.domainMismatchAction = "page"
this.domainMismatchActionPageOptions = {
statusCode: 404,
contentHTML: `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<title>404 not found</title>
</head>
<body>
<h4>找不到您要访问的页面.</h4>
<h4>Sorry, page not found.</h4>
</body>
</html>
`
}
if (this.globalConfig.httpAll.domainMismatchAction != null) {
this.domainMismatchAction = this.globalConfig.httpAll.domainMismatchAction.code
if (this.domainMismatchAction == "page") {
this.domainMismatchActionPageOptions = this.globalConfig.httpAll.domainMismatchAction.options;
}
}
})