mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-04-11 02:05:26 +08:00
安全设置增加允许访问的国家地区、省份、是否局域网访问
This commit is contained in:
51
web/public/js/components/common/countries-selector.js
Normal file
51
web/public/js/components/common/countries-selector.js
Normal file
@@ -0,0 +1,51 @@
|
||||
Vue.component("countries-selector", {
|
||||
props: ["v-countries"],
|
||||
data: function () {
|
||||
let countries = this.vCountries
|
||||
if (countries == null) {
|
||||
countries = []
|
||||
}
|
||||
let countryIds = countries.$map(function (k, v) {
|
||||
return v.id
|
||||
})
|
||||
return {
|
||||
countries: countries,
|
||||
countryIds: countryIds
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add: function () {
|
||||
let countryStringIds = this.countryIds.map(function (v) {
|
||||
return v.toString()
|
||||
})
|
||||
let that = this
|
||||
teaweb.popup("/ui/selectCountriesPopup?countryIds=" + countryStringIds.join(","), {
|
||||
width: "48em",
|
||||
height: "23em",
|
||||
callback: function (resp) {
|
||||
that.countries = resp.data.countries
|
||||
that.change()
|
||||
}
|
||||
})
|
||||
},
|
||||
remove: function (index) {
|
||||
this.countries.$remove(index)
|
||||
this.change()
|
||||
},
|
||||
change: function () {
|
||||
this.countryIds = this.countries.$map(function (k, v) {
|
||||
return v.id
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" name="countryIdsJSON" :value="JSON.stringify(countryIds)"/>
|
||||
<div v-if="countries.length > 0" style="margin-bottom: 0.5em">
|
||||
<div v-for="(country, index) in countries" class="ui label tiny">{{country.name}} <a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove"></i></a></div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="ui button small" type="button" @click.prevent="add">+</button>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
51
web/public/js/components/common/provinces-selector.js
Normal file
51
web/public/js/components/common/provinces-selector.js
Normal file
@@ -0,0 +1,51 @@
|
||||
Vue.component("provinces-selector", {
|
||||
props: ["v-provinces"],
|
||||
data: function () {
|
||||
let provinces = this.vProvinces
|
||||
if (provinces == null) {
|
||||
provinces = []
|
||||
}
|
||||
let provinceIds = provinces.$map(function (k, v) {
|
||||
return v.id
|
||||
})
|
||||
return {
|
||||
provinces: provinces,
|
||||
provinceIds: provinceIds
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add: function () {
|
||||
let provinceStringIds = this.provinceIds.map(function (v) {
|
||||
return v.toString()
|
||||
})
|
||||
let that = this
|
||||
teaweb.popup("/ui/selectProvincesPopup?provinceIds=" + provinceStringIds.join(","), {
|
||||
width: "48em",
|
||||
height: "23em",
|
||||
callback: function (resp) {
|
||||
that.provinces = resp.data.provinces
|
||||
that.change()
|
||||
}
|
||||
})
|
||||
},
|
||||
remove: function (index) {
|
||||
this.provinces.$remove(index)
|
||||
this.change()
|
||||
},
|
||||
change: function () {
|
||||
this.provinceIds = this.provinces.$map(function (k, v) {
|
||||
return v.id
|
||||
})
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
<input type="hidden" name="provinceIdsJSON" :value="JSON.stringify(provinceIds)"/>
|
||||
<div v-if="provinces.length > 0" style="margin-bottom: 0.5em">
|
||||
<div v-for="(province, index) in provinces" class="ui label tiny">{{province.name}} <a href="" title="删除" @click.prevent="remove(index)"><i class="icon remove"></i></a></div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
<div>
|
||||
<button class="ui button small" type="button" @click.prevent="add">+</button>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
@@ -12,7 +12,7 @@
|
||||
{$TEA.VUE}
|
||||
{$echo "header"}
|
||||
<script type="text/javascript" src="/_/@default/@layout.js"></script>
|
||||
<script type="text/javascript" src="/ui/components.js?v=1.0.0"></script>
|
||||
<script type="text/javascript" src="/ui/components.js?v=v{$.teaVersion}"></script>
|
||||
<script type="text/javascript" src="/js/utils.js"></script>
|
||||
<script type="text/javascript" src="/js/sweetalert2/dist/sweetalert2.all.min.js"></script>
|
||||
<script type="text/javascript" src="/js/date.tea.js"></script>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="/_/@default/@layout_override.css" media="all"/>
|
||||
{$echo "header"}
|
||||
<script type="text/javascript" src="/_/@default/@layout.js"></script>
|
||||
<script type="text/javascript" src="/ui/components.js"></script>
|
||||
<script type="text/javascript" src="/ui/components.js?v=v{$.teaVersion}"></script>
|
||||
<script type="text/javascript" src="/js/utils.js"></script>
|
||||
<script type="text/javascript" src="/js/sweetalert2/dist/sweetalert2.all.min.js"></script>
|
||||
<script type="text/javascript" src="/js/date.tea.js"></script>
|
||||
|
||||
@@ -15,6 +15,27 @@
|
||||
<p class="comment">当前服务被别的网页框架嵌套的条件限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>允许访问的国家和地区</td>
|
||||
<td>
|
||||
<countries-selector :v-countries="countries"></countries-selector>
|
||||
<p class="comment">设置后,只有这些国家和地区才能访问管理界面,如果不设置表示没有限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>允许访问的省份(中国)</td>
|
||||
<td>
|
||||
<provinces-selector :v-provinces="provinces"></provinces-selector>
|
||||
<p class="comment">设置后,只有这些省份才能访问管理界面,如果不设置表示没有限制。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>允许局域网访问</td>
|
||||
<td>
|
||||
<checkbox name="allowLocal" v-model="config.allowLocal"></checkbox>
|
||||
<p class="comment">选中表示允许在本机和局域网访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
16
web/views/@default/ui/selectCountriesPopup.css
Normal file
16
web/views/@default/ui/selectCountriesPopup.css
Normal file
@@ -0,0 +1,16 @@
|
||||
.region-letter-group .item {
|
||||
padding-left: 1em !important;
|
||||
padding-right: 1em !important;
|
||||
}
|
||||
.country-group {
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
.country-group .country-list .item {
|
||||
float: left;
|
||||
width: 12em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.country-group .country-list .item .checkbox label {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
/*# sourceMappingURL=selectCountriesPopup.css.map */
|
||||
1
web/views/@default/ui/selectCountriesPopup.css.map
Normal file
1
web/views/@default/ui/selectCountriesPopup.css.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["selectCountriesPopup.less"],"names":[],"mappings":"AAAA,oBACC;EACC,4BAAA;EACA,6BAAA;;AAIF;EAaC,mBAAA;;AAbD,cACC,cACC;EACC,WAAA;EACA,WAAA;EACA,oBAAA;;AALH,cACC,cACC,MAKC,UAAU;EACT,0BAAA","file":"selectCountriesPopup.css"}
|
||||
27
web/views/@default/ui/selectCountriesPopup.html
Normal file
27
web/views/@default/ui/selectCountriesPopup.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>选择国家和地区</h3>
|
||||
<form method="post" data-tea-success="success" data-tea-action="$" class="ui form">
|
||||
<csrf-token></csrf-token>
|
||||
<table class="ui table selectable">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="ui menu tabular tiny region-letter-group">
|
||||
<a href="" v-for="group in letterGroups" class="item" :class="{active: group == selectedGroup}" @click.prevent="selectGroup(group)">{{group}}</a>
|
||||
</div>
|
||||
<div v-for="group in letterGroups">
|
||||
<div v-for="letter in group" v-show="letterCountries[letter] != null && group == selectedGroup" class="country-group">
|
||||
<h4>{{letter}}</h4>
|
||||
<div class="country-list">
|
||||
<div class="item" v-for="country in letterCountries[letter]">
|
||||
<checkbox name="countryIds" :v-value="country.id" v-model="country.isChecked">{{country.name}}</checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
21
web/views/@default/ui/selectCountriesPopup.js
Normal file
21
web/views/@default/ui/selectCountriesPopup.js
Normal file
@@ -0,0 +1,21 @@
|
||||
Tea.context(function () {
|
||||
this.letterGroups = [
|
||||
"ABC", "DEF", "GHI", "JKL", "MNO", "PQR", "STU", "VWX", "YZ"
|
||||
];
|
||||
this.selectedGroup = "ABC"
|
||||
this.letterCountries = {}
|
||||
let that = this
|
||||
this.countries.forEach(function (country) {
|
||||
if (typeof (that.letterCountries[country.letter]) == "undefined") {
|
||||
that.letterCountries[country.letter] = []
|
||||
}
|
||||
that.letterCountries[country.letter].push(country)
|
||||
})
|
||||
this.isCheckingAll = false
|
||||
|
||||
this.selectGroup = function (group) {
|
||||
this.selectedGroup = group
|
||||
}
|
||||
|
||||
this.success = NotifyPopup
|
||||
})
|
||||
22
web/views/@default/ui/selectCountriesPopup.less
Normal file
22
web/views/@default/ui/selectCountriesPopup.less
Normal file
@@ -0,0 +1,22 @@
|
||||
.region-letter-group {
|
||||
.item {
|
||||
padding-left: 1em !important;
|
||||
padding-right: 1em !important;
|
||||
}
|
||||
}
|
||||
|
||||
.country-group {
|
||||
.country-list {
|
||||
.item {
|
||||
float: left;
|
||||
width: 12em;
|
||||
margin-bottom: 0.5em;
|
||||
|
||||
.checkbox label {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
padding-bottom: 1em;
|
||||
}
|
||||
9
web/views/@default/ui/selectProvincesPopup.css
Normal file
9
web/views/@default/ui/selectProvincesPopup.css
Normal file
@@ -0,0 +1,9 @@
|
||||
.province-list .item {
|
||||
float: left;
|
||||
width: 12em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
.province-list .item .checkbox label {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
/*# sourceMappingURL=selectProvincesPopup.css.map */
|
||||
1
web/views/@default/ui/selectProvincesPopup.css.map
Normal file
1
web/views/@default/ui/selectProvincesPopup.css.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["selectProvincesPopup.less"],"names":[],"mappings":"AAAA,cACC;EACC,WAAA;EACA,WAAA;EACA,oBAAA;;AAJF,cACC,MAKC,UAAU;EACT,0BAAA","file":"selectProvincesPopup.css"}
|
||||
19
web/views/@default/ui/selectProvincesPopup.html
Normal file
19
web/views/@default/ui/selectProvincesPopup.html
Normal file
@@ -0,0 +1,19 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>选择省份</h3>
|
||||
|
||||
<form method="post" class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<table class="ui table selectable">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="province-list">
|
||||
<div class="item" v-for="province in provinces">
|
||||
<checkbox name="provinceIds" :v-value="province.id" v-model="province.isChecked">{{province.name}}</checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
3
web/views/@default/ui/selectProvincesPopup.js
Normal file
3
web/views/@default/ui/selectProvincesPopup.js
Normal file
@@ -0,0 +1,3 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyPopup
|
||||
})
|
||||
11
web/views/@default/ui/selectProvincesPopup.less
Normal file
11
web/views/@default/ui/selectProvincesPopup.less
Normal file
@@ -0,0 +1,11 @@
|
||||
.province-list {
|
||||
.item {
|
||||
float: left;
|
||||
width: 12em;
|
||||
margin-bottom: 0.5em;
|
||||
|
||||
.checkbox label {
|
||||
font-size: 12px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user