Compare commits

..

No commits in common. "da6b89fdcd2270aa116297d9ff620b6331f39df9" and "ed2a0a0bcf99d1636b8ae7c1689d348d78b334c1" have entirely different histories.

2 changed files with 79 additions and 89 deletions

View file

@ -466,83 +466,71 @@
</g> </g>
</svg> </svg>
</div> </div>
<a-row type="flex" justify="center" align="middle" <a-row type="flex" justify="center" align="middle" :style="{ height: '100%', overflow: 'auto', overflowX: 'hidden' }">
:style="{ height: '100%', overflow: 'auto', overflowX: 'hidden' }">
<a-col :xs="22" :sm="12" :md="10" :lg="8" :xl="6" :xxl="5" id="login" :style="{ margin: '3rem 0' }"> <a-col :xs="22" :sm="12" :md="10" :lg="8" :xl="6" :xxl="5" id="login" :style="{ margin: '3rem 0' }">
<template v-if="!loadingStates.fetched"> <div class="setting-section">
<div :style="{ textAlign: 'center' }"> <a-popover :overlay-class-name="themeSwitcher.currentTheme" title='{{ i18n "menu.settings" }}' placement="bottomRight" trigger="click">
<a-spin size="large" /> <template slot="content">
</div> <a-space direction="vertical" :size="10">
</template> <a-theme-switch-login></a-theme-switch-login>
<template v-else> <span>{{ i18n "pages.settings.language" }}</span>
<div class="setting-section"> <a-select ref="selectLang" :style="{ width: '100%' }" v-model="lang" @change="LanguageManager.setLanguage(lang)" :dropdown-class-name="themeSwitcher.currentTheme">
<a-popover :overlay-class-name="themeSwitcher.currentTheme" title='{{ i18n "menu.settings" }}' <a-select-option :value="l.value" label="English" v-for="l in LanguageManager.supportedLanguages">
placement="bottomRight" trigger="click"> <span role="img" aria-label="l.name" v-text="l.icon"></span>
<template slot="content"> &nbsp;&nbsp;<span v-text="l.name"></span>
<a-space direction="vertical" :size="10"> </a-select-option>
<a-theme-switch-login></a-theme-switch-login> </a-select>
<span>{{ i18n "pages.settings.language" }}</span> </a-space>
<a-select ref="selectLang" :style="{ width: '100%' }" v-model="lang" </template>
@change="LanguageManager.setLanguage(lang)" :dropdown-class-name="themeSwitcher.currentTheme"> <a-button shape="circle" icon="setting"></a-button>
<a-select-option :value="l.value" label="English" v-for="l in LanguageManager.supportedLanguages"> </a-popover>
<span role="img" aria-label="l.name" v-text="l.icon"></span> </div>
&nbsp;&nbsp;<span v-text="l.name"></span> <a-row type="flex" justify="center">
</a-select-option> <a-col :style="{ width: '100%' }">
</a-select> <h2 class="title headline zoom">
</a-space> <span class="words-wrapper">
</template> <b class="is-visible">{{ i18n "pages.login.hello" }}</b>
<a-button shape="circle" icon="setting"></a-button> <b>{{ i18n "pages.login.title" }}</b>
</a-popover> </span>
</div> </h2>
<a-row type="flex" justify="center"> </a-col>
<a-col :style="{ width: '100%' }"> </a-row>
<h2 class="title headline zoom"> <a-row type="flex" justify="center">
<span class="words-wrapper"> <a-col span="24">
<b class="is-visible">{{ i18n "pages.login.hello" }}</b> <a-form>
<b>{{ i18n "pages.login.title" }}</b> <a-space direction="vertical" size="middle">
</span> <a-form-item>
</h2> <a-input autocomplete="username" name="username" v-model.trim="user.username"
</a-col> placeholder='{{ i18n "username" }}' @keydown.enter.native="login" autofocus>
</a-row> <a-icon slot="prefix" type="user" :style="{ fontSize: '1rem' }"></a-icon>
<a-row type="flex" justify="center"> </a-input>
<a-col span="24"> </a-form-item>
<a-form @submit.prevent="login"> <a-form-item>
<a-space direction="vertical" size="middle"> <a-input-password autocomplete="password" name="password" v-model.trim="user.password"
<a-form-item> placeholder='{{ i18n "password" }}' @keydown.enter.native="login">
<a-input autocomplete="username" name="username" v-model.trim="user.username" <a-icon slot="prefix" type="lock" :style="{ fontSize: '1rem' }"></a-icon>
placeholder='{{ i18n "username" }}' autofocus required> </a-input-password>
<a-icon slot="prefix" type="user" :style="{ fontSize: '1rem' }"></a-icon> </a-form-item>
</a-input> <a-form-item v-if="twoFactorEnable">
</a-form-item> <a-input autocomplete="one-time-code" name="twoFactorCode" v-model.trim="user.twoFactorCode"
<a-form-item> placeholder='{{ i18n "twoFactorCode" }}' @keydown.enter.native="login">
<a-input-password autocomplete="password" name="password" v-model.trim="user.password" <a-icon slot="prefix" type="key" :style="{ fontSize: '1rem' }"></a-icon>
placeholder='{{ i18n "password" }}' required> </a-input>
<a-icon slot="prefix" type="lock" :style="{ fontSize: '1rem' }"></a-icon> </a-form-item>
</a-input-password> <a-form-item>
</a-form-item> <a-row justify="center" class="centered">
<a-form-item v-if="twoFactorEnable"> <div :style="{ height: '50px', marginTop: '1rem', ...loading ? { width: '52px' } : { display: 'inline-block' } }" class="wave-btn-bg wave-btn-bg-cl">
<a-input autocomplete="one-time-code" name="twoFactorCode" v-model.trim="user.twoFactorCode" <a-button class="ant-btn-primary-login" type="primary" :loading="loading" @click="login"
placeholder='{{ i18n "twoFactorCode" }}' required> :icon="loading ? 'poweroff' : undefined">
<a-icon slot="prefix" type="key" :style="{ fontSize: '1rem' }"></a-icon> [[ loading ? '' : '{{ i18n "login" }}' ]]
</a-input> </a-button>
</a-form-item> </div>
<a-form-item> </a-row>
<a-row justify="center" class="centered"> </a-form-item>
<div </a-space>
:style="{ height: '50px', marginTop: '1rem', ...loadingStates.spinning ? { width: '52px' } : { display: 'inline-block' } }" </a-form>
class="wave-btn-bg wave-btn-bg-cl"> </a-col>
<a-button class="ant-btn-primary-login" type="primary" :loading="loadingStates.spinning" </a-row>
:icon="loadingStates.spinning ? 'poweroff' : undefined" html-type="submit">
[[ loadingStates.spinning ? '' : '{{ i18n "login" }}' ]]
</a-button>
</div>
</a-row>
</a-form-item>
</a-space>
</a-form>
</a-col>
</a-row>
</template>
</a-col> </a-col>
</a-row> </a-row>
</a-layout-content> </a-layout-content>
@ -556,10 +544,7 @@
el: '#app', el: '#app',
data: { data: {
themeSwitcher, themeSwitcher,
loadingStates: { loading: false,
fetched: false,
spinning: false
},
user: { user: {
username: "", username: "",
password: "", password: "",
@ -574,23 +559,19 @@
}, },
methods: { methods: {
async login() { async login() {
this.loadingStates.spinning = true; this.loading = true;
const msg = await HttpUtil.post('/login', this.user); const msg = await HttpUtil.post('/login', this.user);
this.loading = false;
if (msg.success) { if (msg.success) {
location.href = basePath + 'panel/'; location.href = basePath + 'panel/';
} }
this.loadingStates.spinning = false;
}, },
async getTwoFactorEnable() { async getTwoFactorEnable() {
this.loading = true;
const msg = await HttpUtil.post('/getTwoFactorEnable'); const msg = await HttpUtil.post('/getTwoFactorEnable');
this.loading = false;
if (msg.success) { if (msg.success) {
this.twoFactorEnable = msg.obj; this.twoFactorEnable = msg.obj;
this.loadingStates.fetched = true;
return msg.obj; return msg.obj;
} }
}, },

View file

@ -1,6 +1,11 @@
{{define "modals/ruleModal"}} {{define "modals/ruleModal"}}
<a-modal id="rule-modal" v-model="ruleModal.visible" :title="ruleModal.title" @ok="ruleModal.ok" :confirm-loading="ruleModal.confirmLoading" :closable="true" :mask-closable="false" :ok-text="ruleModal.okText" cancel-text='{{ i18n "close" }}' :class="themeSwitcher.currentTheme"> <a-modal id="rule-modal" v-model="ruleModal.visible" :title="ruleModal.title" @ok="ruleModal.ok" :confirm-loading="ruleModal.confirmLoading" :closable="true" :mask-closable="false" :ok-text="ruleModal.okText" cancel-text='{{ i18n "close" }}' :class="themeSwitcher.currentTheme">
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }"> <a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
<a-form-item label='Domain Matcher'>
<a-select v-model="ruleModal.rule.domainMatcher" :dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option v-for="dm in ['','hybrid','linear']" :value="dm">[[ dm ]]</a-select-option>
</a-select>
</a-form-item>
<a-form-item> <a-form-item>
<template slot="label"> <template slot="label">
<a-tooltip> <a-tooltip>
@ -118,6 +123,7 @@
confirm: null, confirm: null,
rule: { rule: {
type: "field", type: "field",
domainMatcher: "",
domain: "", domain: "",
ip: "", ip: "",
port: "", port: "",
@ -151,6 +157,7 @@
this.confirm = confirm; this.confirm = confirm;
this.visible = true; this.visible = true;
if (isEdit) { if (isEdit) {
this.rule.domainMatcher = rule.domainMatcher;
this.rule.domain = rule.domain ? rule.domain.join(',') : []; this.rule.domain = rule.domain ? rule.domain.join(',') : [];
this.rule.ip = rule.ip ? rule.ip.join(',') : []; this.rule.ip = rule.ip ? rule.ip.join(',') : [];
this.rule.port = rule.port; this.rule.port = rule.port;
@ -165,6 +172,7 @@
this.rule.balancerTag = rule.balancerTag ? rule.balancerTag : ""; this.rule.balancerTag = rule.balancerTag ? rule.balancerTag : "";
} else { } else {
this.rule = { this.rule = {
domainMatcher: "",
domain: "", domain: "",
ip: "", ip: "",
port: "", port: "",
@ -206,6 +214,7 @@
rule = {}; rule = {};
newRule = {}; newRule = {};
rule.type = "field"; rule.type = "field";
rule.domainMatcher = value.domainMatcher;
rule.domain = value.domain.length > 0 ? value.domain.split(',') : []; rule.domain = value.domain.length > 0 ? value.domain.split(',') : [];
rule.ip = value.ip.length > 0 ? value.ip.split(',') : []; rule.ip = value.ip.length > 0 ? value.ip.split(',') : [];
rule.port = value.port; rule.port = value.port;