diff --git a/frontend/src/i18n/zh.js b/frontend/src/i18n/zh.js index c932ea6d..7013bda5 100644 --- a/frontend/src/i18n/zh.js +++ b/frontend/src/i18n/zh.js @@ -230,8 +230,8 @@ export default { 'Are you sure to run this spider?': '你确定要运行该爬虫?', 'Node info has been saved successfully': '节点信息已成功保存', 'A task has been scheduled successfully': '已经成功派发一个任务', - 'Are you sure to deploy this spider?': '你确定要部署该爬虫?', 'Are you sure to delete this spider?': '你确定要删除该爬虫?', + 'Are you sure to delete this user?': '你确定要删除该用户?', 'Spider info has been saved successfully': '爬虫信息已成功保存', 'Do you allow us to collect some statistics to improve Crawlab?': '您允许我们收集统计数据以更好地优化Crawlab?', 'Saved file successfully': '成功保存文件', @@ -241,6 +241,8 @@ export default { 'Password length should be no shorter than 5': '密码长度不能小于5', 'Two passwords must be the same': '两个密码必须要一致', 'username already exists': '用户名已存在', + 'Deleted successfully': '成功删除', + 'Saved successfully': '成功保存', // 登录 'Sign in': '登录', @@ -255,5 +257,10 @@ export default { 'Initial Username/Password': '初始用户名/密码', 'Username': '用户名', 'Password': '密码', - 'Confirm Password': '确认密码' + 'Confirm Password': '确认密码', + 'normal': '正常用户', + 'admin': '管理用户', + 'Role': '角色', + 'Edit User': '更改用户', + 'Users': '用户' } diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 0371e9e7..473e326a 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -156,37 +156,6 @@ export const constantRouterMap = [ } ] }, - { - name: 'Deploy', - path: '/deploys', - component: Layout, - hidden: true, - meta: { - title: 'Deploy', - icon: 'fa fa-cloud' - }, - children: [ - { - path: '', - name: 'DeployList', - component: () => import('../views/deploy/DeployList'), - meta: { - title: 'Deploys', - icon: 'fa fa-cloud' - } - }, - { - path: ':id', - name: 'DeployDetail', - component: () => import('../views/deploy/DeployDetail'), - meta: { - title: 'Deploy Detail', - icon: 'fa fa-circle-o' - }, - hidden: true - } - ] - }, { name: 'Site', path: '/sites', @@ -207,6 +176,26 @@ export const constantRouterMap = [ } ] }, + { + name: 'User', + path: '/users', + component: Layout, + meta: { + title: 'User', + icon: 'fa fa-user' + }, + children: [ + { + path: '', + name: 'UserList', + component: () => import('../views/user/UserList'), + meta: { + title: 'Users', + icon: 'fa fa-user' + } + } + ] + }, { path: '*', redirect: '/404', hidden: true } ] diff --git a/frontend/src/store/modules/user.js b/frontend/src/store/modules/user.js index 7e79ecea..2f7a9050 100644 --- a/frontend/src/store/modules/user.js +++ b/frontend/src/store/modules/user.js @@ -7,7 +7,12 @@ const user = { // token: getToken(), name: '', avatar: '', - roles: [] + roles: [], + userList: [], + userForm: {}, + pageNum: 1, + pageSize: 10, + totalCount: 0 }, mutations: { @@ -22,6 +27,21 @@ const user = { }, SET_ROLES: (state, roles) => { state.roles = roles + }, + SET_USER_LIST: (state, value) => { + state.userList = value + }, + SET_USER_FORM: (state, value) => { + state.userForm = value + }, + SET_PAGE_NUM: (state, value) => { + state.pageNum = value + }, + SET_PAGE_SIZE: (state, value) => { + state.pageSize = value + }, + SET_TOTAL_COUNT: (state, value) => { + state.totalCount = value } }, @@ -83,6 +103,30 @@ const user = { commit('SET_ROLES', []) resolve() }) + }, + + // 获取用户列表 + getUserList ({ commit, state }) { + return new Promise((resolve, reject) => { + request.get('/users', { + page_num: state.pageNum, + page_size: state.pageSize + }) + .then(response => { + commit('SET_USER_LIST', response.data.data) + commit('SET_TOTAL_COUNT', response.data.total) + }) + }) + }, + + // 删除用户 + deleteUser ({ state }, id) { + return request.delete(`/users/${id}`) + }, + + // 编辑用户 + editUser ({ state }) { + return request.post(`/users/${state.userForm._id}`, state.userForm) } } } diff --git a/frontend/src/views/user/UserList.vue b/frontend/src/views/user/UserList.vue new file mode 100644 index 00000000..e373e4d1 --- /dev/null +++ b/frontend/src/views/user/UserList.vue @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + {{$t('Cancel')}} + {{$t('Confirm')}} + + + + + + + + + + + + + {{ $t(scope.row.role) }} + + + {{ $t(scope.row.role) }} + + + + + + {{getTime(scope.row.create_ts)}} + + + + + + + + + + + + + + + + + + + + +