将带宽限制改为流量限制

This commit is contained in:
GoEdgeLab
2021-11-09 17:36:38 +08:00
parent 63a09bb5a6
commit 55cefdb62c
7 changed files with 42 additions and 42 deletions

View File

@@ -351,10 +351,10 @@ func (this *ServerHelper) createSettingsMenu(secondMenuItem string, serverIdStri
if teaconst.IsPlus { if teaconst.IsPlus {
menuItems = append(menuItems, maps.Map{ menuItems = append(menuItems, maps.Map{
"name": "带宽限制", "name": "流量限制",
"url": "/servers/server/settings/bandwidth?serverId=" + serverIdString, "url": "/servers/server/settings/traffic?serverId=" + serverIdString,
"isActive": secondMenuItem == "bandwidth", "isActive": secondMenuItem == "traffic",
"isOn": serverConfig.BandwidthLimit != nil && serverConfig.BandwidthLimit.IsOn, "isOn": serverConfig.TrafficLimit != nil && serverConfig.TrafficLimit.IsOn,
}) })
} }
} else if serverConfig.IsTCPFamily() { } else if serverConfig.IsTCPFamily() {

View File

@@ -1,6 +1,6 @@
// 套餐价格配置 // 套餐价格配置
Vue.component("plan-price-config-box", { Vue.component("plan-price-config-box", {
props: ["v-price-type", "v-monthly-price", "v-seasonally-price", "v-yearly-price", "v-bandwidth-price"], props: ["v-price-type", "v-monthly-price", "v-seasonally-price", "v-yearly-price", "v-traffic-price"],
data: function () { data: function () {
let priceType = this.vPriceType let priceType = this.vPriceType
if (priceType == null) { if (priceType == null) {
@@ -43,18 +43,18 @@ Vue.component("plan-price-config-box", {
} }
} }
let bandwidthPrice = this.vBandwidthPrice let trafficPrice = this.vTrafficPrice
let bandwidthPriceBaseNumber = 0 let trafficPriceBaseNumber = 0
if (bandwidthPrice != null) { if (trafficPrice != null) {
bandwidthPriceBaseNumber = bandwidthPrice.base trafficPriceBaseNumber = trafficPrice.base
} else { } else {
bandwidthPrice = { trafficPrice = {
base: 0 base: 0
} }
} }
let bandwidthPriceBase = "" let trafficPriceBase = ""
if (bandwidthPriceBaseNumber > 0) { if (trafficPriceBaseNumber > 0) {
bandwidthPriceBase = bandwidthPriceBaseNumber.toString() trafficPriceBase = trafficPriceBaseNumber.toString()
} }
return { return {
@@ -67,8 +67,8 @@ Vue.component("plan-price-config-box", {
seasonallyPriceNumber: seasonallyPriceNumber, seasonallyPriceNumber: seasonallyPriceNumber,
yearlyPriceNumber: yearlyPriceNumber, yearlyPriceNumber: yearlyPriceNumber,
bandwidthPriceBase: bandwidthPriceBase, trafficPriceBase: trafficPriceBase,
bandwidthPrice: bandwidthPrice trafficPrice: trafficPrice
} }
}, },
watch: { watch: {
@@ -93,12 +93,12 @@ Vue.component("plan-price-config-box", {
} }
this.yearlyPriceNumber = price this.yearlyPriceNumber = price
}, },
bandwidthPriceBase: function (v) { trafficPriceBase: function (v) {
let price = parseFloat(v) let price = parseFloat(v)
if (isNaN(price)) { if (isNaN(price)) {
price = 0 price = 0
} }
this.bandwidthPrice.base = price this.trafficPrice.base = price
} }
}, },
template: `<div> template: `<div>
@@ -106,11 +106,11 @@ Vue.component("plan-price-config-box", {
<input type="hidden" name="monthlyPrice" :value="monthlyPriceNumber"/> <input type="hidden" name="monthlyPrice" :value="monthlyPriceNumber"/>
<input type="hidden" name="seasonallyPrice" :value="seasonallyPriceNumber"/> <input type="hidden" name="seasonallyPrice" :value="seasonallyPriceNumber"/>
<input type="hidden" name="yearlyPrice" :value="yearlyPriceNumber"/> <input type="hidden" name="yearlyPrice" :value="yearlyPriceNumber"/>
<input type="hidden" name="bandwidthPriceJSON" :value="JSON.stringify(bandwidthPrice)"/> <input type="hidden" name="trafficPriceJSON" :value="JSON.stringify(trafficPrice)"/>
<div> <div>
<radio :v-value="'period'" :value="priceType" v-model="priceType">&nbsp;按时间周期</radio> &nbsp; &nbsp; <radio :v-value="'period'" :value="priceType" v-model="priceType">&nbsp;按时间周期</radio> &nbsp; &nbsp;
<radio :v-value="'bandwidth'" :value="priceType" v-model="priceType">&nbsp;按带宽用量</radio> <radio :v-value="'traffic'" :value="priceType" v-model="priceType">&nbsp;按量</radio>
</div> </div>
<!-- 按时间周期 --> <!-- 按时间周期 -->
@@ -147,15 +147,15 @@ Vue.component("plan-price-config-box", {
</table> </table>
</div> </div>
<!-- 按带宽 --> <!-- 按流量 -->
<div v-show="priceType =='bandwidth'"> <div v-show="priceType =='traffic'">
<div class="ui divider"></div> <div class="ui divider"></div>
<table class="ui table"> <table class="ui table">
<tr> <tr>
<td class="title">基础带宽费用</td> <td class="title">基础流量费用</td>
<td> <td>
<div class="ui input right labeled"> <div class="ui input right labeled">
<input type="text" v-model="bandwidthPriceBase" maxlength="10" style="width: 7em"/> <input type="text" v-model="trafficPriceBase" maxlength="10" style="width: 7em"/>
<span class="ui label">元/GB</span> <span class="ui label">元/GB</span>
</div> </div>
</td> </td>

View File

@@ -11,8 +11,8 @@ Vue.component("plan-price-view", {
<span v-if="plan.seasonallyPrice > 0">季度:¥{{plan.seasonallyPrice}}元<br/></span> <span v-if="plan.seasonallyPrice > 0">季度:¥{{plan.seasonallyPrice}}元<br/></span>
<span v-if="plan.yearlyPrice > 0">年度:¥{{plan.yearlyPrice}}元</span> <span v-if="plan.yearlyPrice > 0">年度:¥{{plan.yearlyPrice}}元</span>
</span> </span>
<span v-if="plan.priceType == 'bandwidth'"> <span v-if="plan.priceType == 'traffic'">
基础价格:¥{{plan.bandwidthPrice.base}}元/GB 基础价格:¥{{plan.trafficPrice.base}}元/GB
</span> </span>
</div>` </div>`
}) })

View File

@@ -1,7 +1,7 @@
Vue.component("bandwidth-limit-config-box", { Vue.component("traffic-limit-config-box", {
props: ["v-bandwidth-limit"], props: ["v-traffic-limit"],
data: function () { data: function () {
let config = this.vBandwidthLimit let config = this.vTrafficLimit
if (config == null) { if (config == null) {
config = { config = {
isOn: false, isOn: false,
@@ -47,36 +47,36 @@ Vue.component("bandwidth-limit-config-box", {
this.config.noticePageBody = `<!DOCTYPE html> this.config.noticePageBody = `<!DOCTYPE html>
<html> <html>
<head> <head>
<title>Bandwidth Limit Exceeded Warning</title> <title>Traffic Limit Exceeded Warning</title>
<body> <body>
The site bandwidth has exceeded the limit. Please contact with the site administrator. The site traffic has exceeded the limit. Please contact with the site administrator.
</body> </body>
</html>` </html>`
} }
}, },
template: `<div> template: `<div>
<input type="hidden" name="bandwidthLimitJSON" :value="JSON.stringify(config)"/> <input type="hidden" name="trafficLimitJSON" :value="JSON.stringify(config)"/>
<table class="ui table selectable definition"> <table class="ui table selectable definition">
<tbody> <tbody>
<tr> <tr>
<td class="title">是否启用</td> <td class="title">是否启用</td>
<td> <td>
<checkbox v-model="config.isOn"></checkbox> <checkbox v-model="config.isOn"></checkbox>
<p class="comment">注意由于带宽统计是每5分钟统计一次所以超出带宽限制后对用户的提醒也会有所延迟</p> <p class="comment">注意由于流量统计是每5分钟统计一次所以超出流量限制后对用户的提醒也会有所延迟</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody v-show="config.isOn"> <tbody v-show="config.isOn">
<tr> <tr>
<td>带宽限制</td> <td>流量限制</td>
<td> <td>
<size-capacity-box :v-value="config.dailySize"></size-capacity-box> <size-capacity-box :v-value="config.dailySize"></size-capacity-box>
</td> </td>
</tr> </tr>
<tr> <tr>
<td>带宽限制</td> <td>流量限制</td>
<td> <td>
<size-capacity-box :v-value="config.monthlySize"></size-capacity-box> <size-capacity-box :v-value="config.monthlySize"></size-capacity-box>
</td> </td>
@@ -92,7 +92,7 @@ The site bandwidth has exceeded the limit. Please contact with the site administ
<td>网页提示内容</td> <td>网页提示内容</td>
<td> <td>
<textarea v-model="config.noticePageBody"></textarea> <textarea v-model="config.noticePageBody"></textarea>
<p class="comment"><a href="" @click.prevent="showBodyTemplate">[使用模板]</a>HTML</p> <p class="comment"><a href="" @click.prevent="showBodyTemplate">[使用模板]</a>HTML</p>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -1,15 +1,15 @@
// 显示带宽限制说明 // 显示流量限制说明
Vue.component("bandwidth-limit-view", { Vue.component("traffic-limit-view", {
props: ["v-bandwidth-limit"], props: ["v-traffic-limit"],
data: function () { data: function () {
return { return {
config: this.vBandwidthLimit config: this.vTrafficLimit
} }
}, },
template: `<div> template: `<div>
<div v-if="config.isOn"> <div v-if="config.isOn">
<span v-if="config.dailySize != null && config.dailySize.count > 0">带宽限制{{config.dailySize.count}}{{config.dailySize.unit.toUpperCase()}}<br/></span> <span v-if="config.dailySize != null && config.dailySize.count > 0">流量限制{{config.dailySize.count}}{{config.dailySize.unit.toUpperCase()}}<br/></span>
<span v-if="config.monthlySize != null && config.monthlySize.count > 0">带宽限制{{config.monthlySize.count}}{{config.monthlySize.unit.toUpperCase()}}<br/></span> <span v-if="config.monthlySize != null && config.monthlySize.count > 0">流量限制{{config.monthlySize.count}}{{config.monthlySize.unit.toUpperCase()}}<br/></span>
</div> </div>
<span v-else class="disabled">没有限制</span> <span v-else class="disabled">没有限制</span>
</div>` </div>`

View File

@@ -6,7 +6,7 @@
<input type="hidden" name="serverId" :value="serverId"/> <input type="hidden" name="serverId" :value="serverId"/>
<csrf-token></csrf-token> <csrf-token></csrf-token>
<bandwidth-limit-config-box :v-bandwidth-limit="bandwidthLimitConfig"></bandwidth-limit-config-box> <traffic-limit-config-box :v-traffic-limit="trafficLimitConfig"></traffic-limit-config-box>
<submit-btn></submit-btn> <submit-btn></submit-btn>
</form> </form>