mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 14:27:01 +08:00
support frp>=v0.52.0
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
window.clientConfig = {};
|
||||
window.i18n = {};
|
||||
(function ($) {
|
||||
$(function () {
|
||||
function init() {
|
||||
var langLoading = layui.layer.load()
|
||||
$.getJSON('/lang.json').done(function (lang) {
|
||||
window.i18n = lang;
|
||||
$.ajaxSetup({
|
||||
error: function (xhr,) {
|
||||
if (xhr.status === 401) {
|
||||
@@ -18,13 +20,13 @@ window.clientConfig = {};
|
||||
var id = elem.attr('id');
|
||||
var title = elem.text();
|
||||
if (id === 'clientInfo') {
|
||||
loadClientInfo(lang, title.trim());
|
||||
loadClientInfo(title.trim());
|
||||
} else if (id === 'overview') {
|
||||
loadOverview(lang, title.trim());
|
||||
loadOverview(title.trim());
|
||||
} else if (elem.closest('.layui-nav-item').attr('id') === 'proxies') {
|
||||
if (id != null && id.trim() !== '') {
|
||||
var suffix = elem.closest('.layui-nav-item').children('a').text().trim();
|
||||
loadProxyInfo(lang, title + " " + suffix, id);
|
||||
loadProxyInfo(title + " " + suffix, id);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -35,6 +37,45 @@ window.clientConfig = {};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* add verify rule to layui.form
|
||||
*/
|
||||
function initFormVerifyRule() {
|
||||
layui.form.verify({
|
||||
proxyName: function (value, elem) {
|
||||
if (value.trim() === '') {
|
||||
var nameI18n = $('#proxyName').closest('.layui-form-item').children('.layui-form-label').text();
|
||||
return nameI18n + i18n['RequireNotEmpty'];
|
||||
}
|
||||
},
|
||||
localPort: function (value, elem) {
|
||||
if (value !== '' && !/^\d+$/.test(value)) {
|
||||
var nameI18n = $('#localPort').closest('.layui-form-item').children('.layui-form-label').text();
|
||||
return nameI18n + i18n['RequireNumber'];
|
||||
}
|
||||
},
|
||||
domain: function (value, elem) {
|
||||
var proxyType = $('#proxyType').val().toLowerCase();
|
||||
var $customDomains = $('#customDomains');
|
||||
var customDomains = $customDomains.val();
|
||||
var $subdomain = $('#subdomain');
|
||||
var subdomain = $subdomain.val();
|
||||
if (proxyType === 'http' || proxyType === 'https') {
|
||||
if (customDomains.trim() === '' && subdomain.trim() === '') {
|
||||
var customDomainsNameI18n = $customDomains.closest('.layui-form-item').children('.layui-form-label').text();
|
||||
var subdomainNameI18n = $subdomain.closest('.layui-form-item').children('.layui-form-label').text();
|
||||
return customDomainsNameI18n + i18n['and'] + subdomainNameI18n + i18n['RequireNotAllEmpty'];
|
||||
} else if (customDomains.trim() !== '') {
|
||||
var nameI18n = $customDomains.closest('.layui-form-item').children('.layui-form-label').text();
|
||||
if (!/^\s*\[.*]\s*$/.test(customDomains)) {
|
||||
return nameI18n + i18n['RequireArray'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function logout() {
|
||||
$.get("/logout", function (result) {
|
||||
window.location.reload();
|
||||
@@ -46,5 +87,6 @@ window.clientConfig = {};
|
||||
});
|
||||
|
||||
init();
|
||||
initFormVerifyRule();
|
||||
});
|
||||
})(layui.$);
|
||||
Reference in New Issue
Block a user