2020-09-26 11:21:52 +08:00
|
|
|
|
Vue.component("http-web-root-box", {
|
2021-10-07 16:47:14 +08:00
|
|
|
|
props: ["v-root-config", "v-is-location", "v-is-group"],
|
2020-09-26 11:21:52 +08:00
|
|
|
|
data: function () {
|
2023-08-10 11:26:53 +08:00
|
|
|
|
let config = this.vRootConfig
|
|
|
|
|
|
if (config == null) {
|
|
|
|
|
|
config = {
|
2020-09-26 11:21:52 +08:00
|
|
|
|
isPrior: false,
|
2023-07-17 11:54:41 +08:00
|
|
|
|
isOn: false,
|
2020-09-26 11:21:52 +08:00
|
|
|
|
dir: "",
|
|
|
|
|
|
indexes: [],
|
|
|
|
|
|
stripPrefix: "",
|
|
|
|
|
|
decodePath: false,
|
2023-08-10 11:26:53 +08:00
|
|
|
|
isBreak: false,
|
|
|
|
|
|
exceptHiddenFiles: true,
|
|
|
|
|
|
onlyURLPatterns: [],
|
|
|
|
|
|
exceptURLPatterns: []
|
2020-09-26 11:21:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-08-10 11:26:53 +08:00
|
|
|
|
if (config.indexes == null) {
|
|
|
|
|
|
config.indexes = []
|
2020-09-26 11:21:52 +08:00
|
|
|
|
}
|
2023-08-10 11:26:53 +08:00
|
|
|
|
|
|
|
|
|
|
if (config.onlyURLPatterns == null) {
|
|
|
|
|
|
config.onlyURLPatterns = []
|
|
|
|
|
|
}
|
|
|
|
|
|
if (config.exceptURLPatterns == null) {
|
|
|
|
|
|
config.exceptURLPatterns = []
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-09-26 11:21:52 +08:00
|
|
|
|
return {
|
2023-08-10 11:26:53 +08:00
|
|
|
|
config: config,
|
2020-09-26 11:21:52 +08:00
|
|
|
|
advancedVisible: false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
changeAdvancedVisible: function (v) {
|
|
|
|
|
|
this.advancedVisible = v
|
|
|
|
|
|
},
|
|
|
|
|
|
addIndex: function () {
|
|
|
|
|
|
let that = this
|
|
|
|
|
|
teaweb.popup("/servers/server/settings/web/createIndex", {
|
|
|
|
|
|
height: "10em",
|
|
|
|
|
|
callback: function (resp) {
|
2023-08-10 11:26:53 +08:00
|
|
|
|
that.config.indexes.push(resp.data.index)
|
2020-09-26 11:21:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
removeIndex: function (i) {
|
2023-08-10 11:26:53 +08:00
|
|
|
|
this.config.indexes.$remove(i)
|
2020-09-26 11:52:21 +08:00
|
|
|
|
},
|
|
|
|
|
|
isOn: function () {
|
2023-08-10 11:26:53 +08:00
|
|
|
|
return ((!this.vIsLocation && !this.vIsGroup) || this.config.isPrior) && this.config.isOn
|
2020-09-26 11:21:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
template: `<div>
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<input type="hidden" name="rootJSON" :value="JSON.stringify(config)"/>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<table class="ui table selectable definition">
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<prior-checkbox :v-config="config" v-if="vIsLocation || vIsGroup"></prior-checkbox>
|
|
|
|
|
|
<tbody v-show="(!vIsLocation && !vIsGroup) || config.isPrior">
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<tr>
|
2022-11-10 15:07:15 +08:00
|
|
|
|
<td class="title">启用静态资源分发</td>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<td>
|
|
|
|
|
|
<div class="ui checkbox">
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<input type="checkbox" v-model="config.isOn"/>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<label></label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2020-09-26 11:52:21 +08:00
|
|
|
|
</tbody>
|
|
|
|
|
|
<tbody v-show="isOn()">
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<tr>
|
2020-09-28 16:25:26 +08:00
|
|
|
|
<td class="title">静态资源根目录</td>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<td>
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<input type="text" name="root" v-model="config.dir" ref="focus" placeholder="类似于 /home/www"/>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<p class="comment">可以访问此根目录下的静态资源。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
2020-09-26 11:52:21 +08:00
|
|
|
|
<more-options-tbody @change="changeAdvancedVisible" v-if="isOn()"></more-options-tbody>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
|
2020-09-26 11:52:21 +08:00
|
|
|
|
<tbody v-show="isOn() && advancedVisible">
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<tr>
|
|
|
|
|
|
<td>首页文件</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<!-- TODO 支持排序 -->
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<div v-if="config.indexes.length > 0">
|
|
|
|
|
|
<div v-for="(index, i) in config.indexes" class="ui label small basic">
|
2020-09-26 11:21:52 +08:00
|
|
|
|
{{index}} <a href="" title="删除" @click.prevent="removeIndex(i)"><i class="icon remove"></i></a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<button class="ui button tiny" type="button" @click.prevent="addIndex()">+</button>
|
|
|
|
|
|
<p class="comment">在URL中只有目录没有文件名时默认查找的首页文件。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<tr>
|
|
|
|
|
|
<td>例外URL</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<url-patterns-box v-model="config.exceptURLPatterns"></url-patterns-box>
|
|
|
|
|
|
<p class="comment">如果填写了例外URL,表示不支持通过这些URL访问。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td>限制URL</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<url-patterns-box v-model="config.onlyURLPatterns"></url-patterns-box>
|
|
|
|
|
|
<p class="comment">如果填写了限制URL,表示仅支持通过这些URL访问。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td>排除隐藏文件</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<checkbox v-model="config.exceptHiddenFiles"></checkbox>
|
|
|
|
|
|
<p class="comment">排除以点(.)符号开头的隐藏目录或文件,比如<code-label>/.git/logs/HEAD</code-label></p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<tr>
|
|
|
|
|
|
<td>去除URL前缀</td>
|
|
|
|
|
|
<td>
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<input type="text" v-model="config.stripPrefix" placeholder="/PREFIX"/>
|
2020-09-27 10:03:00 +08:00
|
|
|
|
<p class="comment">可以把请求的路径部分前缀去除后再查找文件,比如把 <span class="ui label tiny">/web/app/index.html</span> 去除前缀 <span class="ui label tiny">/web</span> 后就变成 <span class="ui label tiny">/app/index.html</span>。 </p>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td>路径解码</td>
|
|
|
|
|
|
<td>
|
|
|
|
|
|
<div class="ui checkbox">
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<input type="checkbox" v-model="config.decodePath"/>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<label></label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<p class="comment">是否对请求路径进行URL解码,比如把 <span class="ui label tiny">/Web+App+Browser.html</span> 解码成 <span class="ui label tiny">/Web App Browser.html</span> 再查找文件。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
<tr>
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<td>终止请求</td>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<td>
|
|
|
|
|
|
<div class="ui checkbox">
|
2023-08-10 11:26:53 +08:00
|
|
|
|
<input type="checkbox" v-model="config.isBreak"/>
|
2020-09-26 11:21:52 +08:00
|
|
|
|
<label></label>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<p class="comment">在找不到要访问的文件的情况下是否终止请求并返回404,如果选择终止请求,则不再尝试反向代理等设置。</p>
|
|
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
<div class="margin"></div>
|
|
|
|
|
|
</div>`
|
|
|
|
|
|
})
|