Skip to content

Commit e97a10d

Browse files
committed
test code
1 parent 27da739 commit e97a10d

File tree

4 files changed

+47
-17
lines changed

4 files changed

+47
-17
lines changed

src/permission.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import store from './store'
44

55
import NProgress from 'nprogress' // progress bar
66
import 'nprogress/nprogress.css' // progress bar style
7+
import notification from 'ant-design-vue/es/notification'
78
import { ACCESS_TOKEN } from "@/store/mutation-types"
89

910
NProgress.configure({ showSpinner: false })// NProgress Configuration
@@ -27,6 +28,7 @@ router.beforeEach((to, from, next) => {
2728
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
2829
})
2930
}).catch(() => {
31+
notification.error({ message: '错误', description: '请求用户信息失败,请重试' })
3032
store.dispatch('Logout').then(() => {
3133
next({ path: '/user/login' })
3234
})

src/views/dashboard/Workplace.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
import HeadInfo from '@/components/tools/HeadInfo'
118118
import Radar from '@/components/chart/Radar'
119119
120+
import { getRoleList, getServiceList } from "@/api/manage"
121+
120122
const DataSet = require('@antv/data-set')
121123
122124
export default {
@@ -185,6 +187,14 @@
185187
created() {
186188
this.user = this.userInfo
187189
this.avatar = this.userInfo.avatar
190+
191+
getRoleList().then(res => {
192+
console.log('workplace -> call getRoleList()', res)
193+
})
194+
195+
getServiceList().then(res => {
196+
console.log('workplace -> call getServiceList()', res)
197+
})
188198
},
189199
mounted() {
190200
this.getProjects()

src/views/user/Login.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<a-form-item
1111
fieldDecoratorId="username"
12-
:fieldDecoratorOptions="{rules: [{ required: true, message: '请输入帐户名或邮箱地址' }, { validator: this.handleUsernameOrEmail }], validateTrigger: 'blur'}"
12+
:fieldDecoratorOptions="{rules: [{ required: true, message: '请输入帐户名或邮箱地址' }, { validator: this.handleUsernameOrEmail }], validateTrigger: 'change'}"
1313
>
1414
<a-input size="large" type="text" placeholder="帐户名或邮箱地址 / admin">
1515
<a-icon slot="prefix" type='user' :style="{ color: 'rgba(0,0,0,.25)' }"/>
@@ -27,7 +27,7 @@
2727
<a-tab-pane key="tab2" tab="手机号登陆">
2828
<a-form-item
2929
fieldDecoratorId="mobile"
30-
:fieldDecoratorOptions="{rules: [{ required: true, pattern: /^1[34578]\d{9}$/, message: '请输入正确的手机号' }], validateTrigger: 'blur'}">
30+
:fieldDecoratorOptions="{rules: [{ required: true, pattern: /^1[34578]\d{9}$/, message: '请输入正确的手机号' }], validateTrigger: 'change'}">
3131
<a-input size="large" type="text" placeholder="手机号">
3232
<a-icon slot="prefix" type='mobile' :style="{ color: 'rgba(0,0,0,.25)' }"/>
3333
</a-input>

src/views/user/Register.vue

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111

1212
<a-form-item
1313
fieldDecoratorId="password"
14-
:fieldDecoratorOptions="{rules: [{ required: true, message: '至少6位密码,区分大小写' }, { validator: this.handlePasswordLevel }], validateTrigger: 'change'}">
15-
<a-popover placement="right">
14+
:fieldDecoratorOptions="{rules: [{ required: true, message: '至少6位密码,区分大小写' }, { validator: this.handlePasswordLevel }], validateTrigger: ['change', 'blur']}">
15+
<a-popover placement="right" trigger="click" :visible="clicked" @visibleChange="clicked = true">
1616
<template slot="content">
1717
<div :style="{ width: '240px' }">
18-
<div :class="['user-register', getPasswordLevelClass()]">强度:<span></span></div>
19-
<a-progress :percent="30" :showInfo="false" strokeColor="#FF0000" />
18+
<div :class="['user-register', passwordLevelClass]">强度:<span>{{ passwordLevelName }}</span></div>
19+
<a-progress :percent="state.percent" :showInfo="false" strokeColor="#FF0000" />
2020
<div style="margin-top: 10px;">
2121
<span>请至少输入 6 个字符。请不要使用容易被猜到的密码。</span>
2222
</div>
@@ -86,6 +86,18 @@
8686
<script>
8787
import { getSmsCaptcha } from '@/api/login'
8888
89+
const levelNames = {
90+
0: '',
91+
1: '',
92+
2: '',
93+
3: ''
94+
}
95+
const levelClass = {
96+
0: 'error',
97+
1: 'error',
98+
2: 'warning',
99+
3: 'success'
100+
}
89101
export default {
90102
name: "Register",
91103
components: {
@@ -94,14 +106,24 @@
94106
return {
95107
form: null,
96108
109+
clicked: false,
97110
state: {
98111
time: 60,
99112
smsSendBtn: false,
100-
passwordLevel: 0
113+
passwordLevel: 0,
114+
percent: 0,
101115
},
102116
registerBtn: false
103117
}
104118
},
119+
computed: {
120+
passwordLevelClass () {
121+
return levelClass[this.state.passwordLevel]
122+
},
123+
passwordLevelName () {
124+
return levelNames[this.state.passwordLevel]
125+
}
126+
},
105127
methods: {
106128
107129
handlePasswordLevel (rule, value, callback) {
@@ -120,7 +142,12 @@
120142
level++
121143
}
122144
this.state.passwordLevel = level
145+
this.state.percent = level * 30
146+
console.log('passwordLevel', this.state.passwordLevel, 'level', level)
123147
if (level >= 2) {
148+
if (level >= 3) {
149+
this.state.percent = 100
150+
}
124151
callback()
125152
} else {
126153
callback(new Error('密码强度不够'))
@@ -143,16 +170,6 @@
143170
})
144171
},
145172
146-
getPasswordLevelClass () {
147-
const c = {
148-
0: 'error',
149-
1: 'error',
150-
2: 'warning',
151-
3: 'success'
152-
}
153-
return c[this.state.passwordLevel]
154-
},
155-
156173
getCaptcha(e) {
157174
e.preventDefault()
158175
let that = this
@@ -201,6 +218,7 @@
201218
},
202219
watch: {
203220
'state.passwordLevel' (val) {
221+
console.log(val)
204222
205223
}
206224
}

0 commit comments

Comments
 (0)