Welcome to mirror list, hosted at ThFree Co, Russian Federation.

login.html « html « web - github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3ec410c67bf9a806be9610131b321660d3ca0d55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!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;
    }

    .ant-input-group-addon {
        border-radius: 0 30px 30px 0;
        width: 50px;
        font-size: 18px;
    }

    .ant-input-affix-wrapper .ant-input-prefix {
        left: 23px;
    }

    .ant-input-affix-wrapper .ant-input:not(:first-child) {
        padding-left: 50px;
    }

    .centered {
        display: flex;
        text-align: center;
        align-items: center;
        justify-content: center;
    }

    .title {
        font-size: 32px;
        font-weight: bold;
    }

</style>
<body>
<a-layout id="app" v-cloak class="login" :class="themeSwitcher.darkCardClass">
    <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">
                    <h1 class="title">{{ i18n "pages.login.title" }}</h1>
                </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>
                                <a-icon slot="prefix" type="user" :style="'font-size: 16px;' + themeSwitcher.textStyle" />
                            </a-input>
                        </a-form-item>
                        <a-form-item>
                            <password-input icon="lock" v-model.trim="user.password"
                                            placeholder='{{ i18n "password" }}' @keydown.enter.native="login">
                            </password-input>
                        </a-form-item>
                        <a-form-item v-if="secretEnable">
                            <password-input icon="key" v-model.trim="user.loginSecret"
                                            placeholder='{{ i18n "secretToken" }}' @keydown.enter.native="login">
                            </password-input>
                        </a-input>
                        </a-form-item>
                        <a-form-item>
                            <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="l.value" v-for="l in supportLangs">
                                            <span role="img" aria-label="l.name" v-text="l.icon"></span>
                                            &nbsp;&nbsp;<span v-text="l.name"></span>
                                        </a-select-option>
                                    </a-select>
                                </a-col>
                            </a-row>
                        </a-form-item>
                        <a-form-item>
                            <a-row justify="center" class="centered">
                                <theme-switch />
                            </a-row>
                        </a-form-item>
                    </a-form>
                </a-col>
            </a-row>
        </a-layout-content>
    </transition>
</a-layout>
{{template "js" .}}
{{template "component/themeSwitcher" .}}
{{template "component/password" .}}
<script>

    const app = new Vue({
        delimiters: ['[[', ']]'],
        el: '#app',
        data: {
            themeSwitcher,
            loading: false,
            user: new User(),
            secretEnable: false,
            lang: ""
        },
        async created() {
            this.updateBackground();
            this.lang = getLang();
            this.secretEnable = await this.getSecretStatus();
        },
        methods: {
            async login() {
                this.loading = true;
                const msg = await HttpUtil.post('/login', this.user);
                this.loading = false;
                if (msg.success) {
                    location.href = basePath + 'panel/';
                }
            },
            async getSecretStatus() {
                this.loading = true;
                const msg = await HttpUtil.post('/getSecretStatus');
                this.loading = false;
                if (msg.success) {
                    this.secretEnable = msg.obj;
                    return msg.obj;
                }
            },
            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();
            },
        },
    });

</script>
</body>
</html>