2023-02-09 19:18:06 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
{{template "head" .}}
|
|
|
|
<style>
|
|
|
|
|
|
|
|
#app {
|
|
|
|
padding-top: 100px;
|
|
|
|
}
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
text-align: center;
|
|
|
|
color: #fff;
|
|
|
|
margin: 20px 0 50px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ant-btn, .ant-input {
|
|
|
|
height: 50px;
|
|
|
|
border-radius: 30px;
|
|
|
|
}
|
|
|
|
|
2023-05-08 14:50:13 +00:00
|
|
|
.ant-input-group-addon {
|
|
|
|
border-radius: 0 30px 30px 0;
|
|
|
|
width: 50px;
|
|
|
|
font-size: 18px;
|
|
|
|
}
|
|
|
|
|
2023-02-09 19:18:06 +00:00
|
|
|
.ant-input-affix-wrapper .ant-input-prefix {
|
|
|
|
left: 23px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ant-input-affix-wrapper .ant-input:not(:first-child) {
|
|
|
|
padding-left: 50px;
|
|
|
|
}
|
|
|
|
|
2023-05-08 14:50:13 +00:00
|
|
|
.centered {
|
2023-02-09 19:18:06 +00:00
|
|
|
display: flex;
|
|
|
|
text-align: center;
|
2023-05-08 14:50:13 +00:00
|
|
|
align-items: center;
|
2023-02-09 19:18:06 +00:00
|
|
|
justify-content: center;
|
|
|
|
}
|
|
|
|
|
2023-05-08 14:50:13 +00:00
|
|
|
.title {
|
|
|
|
font-size: 32px;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
2023-02-09 19:18:06 +00:00
|
|
|
</style>
|
|
|
|
<body>
|
2023-05-12 20:22:12 +00:00
|
|
|
<a-layout id="app" v-cloak :class="themeSwitcher.darkCardClass">
|
2023-02-09 19:18:06 +00:00
|
|
|
<transition name="list" appear>
|
|
|
|
<a-layout-content>
|
|
|
|
<a-row type="flex" justify="center">
|
|
|
|
<a-col :xs="22" :sm="20" :md="16" :lg="12" :xl="8">
|
2023-05-08 14:50:13 +00:00
|
|
|
<h1 class="title">{{ i18n "pages.login.title" }}</h1>
|
2023-02-09 19:18:06 +00:00
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
<a-row type="flex" justify="center">
|
|
|
|
<a-col :xs="22" :sm="20" :md="16" :lg="12" :xl="8">
|
|
|
|
<a-form>
|
|
|
|
<a-form-item>
|
|
|
|
<a-input v-model.trim="user.username" placeholder='{{ i18n "username" }}'
|
|
|
|
@keydown.enter.native="login" autofocus>
|
2023-05-08 14:50:13 +00:00
|
|
|
<a-icon slot="prefix" type="user" :style="'font-size: 16px;' + themeSwitcher.textStyle" />
|
2023-02-09 19:18:06 +00:00
|
|
|
</a-input>
|
|
|
|
</a-form-item>
|
|
|
|
<a-form-item>
|
2023-05-08 14:54:44 +00:00
|
|
|
<password-input icon="lock" v-model.trim="user.password"
|
|
|
|
placeholder='{{ i18n "password" }}' @keydown.enter.native="login">
|
|
|
|
</password-input>
|
2023-02-09 19:18:06 +00:00
|
|
|
</a-form-item>
|
2023-04-21 15:30:14 +00:00
|
|
|
<a-form-item v-if="secretEnable">
|
2023-05-08 14:54:44 +00:00
|
|
|
<password-input icon="key" v-model.trim="user.loginSecret"
|
|
|
|
placeholder='{{ i18n "secretToken" }}' @keydown.enter.native="login">
|
|
|
|
</password-input>
|
2023-04-21 15:30:14 +00:00
|
|
|
</a-input>
|
|
|
|
</a-form-item>
|
2023-02-09 19:18:06 +00:00
|
|
|
<a-form-item>
|
2023-05-08 14:50:13 +00:00
|
|
|
<a-row justify="center" class="centered">
|
|
|
|
<a-button type="primary" :loading="loading" @click="login" :icon="loading ? 'poweroff' : undefined"
|
|
|
|
:style="loading ? { width: '50px' } : { display: 'block', width: '100%' }">
|
|
|
|
[[ loading ? '' : '{{ i18n "login" }}' ]]
|
|
|
|
</a-button>
|
|
|
|
</a-row>
|
|
|
|
</a-form-item>
|
|
|
|
<a-form-item>
|
|
|
|
<a-row justify="center" class="centered">
|
|
|
|
<a-col :span="12">
|
|
|
|
<a-select ref="selectLang" v-model="lang" @change="setLang(lang)" :dropdown-class-name="themeSwitcher.darkCardClass">
|
|
|
|
<a-select-option :value="l.value" label="English" v-for="l in supportLangs">
|
2023-02-09 19:18:06 +00:00
|
|
|
<span role="img" aria-label="l.name" v-text="l.icon"></span>
|
|
|
|
<span v-text="l.name"></span>
|
|
|
|
</a-select-option>
|
|
|
|
</a-select>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</a-form-item>
|
2023-05-08 14:50:13 +00:00
|
|
|
<a-form-item>
|
|
|
|
<a-row justify="center" class="centered">
|
2023-05-08 15:14:18 +00:00
|
|
|
<theme-switch />
|
2023-05-08 14:50:13 +00:00
|
|
|
</a-row>
|
|
|
|
</a-form-item>
|
2023-02-09 19:18:06 +00:00
|
|
|
</a-form>
|
|
|
|
</a-col>
|
|
|
|
</a-row>
|
|
|
|
</a-layout-content>
|
|
|
|
</transition>
|
|
|
|
</a-layout>
|
|
|
|
{{template "js" .}}
|
2023-05-08 14:50:13 +00:00
|
|
|
{{template "component/themeSwitcher" .}}
|
2023-05-08 14:56:01 +00:00
|
|
|
{{template "component/password" .}}
|
2023-02-09 19:18:06 +00:00
|
|
|
<script>
|
2023-05-08 14:50:13 +00:00
|
|
|
|
2023-02-09 19:18:06 +00:00
|
|
|
const app = new Vue({
|
|
|
|
delimiters: ['[[', ']]'],
|
|
|
|
el: '#app',
|
|
|
|
data: {
|
2023-05-08 14:50:13 +00:00
|
|
|
themeSwitcher,
|
2023-02-09 19:18:06 +00:00
|
|
|
loading: false,
|
|
|
|
user: new User(),
|
2023-04-21 15:30:14 +00:00
|
|
|
secretEnable: false,
|
2023-05-08 14:50:13 +00:00
|
|
|
lang: ""
|
2023-02-09 19:18:06 +00:00
|
|
|
},
|
2023-05-12 17:29:41 +00:00
|
|
|
async created() {
|
2023-05-08 14:50:13 +00:00
|
|
|
this.updateBackground();
|
|
|
|
this.lang = getLang();
|
2023-05-12 17:29:41 +00:00
|
|
|
this.secretEnable = await this.getSecretStatus();
|
2023-02-09 19:18:06 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async login() {
|
|
|
|
this.loading = true;
|
|
|
|
const msg = await HttpUtil.post('/login', this.user);
|
|
|
|
this.loading = false;
|
|
|
|
if (msg.success) {
|
2023-05-12 18:06:05 +00:00
|
|
|
location.href = basePath + 'panel/';
|
2023-02-09 19:18:06 +00:00
|
|
|
}
|
2023-04-21 15:30:14 +00:00
|
|
|
},
|
|
|
|
async getSecretStatus() {
|
2023-05-08 14:50:13 +00:00
|
|
|
this.loading = true;
|
2023-04-21 15:30:14 +00:00
|
|
|
const msg = await HttpUtil.post('/getSecretStatus');
|
|
|
|
this.loading = false;
|
2023-05-08 14:50:13 +00:00
|
|
|
if (msg.success) {
|
2023-04-21 15:30:14 +00:00
|
|
|
this.secretEnable = msg.obj;
|
|
|
|
return msg.obj;
|
|
|
|
}
|
2023-05-08 14:50:13 +00:00
|
|
|
},
|
|
|
|
updateBackground() {
|
|
|
|
const leftColor = RandomUtil.randomIntRange(0x222222, 0xFFFFFF / 2).toString(16);
|
|
|
|
const rightColor = RandomUtil.randomIntRange(0xFFFFFF / 2, 0xDDDDDD).toString(16);
|
|
|
|
const deg = RandomUtil.randomIntRange(0, 360);
|
|
|
|
const background = `linear-gradient(${deg}deg, #${leftColor} 10%, #${rightColor} 100%)`;
|
|
|
|
document.querySelector('#app').style.background = this.themeSwitcher.isDarkTheme ? colors.dark.bg : background;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'themeSwitcher.isDarkTheme'(newVal, oldVal) {
|
|
|
|
this.updateBackground();
|
|
|
|
},
|
|
|
|
},
|
2023-02-09 19:18:06 +00:00
|
|
|
});
|
2023-05-08 14:50:13 +00:00
|
|
|
|
2023-02-09 19:18:06 +00:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|