Skip to content

Commit 743911d

Browse files
committed
Feature(profile): add profile pages
1 parent 525f0f1 commit 743911d

File tree

20 files changed

+642
-12
lines changed

20 files changed

+642
-12
lines changed

mock/users.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ const userList: IUserData[] = [
1010
name: 'Super Admin',
1111
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
1212
introduction: 'I am a super administrator',
13-
email: '',
14-
phone: '',
13+
14+
phone: '1234567890',
1515
roles: ['admin'],
1616
},
1717
{
@@ -21,8 +21,8 @@ const userList: IUserData[] = [
2121
name: 'Normal Editor',
2222
avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
2323
introduction: 'I am an editor',
24-
email: '',
25-
phone: '',
24+
25+
phone: '1234567890',
2626
roles: ['editor'],
2727
}
2828
]

src/filters/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ export const articleStatusFilter = (status: string) => {
1010
}
1111
return statusMap[status]
1212
}
13+
14+
// Filter to uppercase the first character
15+
export const uppercaseFirstChar = (str: string) => {
16+
return str.charAt(0).toUpperCase() + str.slice(1)
17+
}

src/icons/components/education.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable */
2+
/* tslint:disable */
3+
// @ts-ignore
4+
import icon from 'vue-svgicon'
5+
icon.register({
6+
'education': {
7+
width: 128,
8+
height: 128,
9+
viewBox: '0 0 128 128',
10+
data: '<path pid="0" d="M88.9 119.6c-7.3 0-19.5 2.5-21.4 8.2v.1c-4.2.2-5.2 0-7 0-2-5.7-14.1-8.2-21.4-8.2H0V0h42.5C51.7 0 59.6 5.5 64 13.6 68.4 5.5 76.3 0 85.5 0H128v119.6H88.9zM60.4 24.8c0-9.7-9-16.5-17.7-16.5H7v103.1h32c7-.1 18.2.1 21.3 6.2V24.8zM121 8.2H85.3c-8.8 0-17.7 6.9-17.7 16.5v92.7c3.1-6 14.2-6.2 21.3-6h32V8.1z"/>'
11+
}
12+
})

src/icons/components/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import './dashboard'
99
import './documentation'
1010
import './drag'
1111
import './edit'
12+
import './education'
1213
import './email'
1314
import './example'
1415
import './excel'
@@ -23,6 +24,7 @@ import './hamburger'
2324
import './icon'
2425
import './international'
2526
import './language'
27+
import './like'
2628
import './link'
2729
import './list'
2830
import './lock'
@@ -37,6 +39,7 @@ import './qq'
3739
import './search'
3840
import './shopping'
3941
import './size'
42+
import './skill'
4043
import './star'
4144
import './tab'
4245
import './table'

src/icons/components/like.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable */
2+
/* tslint:disable */
3+
// @ts-ignore
4+
import icon from 'vue-svgicon'
5+
icon.register({
6+
'like': {
7+
width: 24,
8+
height: 24,
9+
viewBox: '0 0 24 24',
10+
data: '<path pid="0" d="M12 21.6C6.4 16 1 11.3 1 7.2 1 3.4 4 2 6.3 2c1.3 0 4.1.5 5.7 4.5 1.6-4 4.5-4.5 5.7-4.5C20.3 2 23 3.6 23 7.2c0 4-5.1 8.6-11 14.4M17.7 1c-2.2 0-4.4 1-5.7 3.2A6.5 6.5 0 0 0 6.3 1C3 1 0 3.2 0 7.2c0 4.7 5.6 9.4 12 15.8 6.4-6.4 12-11.1 12-15.8 0-4-3.1-6.2-6.3-6.2"/>'
11+
}
12+
})

src/icons/components/skill.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* eslint-disable */
2+
/* tslint:disable */
3+
// @ts-ignore
4+
import icon from 'vue-svgicon'
5+
icon.register({
6+
'skill': {
7+
width: 128,
8+
height: 128,
9+
viewBox: '0 0 128 128',
10+
data: '<path pid="0" d="M31.7 93.2H65a41 41 0 0 0 5 6.8H31.7v-6.7zm0-10.6h28.9a44.8 44.8 0 0 1-1.3-6.7H31.7v6.7zm0-17.2h27.7c.3-2.3.7-4.6 1.3-6.7h-29v6.7zm53.9 44.8v5.8c0 2.8-2.1 5.1-4.7 5.1h-70c-2.6 0-4.7-2.3-4.7-5V31.2l23.2-21v22.3H17.2v6.6h18.4V6.7h45.3c2.6 0 4.7 2.3 4.7 5v20c2-.6 4-1 6.1-1.4V11.8C91.7 5.3 87 0 81 0H31.1L0 28.1v88c0 6.4 4.9 11.7 10.8 11.7H81c6 0 10.8-5.3 10.8-11.8v-4.4c-2-.3-4.1-.7-6.1-1.4zM23.3 58.7h-8v6.7h8v-6.7zm-8 41.2h8v-6.7h-8v6.7zm8-24h-8v6.7h8V76zM113 61l-4.9-4-12.4 17.5-11.2-9.3-3.8 5.3 16 13.4 16.3-23zm15 10c0-18.6-14-33.7-31.1-33.7-17.2 0-31.2 15.2-31.2 33.8 0 18.6 14 33.8 31.2 33.8C114 104.8 128 89.6 128 71zm-6.2 0c0 15-11.2 27.2-25 27.2-13.7 0-25-12.2-25-27.1 0-15 11.3-27.1 25-27.1 13.8 0 25 12.1 25 27z"/>'
11+
}
12+
})

src/icons/svg/education.svg

Lines changed: 3 additions & 0 deletions
Loading

src/icons/svg/like.svg

Lines changed: 3 additions & 0 deletions
Loading

src/icons/svg/skill.svg

Lines changed: 3 additions & 0 deletions
Loading

src/lang/en.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ export default {
6161
theme: 'Theme',
6262
clipboard: 'Clipboard',
6363
i18n: 'I18n',
64-
externalLink: 'External Link'
64+
externalLink: 'External Link',
65+
profile: 'Profile'
6566
},
6667
navbar: {
6768
logOut: 'Log Out',
6869
dashboard: 'Dashboard',
6970
github: 'Github',
7071
theme: 'Theme',
71-
size: 'Global Size'
72+
size: 'Global Size',
73+
profile: 'Profile'
7274
},
7375
login: {
7476
title: 'Login Form',

src/lang/es.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ export default {
6161
theme: 'Tema',
6262
clipboard: 'Clipboard',
6363
i18n: 'I18n',
64-
externalLink: 'Enlace externo'
64+
externalLink: 'Enlace externo',
65+
profile: 'Profile'
6566
},
6667
navbar: {
6768
logOut: 'Salir',
6869
dashboard: 'Panel de control',
6970
github: 'Github',
7071
theme: 'Tema',
71-
size: 'Tamaño global'
72+
size: 'Tamaño global',
73+
profile: 'Profile'
7274
},
7375
login: {
7476
title: 'Formulario de acceso',

src/lang/zh.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ export default {
6161
theme: '换肤',
6262
clipboard: '粘贴板',
6363
i18n: '国际化',
64-
externalLink: '外链'
64+
externalLink: '外链',
65+
profile: '个人中心'
6566
},
6667
navbar: {
6768
logOut: '退出登录',
6869
dashboard: '首页',
6970
github: '项目地址',
7071
theme: '换肤',
71-
size: '布局大小'
72+
size: '布局大小',
73+
profile: '个人中心'
7274
},
7375
login: {
7476
title: '系统登录',

src/layout/components/Navbar/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
<i class="el-icon-caret-bottom" />
3737
</div>
3838
<el-dropdown-menu slot="dropdown">
39+
<router-link to="/profile/">
40+
<el-dropdown-item>
41+
{{ $t('navbar.profile') }}
42+
</el-dropdown-item>
43+
</router-link>
3944
<router-link to="/">
4045
<el-dropdown-item>
4146
{{ $t('navbar.dashboard') }}
@@ -51,7 +56,7 @@
5156
</a>
5257
<a
5358
target="_blank"
54-
href="https://panjiachen.github.io/vue-element-admin-site/#/"
59+
href="https://armour.github.io/vue-typescript-admin-docs/"
5560
>
5661
<el-dropdown-item>Docs</el-dropdown-item>
5762
</a>

src/router/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,24 @@ export const constantRoutes: RouteConfig[] = [
117117
}
118118
}
119119
]
120+
},
121+
{
122+
path: '/profile',
123+
component: Layout,
124+
redirect: '/profile/index',
125+
meta: { hidden: true },
126+
children: [
127+
{
128+
path: 'index',
129+
component: () => import(/* webpackChunkName: "profile" */ '@/views/profile/index.vue'),
130+
name: 'Profile',
131+
meta: {
132+
title: 'profile',
133+
icon: 'user',
134+
noCache: true
135+
}
136+
}
137+
]
120138
}
121139
]
122140

src/store/modules/user.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface IUserState {
1212
avatar: string
1313
introduction: string
1414
roles: string[]
15+
email: string
1516
}
1617

1718
@Module({ dynamic: true, store, name: 'user' })
@@ -21,6 +22,7 @@ class User extends VuexModule implements IUserState {
2122
public avatar = ''
2223
public introduction = ''
2324
public roles: string[] = []
25+
public email = ''
2426

2527
@Mutation
2628
private SET_TOKEN(token: string) {
@@ -47,6 +49,11 @@ class User extends VuexModule implements IUserState {
4749
this.roles = roles
4850
}
4951

52+
@Mutation
53+
private SET_EMAIL(email: string) {
54+
this.email = email
55+
}
56+
5057
@Action
5158
public async Login(userInfo: { username: string, password: string}) {
5259
let { username, password } = userInfo
@@ -72,7 +79,7 @@ class User extends VuexModule implements IUserState {
7279
if (!data) {
7380
throw Error('Verification failed, please Login again.')
7481
}
75-
const { roles, name, avatar, introduction } = data.user
82+
const { roles, name, avatar, introduction, email } = data.user
7683
// roles must be a non-empty array
7784
if (!roles || roles.length <= 0) {
7885
throw Error('GetUserInfo: roles must be a non-null array!')
@@ -81,6 +88,7 @@ class User extends VuexModule implements IUserState {
8188
this.SET_NAME(name)
8289
this.SET_AVATAR(avatar)
8390
this.SET_INTRODUCTION(introduction)
91+
this.SET_EMAIL(email)
8492
}
8593

8694
@Action
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<el-form>
3+
<el-form-item label="Name">
4+
<el-input v-model.trim="user.name" />
5+
</el-form-item>
6+
<el-form-item label="Email">
7+
<el-input v-model.trim="user.email" />
8+
</el-form-item>
9+
<el-form-item>
10+
<el-button
11+
type="primary"
12+
@click="submit"
13+
>
14+
Update
15+
</el-button>
16+
</el-form-item>
17+
</el-form>
18+
</template>
19+
20+
<script lang="ts">
21+
import { Component, Prop, Vue } from 'vue-property-decorator'
22+
import { IProfile } from '../index.vue'
23+
24+
@Component({
25+
name: 'Account'
26+
})
27+
export default class extends Vue {
28+
@Prop({ required: true }) private user!: IProfile
29+
30+
private submit() {
31+
this.$message({
32+
message: 'User information has been updated successfully',
33+
type: 'success',
34+
duration: 5 * 1000
35+
})
36+
}
37+
}
38+
</script>

0 commit comments

Comments
 (0)