Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
<first-menu>
<menu-item href="/ns/routes" code="index">自定义线路</menu-item>
<menu-item href="/ns/routes/categories" code="category">线路分类</menu-item>
<span class="ui item disabled">|</span>
<menu-item href="/ns/routes/internal" code="internal">内置线路</menu-item>
</first-menu>

View File

@@ -0,0 +1,30 @@
{$layout "layout_popup"}
<h3>修改分类</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="categoryId" :value="category.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">分类名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus" v-model="category.name"/>
</td>
</tr>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>启用当前分类</td>
<td>
<checkbox name="isOn" v-model="category.isOn"></checkbox>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,17 @@
{$layout "layout_popup"}
<h3>添加分类</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<table class="ui table definition selectable">
<tr>
<td class="title">分类名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus"/>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,36 @@
{$layout}
{$template "../menu"}
<second-menu>
<menu-item @click.prevent="createCategory">[添加分类]</menu-item>
</second-menu>
<p class="comment" v-if="categories.length == 0">暂时还没有线路分类。</p>
<div v-if="categories.length > 0">
<table class="ui table celled selectable" id="sortable-table">
<thead>
<tr>
<th style="width: 3em"></th>
<th>分类名称</th>
<th class="width6">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tbody v-for="category in categories" :v-id="category.id">
<tr>
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
<td>
<a href="" @click.prevent="updateCategory(category.id)">{{category.name}} <i class="icon expand small"></i></a>
</td>
<td><label-on :v-is-on="category.isOn"></label-on></td>
<td>
<a href="" @click.prevent="updateCategory(category.id)">修改</a> &nbsp;
<a href="" @click.prevent="deleteCategory(category.id)">删除</a>
</td>
</tr>
</tbody>
</table>
<p class="comment" v-if="categories.length > 0">可以拖动左侧的<i class="icon bars"></i>排序。</p>
</div>

View File

@@ -0,0 +1,44 @@
Tea.context(function () {
this.$delay(function () {
let that = this
sortTable(function (ids) {
that.$post(".sort")
.params({
categoryIds: ids
})
.success(function () {
teaweb.successToast("排序保存成功")
})
})
})
this.createCategory = function () {
teaweb.popup(".createPopup", {
callback: function () {
teaweb.successRefresh("保存成功")
}
})
}
this.updateCategory = function (categoryId) {
teaweb.popup(".category.updatePopup?categoryId=" + categoryId, {
callback: function () {
teaweb.successRefresh("保存成功")
}
})
}
this.deleteCategory = function (categoryId) {
let that = this
teaweb.confirm("确定要删除此分类吗?", function () {
this.$post(".category.delete")
.params({
categoryId: categoryId
})
.success(function () {
teaweb.successRefresh("删除成功")
})
})
}
})

View File

@@ -0,0 +1,60 @@
{$layout "layout_popup"}
<h3>创建线路</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="clusterId" :value="clusterId"/>
<input type="hidden" name="domainId" :value="domainId"/>
<input type="hidden" name="userId" :value="userId"/>
<table class="ui table definition selectable">
<tr>
<td class="title">线路名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus"/>
</td>
</tr>
<tr>
<td rowspan="2">范围类型</td>
<td>
<select class="ui dropdown auto-width" v-model="rangeTypeCode" @change="changeRangeType">
<option v-for="rangeType in rangeTypes" :value="rangeType.code">{{rangeType.name}}</option>
</select>
</td>
</tr>
<tr>
<td>
<ns-route-ranges-box ref="routeRangesBox"></ns-route-ranges-box>
</td>
</tr>
<tr>
<td>所属分类</td>
<td>
<div v-if="categories.length > 0">
<select class="ui dropdown auto-width" name="categoryId">
<option value="0">[选择分类]</option>
<option v-for="category in categories" :value="category.id">{{category.name}}</option>
</select>
<p class="comment">可选项。</p>
</div>
<span class="comment" v-if="categories.length == 0">暂时还没有分类。</span>
</td>
</tr>
<tr>
<td>优先级</td>
<td>
<input type="text" name="priority" maxlength="10" style="width: 5em" value="0"/>
<p class="comment">优先级越高,越优先匹配。</p>
</td>
</tr>
<tr>
<td>公用</td>
<td>
<checkbox checked="checked" name="isPublic"></checkbox>
<p class="comment">选中后,表示允许用户使用当前创建的线路,否则只有管理员才能使用当前线路。</p>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,23 @@
Tea.context(function () {
this.rangeTypeCode = "ipRange"
this.rangeType = null
this.ranges = []
this.$delay(function () {
this.changeRangeType()
})
this.changeRangeType = function () {
let that = this
this.rangeType = this.rangeTypes.$find(function (k, v) {
return v.code == that.rangeTypeCode
})
if (this.$refs != null) {
let rangesBox = this.$refs.routeRangesBox
if (rangesBox != null) {
rangesBox.updateRangeType(this.rangeTypeCode)
}
}
}
})

View File

@@ -0,0 +1,19 @@
{$layout "layout_popup"}
<h3>导入IP</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success" data-tea-before="before" data-tea-done="done">
<csrf-token></csrf-token>
<table class="ui table definition selectable">
<tr>
<td class="title">选择IP数据文件 *</td>
<td>
<input type="file" name="file" accept=".json"/>
<p class="comment">文件名通常是AGENT_IP_LIST.json。</p>
</td>
</tr>
</table>
<submit-btn v-show="!isSending">导入</submit-btn>
<button class="ui button disabled" type="button" v-show="isSending">导入中...</button>
</form>

View File

@@ -0,0 +1,11 @@
Tea.context(function () {
this.isSending = false
this.before = function () {
this.isSending = true
}
this.done = function () {
this.isSending = false
}
})

View File

@@ -0,0 +1,73 @@
{$layout}
{$template "menu"}
<second-menu>
<menu-item href="" @click.prevent="createRoute()">[创建线路]</menu-item>
</second-menu>
<form class="ui form" action="/ns/routes" method="get" v-show="categories.length > 0">
<div class="ui fields inline">
<div class="ui field">
<select name="categoryId" class="ui dropdown" v-model="categoryId">
<option value="0">[选择分类]</option>
<option v-for="category in categories" :value="category.id">{{category.name}}</option>
</select>
</div>
<div class="ui field">
<button class="ui button" type="submit">搜索</button>
&nbsp;
<a href="/ns/routes" v-if="categoryId > 0">[清除条件]</a>
</div>
</div>
</form>
<div class="margin"></div>
<div v-if="routes.length == 0">
<p class="comment"><span v-if="categoryId > 0">当前分类下</span>暂时还没有线路。</p>
</div>
<div v-show="routes.length > 0">
<table class="ui table selectable celled" id="sortable-table">
<thead>
<tr>
<th style="width: 3em"></th>
<th>线路名称</th>
<th class="two wide">代号</th>
<th class="two wide">优先级 &nbsp; <tip-icon content="优先级越高越优先匹配。"></tip-icon></th>
<th class="two wide">公用&nbsp; <tip-icon content="设置为“公用”的线路允许用户使用。"></tip-icon></th>
<th class="two wide">状态</th>
<th class="two op">操作</th>
</tr>
</thead>
<tbody v-for="route in routes" :v-id="route.id">
<tr>
<td style="text-align: center;"><i class="icon bars handle grey"></i> </td>
<td><a href="" @click.prevent="updateRoute(route.id)">{{route.name}} <i class="icon expand small"></i></a>
<div>
<grey-label v-if="route.category.id > 0">{{route.category.name}}</grey-label>
<grey-label v-if="route.category.id == 0" class="disabled">[未分类]</grey-label>
</div>
</td>
<td>id:{{route.id}}</td>
<td>
<span v-if="route.priority > 0">{{route.priority}}</span>
<span v-else class="disabled">0</span>
</td>
<td>
<span v-if="route.isPublic" class="green">Y</span>
<span v-else class="disabled">N</span>
</td>
<td>
<label-on :v-is-on="route.isOn"></label-on>
</td>
<td>
<a href="" @click.prevent="updateRoute(route.id)">修改</a> &nbsp;
<a href="" @click.prevent="deleteRoute(route.id)">删除</a>
</td>
</tr>
</tbody>
</table>
<p class="comment" v-if="routes.length > 0">可以拖动左侧的<i class="icon bars"></i>排序;其中只有设置为"公用"的线路才允许用户使用。</p>
</div>

View File

@@ -0,0 +1,51 @@
Tea.context(function () {
this.$delay(function () {
let that = this
sortTable(function (ids) {
that.$post(".sort")
.params({
routeIds: ids
})
.success(function () {
teaweb.successToast("排序保存成功")
})
})
})
this.createRoute = function () {
teaweb.popup("/ns/routes/createPopup", {
width: "50em",
height: "30em",
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.updateRoute = function (routeId) {
teaweb.popup("/ns/routes/updatePopup?routeId=" + routeId, {
width: "50em",
height: "30em",
callback: function () {
teaweb.success("保存成功", function () {
teaweb.reload()
})
}
})
}
this.deleteRoute = function (routeId) {
let that = this
teaweb.confirm("确定要删除此线路吗?", function () {
that.$post(".delete")
.params({
routeId: routeId
})
.success(function () {
teaweb.reload()
})
})
}
})

View File

@@ -0,0 +1,83 @@
{$layout}
{$template "menu"}
<second-menu>
<menu-item :class="{active: selectedType == 'isp'}" @click.prevent="selectRouteType('isp')">运营商</menu-item>
<menu-item :class="{active: selectedType == 'chinaProvince'}" @click.prevent="selectRouteType('chinaProvince')">中国省市</menu-item>
<menu-item :class="{active: selectedType == 'worldRegion'}" @click.prevent="selectRouteType('worldRegion')">全球国家地区</menu-item>
<menu-item :class="{active: selectedType == 'agent'}" @click.prevent="selectRouteType('agent')">搜索引擎</menu-item>
</second-menu>
<!-- 运营商 -->
<div v-if="selectedType == 'isp'">
<table class="ui table selectable celled" style="width: 30em">
<thead>
<tr>
<th>运营商</th>
<th>代号</th>
</tr>
</thead>
<tr v-for="route in ispRoutes">
<td style="width: 50%">{{route.name}}</td>
<td>{{route.code}}</td>
</tr>
</table>
</div>
<!-- 中国省市 -->
<div v-if="selectedType == 'chinaProvince'">
<table class="ui table selectable celled" style="width: 30em">
<thead>
<tr>
<th>省市</th>
<th>代号</th>
</tr>
</thead>
<tr v-for="route in chinaProvinceRoutes">
<td style="width: 50%">{{route.name}}</td>
<td>{{route.code}}</td>
</tr>
</table>
</div>
<!-- 全球国家地区 -->
<div v-if="selectedType == 'worldRegion'">
<table class="ui table selectable celled" style="width: 30em">
<thead>
<tr>
<th>国家/地区</th>
<th>代号</th>
</tr>
</thead>
<tr v-for="route in worldRegionRoutes">
<td style="width: 50%">{{route.name}}</td>
<td>{{route.code}}</td>
</tr>
</table>
</div>
<!-- 搜索引擎 -->
<div v-if="selectedType == 'agent'">
<div>
<a href="/ns/routes/exportAgentIPs">[导出IP]</a> &nbsp; &nbsp;
<a href="" @click.prevent="importAgentIPs">[导入IP]</a>
</div>
<table class="ui table selectable celled" style="width: 30em">
<thead>
<tr>
<th>搜索引擎</th>
<th>代号</th>
<th>IP数量</th>
</tr>
</thead>
<tr v-for="route in agentRoutes">
<td style="width: 50%">{{route.name}}</td>
<td>{{route.code}}</td>
<td>
<span v-if="route.countIPs > 0">{{route.countIPs}}</span>
<span v-else class="disabled">-</span>
</td>
</tr>
</table>
<p class="comment" v-if="hasEmptyAgents">在集群开启"监测搜索引擎"后上表中没有IP的搜索引擎在访问智能DNS时会自动被记录。</p>
</div>

View File

@@ -0,0 +1,27 @@
Tea.context(function () {
this.createRoute = function () {
teaweb.popup("/ns/routes/createPopup", {
width: "50em",
height: "30em",
callback: function () {
teaweb.success("保存成功", function () {
window.location = "/ns/routes"
})
}
})
}
this.selectedType = "isp"
this.selectRouteType = function (routeType) {
this.selectedType = routeType
}
this.importAgentIPs = function () {
teaweb.popup("/ns/routes/importAgentIPsPopup", {
callback: function () {
teaweb.successRefresh("导入成功")
}
})
}
})

View File

@@ -0,0 +1,68 @@
{$layout "layout_popup"}
<h3>修改线路</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="routeId" :value="route.id"/>
<table class="ui table definition selectable">
<tr>
<td class="title">线路名称 *</td>
<td>
<input type="text" name="name" maxlength="100" ref="focus" v-model="route.name"/>
</td>
</tr>
<tr>
<td rowspan="2">范围类型</td>
<td>
<select class="ui dropdown auto-width" v-model="rangeTypeCode" @change="changeRangeType">
<option v-for="rangeType in rangeTypes" :value="rangeType.code">{{rangeType.name}}</option>
</select>
</td>
</tr>
<tr>
<td>
<ns-route-ranges-box ref="routeRangesBox" :v-ranges="route.ranges"></ns-route-ranges-box>
</td>
</tr>
<tr>
<td>所属分类</td>
<td>
<div v-if="categories.length > 0">
<select class="ui dropdown auto-width" name="categoryId" v-model="route.categoryId">
<option value="0">[选择分类]</option>
<option v-for="category in categories" :value="category.id">{{category.name}}</option>
</select>
<p class="comment">可选项。</p>
</div>
<span class="comment" v-if="categories.length == 0">暂时还没有分类。</span>
</td>
</tr>
<tr>
<td>优先级</td>
<td>
<input type="text" name="priority" maxlength="10" style="width: 5em" v-model="route.priority"/>
<p class="comment">优先级越高,越优先匹配。</p>
</td>
</tr>
<tr>
<td>公用</td>
<td>
<checkbox name="isPublic" v-model="route.isPublic"></checkbox>
<p class="comment">选中后,表示允许用户使用当前创建的线路,否则只有管理员才能使用当前线路。</p>
</td>
</tr>
<tr>
<td colspan="2"><more-options-indicator></more-options-indicator></td>
</tr>
<tbody v-show="moreOptionsVisible">
<tr>
<td>启用当前线路</td>
<td>
<checkbox name="isOn" value="1" v-model="route.isOn"></checkbox>
</td>
</tr>
</tbody>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,23 @@
Tea.context(function () {
this.rangeTypeCode = "ipRange"
this.rangeType = null
this.ranges = []
this.$delay(function () {
this.changeRangeType()
})
this.changeRangeType = function () {
let that = this
this.rangeType = this.rangeTypes.$find(function (k, v) {
return v.code == that.rangeTypeCode
})
if (this.$refs != null) {
let rangesBox = this.$refs.routeRangesBox
if (rangesBox != null) {
rangesBox.updateRangeType(this.rangeTypeCode)
}
}
}
})