Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 7633f11

Browse files
committed
新增 用户密码初始化框
1 parent c839d50 commit 7633f11

File tree

3 files changed

+124
-4
lines changed

3 files changed

+124
-4
lines changed

src/app/views/Overview.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,14 @@
205205
</el-row>
206206
</template>
207207
</Panel>
208+
209+
<UserInit v-model:visible="initUserVisible"></UserInit>
208210
</template>
209211

210212
<script>
211213
import * as echarts from "echarts";
212214
import Panel from "../../components/Panel";
215+
import UserInit from "../../components/UserInit";
213216
// import LineLabel from "../../components/LineLabel";
214217
import { request } from "../service/protocol";
215218
import { API_OVERVIEW } from "../service/common";
@@ -220,6 +223,7 @@ import {
220223
} from "../service/chart_option";
221224
import ValueCard from "../../components/ValueCard";
222225
export default {
226+
components: { Panel, ValueCard, UserInit },
223227
data() {
224228
return {
225229
loading: true,
@@ -253,7 +257,10 @@ export default {
253257
totalLogin: 0,
254258
failedLogin: 0,
255259
Logined: 0
256-
}
260+
},
261+
262+
// 初始化用户密码窗口
263+
initUserVisible: false
257264
};
258265
},
259266
methods: {
@@ -480,7 +487,6 @@ export default {
480487
this.setSystemChart();
481488
}
482489
},
483-
components: { Panel, ValueCard },
484490
async mounted() {
485491
this.loading = true;
486492
const data = await this.request();
@@ -489,6 +495,13 @@ export default {
489495
this.loading = false;
490496
this.manualLink = window.onlineMCSManagerNotice ? window.onlineMCSManagerNotice() : null;
491497
this.startInterval();
498+
499+
setTimeout(() => {
500+
const { isInit, permission } = this.$store.state.userInfo;
501+
if (isInit === false && permission === 10) {
502+
this.initUserVisible = true;
503+
}
504+
}, 1000);
492505
},
493506
beforeUnmount() {
494507
this.stopInterval();

src/components/Dialog.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<template #title>
2929
<div class="flex flex-space-between flex-align-items-center" style="width: 100%">
3030
<slot name="title"></slot>
31-
<div class="component-dialog-close-button" @click="close">
31+
<div class="component-dialog-close-button" @click="close" v-if="canClose">
3232
<i class="el-icon-close"></i>
3333
</div>
3434
</div>
@@ -52,7 +52,11 @@ export default {
5252
props: {
5353
modelValue: Boolean,
5454
cancel: Function,
55-
style: String
55+
style: String,
56+
canClose: {
57+
type: Boolean,
58+
default: true
59+
}
5660
},
5761
emits: ["update:modelValue"],
5862
data: function () {

src/components/UserInit.vue

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<!-- eslint-disable vue/no-mutating-props -->
2+
<!--
3+
Copyright (C) 2022 Suwings <[email protected]>
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU Affero General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
According to the AGPL, it is forbidden to delete all copyright notices,
11+
and if you modify the source code, you must open source the
12+
modified source code.
13+
14+
版权所有 (C) 2022 Suwings <[email protected]>
15+
16+
该程序是免费软件,您可以重新分发和/或修改据 GNU Affero 通用公共许可证的条款,
17+
由自由软件基金会,许可证的第 3 版,或(由您选择)任何更高版本。
18+
19+
根据 AGPL 与用户协议,您必须保留所有版权声明,如果修改源代码则必须开源修改后的源代码。
20+
可以前往 https://mcsmanager.com/ 阅读用户协议,申请闭源开发授权等。
21+
-->
22+
23+
<template>
24+
<Dialog v-model="visible" :canClose="false">
25+
<template #title>请更改密码</template>
26+
<template #default>
27+
<div class="content">
28+
<div class="sub-title">
29+
<div class="sub-title-title require-field">重置最高级别账号密码</div>
30+
<div class="sub-title-info">
31+
为确保面板安全,第一次登录必须重设密码,密码必须由大写字母,小写字母和数字组成,长度为
32+
12 到 36 位
33+
</div>
34+
<div class="row-mt">
35+
<el-input
36+
type="text"
37+
v-model="passWord"
38+
autocomplete="off"
39+
placeholder="请输入您要设置的新密码"
40+
/>
41+
<div style="text-align: right">
42+
<el-button size="small" class="row-mt" @click="submit()" type="danger" plain
43+
>重置密码</el-button
44+
>
45+
</div>
46+
</div>
47+
</div>
48+
</div>
49+
</template>
50+
</Dialog>
51+
</template>
52+
53+
<script>
54+
import { API_USER_UPDATE } from "../app/service/common";
55+
import { request } from "../app/service/protocol";
56+
import Dialog from "./Dialog";
57+
58+
export default {
59+
components: { Dialog },
60+
props: {
61+
visible: {
62+
type: Boolean,
63+
default: false
64+
}
65+
},
66+
data() {
67+
return {
68+
passWord: ""
69+
};
70+
},
71+
mounted() {},
72+
methods: {
73+
async submit() {
74+
try {
75+
await request({
76+
method: "PUT",
77+
url: API_USER_UPDATE,
78+
data: {
79+
passWord: this.passWord,
80+
isInit: true
81+
}
82+
});
83+
this.$message({ message: "已设置密码,欢迎使用", type: "success" });
84+
this.$emit("update:visible", false);
85+
} catch (error) {
86+
this.$message({
87+
message: error,
88+
type: "error"
89+
});
90+
}
91+
}
92+
}
93+
};
94+
</script>
95+
96+
<style scoped>
97+
.content {
98+
max-width: 500px;
99+
}
100+
.title {
101+
margin: 8px 0px;
102+
}
103+
</style>

0 commit comments

Comments
 (0)