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,64 @@
{$layout}
<second-menu>
<menu-item href="/anti-ddos/packages">[购买实例]</menu-item>
</second-menu>
<p class="comment" v-if="userInstances.length == 0">暂时还没有实例,<a href="/anti-ddos/packages">[点此购买]</a></p>
<div v-if="userInstances.length > 0">
<table class="ui table selectable celled">
<thead>
<tr>
<th>高防产品</th>
<th>高防IP</th>
<th style="width: 7em">有效期</th>
<th style="width: 7em">开始日期</th>
<th style="width: 7em">结束日期</th>
<th class="width6">防护对象</th>
<th class="two op">操作</th>
</tr>
</thead>
<tr v-for="userInstance in userInstances">
<td>
<span v-if="userInstance.package.id > 0">{{userInstance.package.summary}}</span>
<span v-else class="red">已删除</span>
</td>
<td>
<div v-if="userInstance.ipAddresses != null && userInstance.ipAddresses.length > 0">
<div v-for="ip in userInstance.ipAddresses">
{{ip}}
</div>
</div>
<span v-else class="red">无有效IP</span>
</td>
<td>{{userInstance.periodCount}}{{userInstance.periodUnitName}}</td>
<td>{{userInstance.dayFrom}}</td>
<td>{{userInstance.dayTo}}
<div v-if="userInstance.isExpired">
<span v-if="userInstance.isExpired" class="small red">已过期</span>
</div>
</td>
<td>
<!-- 防护对象 -->
<a href="" v-if="userInstance.isAvailable" @click.prevent="updateObjectsPopup(userInstance.id)">
<span v-if="userInstance.countObjects > 0">{{userInstance.countObjects}}个对象</span>
<span v-else>设置</span>
</a>
<span v-else class="disabled">{{userInstance.countObjects}}</span>
&nbsp;
</td>
<td>
<!-- 续费 -->
<span v-if="userInstance.instance.userInstanceId == userInstance.id"><a :href="'/anti-ddos/instances/renew?userInstanceId=' + userInstance.id">续费</a></span>
<span v-else class="disabled">续费</span> &nbsp;
<!-- 删除 -->
<a href="" v-if="userInstance.canDelete" @click.prevent="deleteUserInstance(userInstance.id)">删除</a>
</td>
</tr>
</table>
<page-box></page-box>
</div>

View File

@@ -0,0 +1,33 @@
Tea.context(function () {
this.renewUserInstance = function (userInstanceId) {
teaweb.popup(".renewPopup?userInstanceId=" + userInstanceId, {
height: "26em",
callback: function () {
teaweb.successRefresh("续期成功")
}
})
}
this.updateObjectsPopup = function (userInstanceId) {
teaweb.popup(".updateObjectsPopup?userInstanceId=" + userInstanceId, {
width: "60em",
height: "40em",
callback: function () {
teaweb.successRefresh("保存成功")
}
})
}
this.deleteUserInstance = function (userInstanceId) {
let that = this
teaweb.confirm("确定要删除此实例吗?", function () {
that.$post(".delete")
.params({
userInstanceId: userInstanceId
})
.success(function () {
teaweb.successRefresh("删除成功")
})
})
}
})

View File

@@ -0,0 +1,62 @@
{$layout}
<!-- 步骤 -->
<div class="ui steps fluid">
<div class="step active">
<a href="/anti-ddos/instances">选择要续费的实例</a>
</div>
<div class="step">
<strong>支付</strong>
</div>
</div>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="userInstanceId" :value="userInstance.id"/>
<input type="hidden" name="periodId" :value="selectedPeriodId"/>
<table class="ui table definition selectable">
<tr>
<td>高防产品</td>
<td>
<div v-if="userInstance.package.id > 0">{{userInstance.package.summary}}</div>
<span v-else class="red">已删除</span>
</td>
</tr>
<tr>
<td>高防IP</td>
<td>
<div v-if="userInstance.instance.id > 0">
<div v-for="ip in userInstance.instance.ipAddresses">{{ip}}</div>
</div>
<span v-else class="red">已删除</span>
</td>
</tr>
<tr>
<td>当前有效期</td>
<td>{{userInstance.dayTo}}
<p class="comment" v-if="userInstance.isExpired">
<span class="red">已过期,续费后新的有效期将会从今天({{userInstance.today}})开始。</span>
</p>
<p class="comment" v-else>续费后,将会在此基础上增加新的有效期。</p>
</td>
</tr>
<tr>
<td>新续有效期 *</td>
<td>
<div v-if="allPeriods.length > 0">
<a v-for="period in allPeriods" class="ui label basic" :class="{blue: period.id == selectedPeriodId}" @click.prevent="selectPeriod(period.id)">{{period.count}}{{period.unitName}}</a>
</div>
<span v-else class="red">没有可用的有效期</span>
</td>
</tr>
<tr>
<td>价格</td>
<td>
<span v-if="amount == 0" class="disabled">没有找到对应价格</span>
<span v-if="amount > 0">{{amount}}元</span>
<p class="comment">管理员操作时,此价格仅供展示,并不会从用户账户中扣款。</p>
</td>
</tr>
</table>
<button class="ui button primary" type="button" @click.prevent="goNext()" v-if="amount > 0">下一步</button>
</form>

View File

@@ -0,0 +1,29 @@
Tea.context(function () {
this.selectedPeriodId = 0
this.amount = -1
this.$delay(function () {
if (this.userInstance.periodId > 0) {
let that = this
if (this.allPeriods.$find(function (k, v) {
return that.userInstance.periodId == v.id
}) != null) {
this.selectPeriod(this.userInstance.periodId)
}
}
})
this.selectPeriod = function (periodId) {
this.selectedPeriodId = periodId
this.amount = this.prices.$find(function (k, v) {
return v.periodId == periodId
}).price
}
this.goNext = function () {
if (this.userInstance.id > 0 && this.selectedPeriodId > 0) {
window.location = "/anti-ddos/instances/renewConfirm?userInstanceId=" + this.userInstance.id + "&periodId=" + this.selectedPeriodId
}
}
})

View File

@@ -0,0 +1,37 @@
{$layout}
<!-- 步骤 -->
<div class="ui steps fluid">
<div class="step">
<a href="/anti-ddos/instances">选择要续费的实例</a>
</div>
<div class="step active">
<strong>支付</strong>
</div>
</div>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="userInstanceId" :value="userInstanceId"/>
<input type="hidden" name="periodId" :value="periodId"/>
<table class="ui table definition selectable">
<tr>
<td class="title">高防实例</td>
<td>[{{packageSummary}} / <span v-for="(ipAddr, index) in ipAddresses">{{ipAddr}}<span v-if="index != ipAddresses.length -1">,</span></span> / 当前有效期至{{dayTo}} / 新增{{periodName}}]</td>
</tr>
<tr>
<td>价格</td>
<td>¥{{amount}}元</td>
</tr>
<tr>
<td>支付方式</td>
<td>
<pay-method-selector></pay-method-selector>
</td>
</tr>
</table>
<submit-btn v-show="amount > 0">确定购买</submit-btn><span class="red" v-if="amount == 0">参数错误,请返回重新选择。</span> &nbsp; <a href="/anti-ddos/packages">上一步</a>
</form>

View File

@@ -0,0 +1,23 @@
Tea.context(function () {
this.goBack = function () {
window.history.back()
}
this.success = function (resp) {
if (resp.data.success) {
teaweb.success("实例续费成功", function () {
window.location = "/anti-ddos/instances"
})
return
}
if (resp.data.orderCode.length > 0) {
window.location = "/finance/pay?code=" + resp.data.orderCode + "&from=" + window.escape(window.location.toString()) + "&returnURL=/anti-ddos/instances"
}
}
this.methodCode = "@balance"
this.changePayMethod = function (methodCode) {
this.methodCode = methodCode
}
})

View File

@@ -0,0 +1,38 @@
{$layout "layout_popup"}
<h3>设置防护对象</h3>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="userInstanceId" :value="userInstance.id"/>
<table class="ui table selectable definition">
<tr>
<td class="title">高防产品</td>
<td>
<div v-if="userInstance.package.id > 0">{{userInstance.package.summary}}</div>
<span v-else class="red">已删除</span>
</td>
</tr>
<tr>
<td>高防IP</td>
<td>
<div v-if="userInstance.instance.id > 0">
<div v-for="ip in userInstance.instance.ipAddresses">{{ip}}</div>
</div>
<span v-else class="red">已删除</span>
</td>
</tr>
<tr>
<td>防护对象</td>
<td>
<div v-if="userInstance.isAvailable && userInstance.user.id > 0">
<ad-instance-objects-box :v-objects="userInstance.objects" :v-user-id="userInstance.user.id"></ad-instance-objects-box>
</div>
<span v-else class="red">实例已经失效,无法设置防护对象</span>
</td>
</tr>
</table>
<submit-btn v-show="userInstance.isAvailable && userInstance.user.id > 0"></submit-btn>
</form>

View File

@@ -0,0 +1,38 @@
{$layout}
<!-- 步骤 -->
<div class="ui steps fluid">
<div class="step">
<a href="/anti-ddos/packages">选择实例规格</a>
</div>
<div class="step active">
<strong>支付</strong>
</div>
</div>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="packageId" :value="packageId"/>
<input type="hidden" name="periodId" :value="periodId"/>
<input type="hidden" name="count" :value="count"/>
<table class="ui table definition selectable">
<tr>
<td class="title">高防实例</td>
<td>[{{packageSummary}} / {{periodName}}] x {{count}}</td>
</tr>
<tr>
<td>价格</td>
<td>¥{{amount}}元</td>
</tr>
<tr>
<td>支付方式</td>
<td>
<pay-method-selector></pay-method-selector>
</td>
</tr>
</table>
<submit-btn v-show="amount > 0">确定购买</submit-btn><span class="red" v-if="amount == 0">参数错误,请返回重新选择。</span> &nbsp; <a href="/anti-ddos/packages">上一步</a>
</form>

View File

@@ -0,0 +1,23 @@
Tea.context(function () {
this.goBack = function () {
window.history.back()
}
this.success = function (resp) {
if (resp.data.success) {
teaweb.success("实例购买成功", function () {
window.location = "/anti-ddos/instances"
})
return
}
if (resp.data.orderCode.length > 0) {
window.location = "/finance/pay?code=" + resp.data.orderCode + "&from=" + window.escape(window.location.toString()) + "&returnURL=/anti-ddos/instances"
}
}
this.methodCode = "@balance"
this.changePayMethod = function (methodCode) {
this.methodCode = methodCode
}
})

View File

@@ -0,0 +1,62 @@
{$layout}
<!-- 步骤 -->
<div class="ui steps fluid">
<div class="step active">
<a href="/anti-ddos/packages">选择实例规格</a>
</div>
<div class="step">支付</div>
</div>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<input type="hidden" name="packageId" :value="selectedPackageId"/>
<input type="hidden" name="periodId" :value="selectedPeriodId"/>
<table class="ui table definition selectable">
<tr>
<td class="title">选择线路 *</td>
<td>
<a v-for="network in allNetworks" class="ui label basic" :class="{blue: network.id == selectedNetworkId}" @click.prevent="selectNetwork(network.id)">{{network.name}}</a>
<p class="comment" v-for="network in allNetworks" v-if="network.id == selectedNetworkId && network.description.length > 0">{{network.name}}{{network.description}}</p>
</td>
</tr>
<tr>
<td>选择防护带宽 *</td>
<td>
<a v-for="protectionBandwidth in allProtectionBandwidthSizes" v-if="hasProtectionBandwidth(protectionBandwidth)" class="ui label basic" :class="{blue: protectionBandwidth == selectedProtectionBandwidth}" @click.prevent="selectProtectionBandwidth(protectionBandwidth)">{{protectionBandwidth}}</a>
</td>
</tr>
<tr>
<td>选择业务带宽 *</td>
<td>
<a v-for="serverBandwidth in allServerBandwidthSizes" v-if="hasServerBandwidth(serverBandwidth)" class="ui label basic" :class="{blue: serverBandwidth == selectedServerBandwidth}" @click.prevent="selectServerBandwidth(serverBandwidth)">{{serverBandwidth}}</a>
</td>
</tr>
<tr>
<td>选择有效期 *</td>
<td>
<a v-for="period in allPeriods" class="ui label basic" v-if="hasPeriod(period.id)" :class="{blue: period.id == selectedPeriodId}" @click.prevent="selectPeriod(period.id)">{{period.count}}{{period.unitName}}</a>
</td>
</tr>
<tr>
<td>选择实例数量 *</td>
<td>
<div class="ui input">
<select class="ui dropdown" name="count" v-model="count" @change="changeCount(this.count)">
<option v-for="i in max" :value="i">{{i}}</option>
</select>
</div>
</td>
</tr>
<tr>
<td>价格</td>
<td>
<span v-if="amount == 0" class="disabled">没有找到对应价格</span>
<span v-if="amount > 0">{{amount}}元</span>
</td>
</tr>
</table>
<button class="ui button primary" type="button" :class="{disabled: amount <= 0}" @click.prevent="goNext()">下一步</button>
</form>

View File

@@ -0,0 +1,219 @@
Tea.context(function () {
this.selectedNetworkId = 0
this.selectedProtectionBandwidth = ""
this.selectedServerBandwidth = ""
this.selectedPackageId = 0
this.selectedPeriodId = 0
this.amount = -1
this.max = 1
this.count = 1
this.selectedPrice = null
this.$delay(function () {
if (this.allNetworks.length > 0) {
this.selectNetwork(this.allNetworks[0].id)
}
})
this.selectNetwork = function (networkId) {
this.selectedNetworkId = networkId
this.selectedProtectionBandwidth = ""
this.selectedServerBandwidth = ""
this.selectedPeriodId = 0
this.amount = -1
// 选择第一个防护带宽
let that = this
let found = false
this.prices.sort(function (v1, v2) {
return that.compareBits(v1.protectionBandwidth, v2.protectionBandwidth)
}).forEach(function (v) {
if (!found && v.networkId == that.selectedNetworkId) {
that.selectProtectionBandwidth(v.protectionBandwidth)
found = true
}
})
}
this.selectProtectionBandwidth = function (protectionBandwidth) {
this.selectedProtectionBandwidth = protectionBandwidth
this.selectedServerBandwidth = ""
this.selectedPeriodId = 0
this.amount = -1
// 选择第一个业务带宽
let that = this
let found = false
this.prices.sort(function (v1, v2) {
return that.compareBits(v1.serverBandwidth, v2.serverBandwidth)
}).forEach(function (v) {
if (!found && v.networkId == that.selectedNetworkId && v.protectionBandwidth == protectionBandwidth) {
that.selectServerBandwidth(v.serverBandwidth)
found = true
}
})
}
this.selectServerBandwidth = function (serverBandwidth) {
this.selectedServerBandwidth = serverBandwidth
this.selectedPeriodId = 0
this.amount = -1
// 选择第一个有效期
let that = this
let found = false
this.prices.sort(function (v1, v2) {
let periodId1 = v1.periodId
let periodId2 = v2.periodId
return (that.toPeriodMonths(that.findPeriodWithId(periodId1)) > that.toPeriodMonths(that.findPeriodWithId(periodId2))) ? 1 : -1
}).forEach(function (v) {
if (!found && v.networkId == that.selectedNetworkId && v.protectionBandwidth == that.selectedProtectionBandwidth && v.serverBandwidth == serverBandwidth) {
that.selectPeriod(v.periodId)
found = true
}
})
}
this.selectPeriod = function (periodId) {
this.selectedPeriodId = periodId
let price = null
let found = false
let that = this
this.prices.forEach(function (v) {
if (!found && v.networkId == that.selectedNetworkId
&& v.protectionBandwidth == that.selectedProtectionBandwidth
&& v.serverBandwidth == that.selectedServerBandwidth
&& v.periodId == that.selectedPeriodId) {
price = v
found = true
}
})
if (price == null) {
teaweb.warn("数据错误,请刷新页面后重试,如果仍然没有恢复,请联系管理员。")
return
}
this.selectedPrice = price
this.selectedPackageId = price.packageId
this.count = 1
this.max = price.maxInstances
this.changeCount(this.count)
}
this.hasProtectionBandwidth = function (protectionBandwidth) {
if (this.prices == null) {
return
}
let found = false
let that = this
this.prices.forEach(function (v) {
if (v.networkId == that.selectedNetworkId && v.protectionBandwidth == protectionBandwidth) {
found = true
}
})
return found
}
this.hasServerBandwidth = function (serverBandwidth) {
if (this.prices == null) {
return
}
let found = false
let that = this
this.prices.forEach(function (v) {
if (v.networkId == that.selectedNetworkId
&& v.protectionBandwidth == that.selectedProtectionBandwidth
&& v.serverBandwidth == serverBandwidth) {
found = true
}
})
return found
}
this.hasPeriod = function (periodId) {
if (this.prices == null) {
return
}
let found = false
let that = this
this.prices.forEach(function (v) {
if (v.networkId == that.selectedNetworkId
&& v.protectionBandwidth == that.selectedProtectionBandwidth
&& v.serverBandwidth == that.selectedServerBandwidth
&& v.periodId == periodId) {
found = true
}
})
return found
}
this.changeCount = function () {
if (this.selectedPrice == null) {
this.amount = -1
return
}
this.amount = this.selectedPrice.price * this.count
// 从服务器获取最新价格
this.$post(".price")
.params({
packageId: this.selectedPackageId,
periodId: this.selectedPeriodId,
count: this.count
})
.success(function (resp) {
this.amount = resp.data.amount
})
}
this.goNext = function () {
if (this.selectedPackageId > 0 && this.selectedPeriodId > 0 && this.count > 0 && this.amount > 0) {
window.location = "/anti-ddos/packages/confirm?packageId=" + this.selectedPackageId + "&periodId=" + this.selectedPeriodId + "&count=" + this.count
}
}
this.toBits = function (b) {
let m = b.match(/^(\d+)(\w+)$/)
let n = parseInt(m[1])
switch (m[2]) {
case "bps":
return n
case "Kbps":
return n * 1024
case "Mbps":
return n * Math.pow(1024, 2)
case "Gbps":
return n * Math.pow(1024, 3)
case "Tbps":
return n * Math.pow(1024, 4)
case "Pbps":
return n * Math.pow(1024, 5)
}
return n
}
this.compareBits = function (b1, b2) {
return (this.toBits(b1) > this.toBits(b2)) ? 1 : -1
}
this.findPeriodWithId = function (periodId) {
return this.allPeriods.$find(function (k, v) {
return v.id == periodId
})
}
this.toPeriodMonths = function (period) {
switch (period.unit) {
case "year":
return period.count * 12
default:
return period.count
}
}
})