diff --git a/.env.development b/.env.development index de583d0..8245922 100644 --- a/.env.development +++ b/.env.development @@ -2,4 +2,4 @@ ENV = 'development' # base api -VUE_APP_BASE_API = '/dev-api' +VUE_APP_BASE_API = '/' diff --git a/package.json b/package.json index 02f68e2..0b00af6 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "vue-element-admin", + "name": "kubex", "version": "4.4.0", - "description": "A magical vue admin. An out-of-box UI solution for enterprise applications. Newest development stack of vue. Lots of awesome features", - "author": "Pan ", + "description": "", + "author": "", "scripts": { "dev": "vue-cli-service serve", "lint": "eslint --ext .js,.vue src", diff --git a/src/api/user.js b/src/api/user.js index b8b8741..48bf076 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,10 +1,11 @@ import request from '@/utils/request' +const qs = require('qs') export function login(data) { return request({ - url: '/vue-element-admin/user/login', + url: '/oauth/token', method: 'post', - data + data: qs.stringify(data) }) } diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index e224ff7..acabcaa 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -37,7 +37,7 @@ export default { const first = matched[0] if (!this.isDashboard(first)) { - matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched) + matched = [{ path: '/', meta: { title: 'KUBEX' }}].concat(matched) } this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) diff --git a/src/components/ClusterManagement/clusterMessage.vue b/src/components/ClusterManagement/clusterMessage.vue new file mode 100644 index 0000000..ebe535b --- /dev/null +++ b/src/components/ClusterManagement/clusterMessage.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/src/components/ClusterManagement/componentStatus.vue b/src/components/ClusterManagement/componentStatus.vue new file mode 100644 index 0000000..391e502 --- /dev/null +++ b/src/components/ClusterManagement/componentStatus.vue @@ -0,0 +1,32 @@ + + + + + diff --git a/src/components/ClusterManagement/nodeMessage.vue b/src/components/ClusterManagement/nodeMessage.vue new file mode 100644 index 0000000..e6f719d --- /dev/null +++ b/src/components/ClusterManagement/nodeMessage.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/src/components/ClusterManagement/nodeStatus.vue b/src/components/ClusterManagement/nodeStatus.vue new file mode 100644 index 0000000..ab44f3d --- /dev/null +++ b/src/components/ClusterManagement/nodeStatus.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/src/components/ClusterManagement/resourceUsage.vue b/src/components/ClusterManagement/resourceUsage.vue new file mode 100644 index 0000000..4e4df88 --- /dev/null +++ b/src/components/ClusterManagement/resourceUsage.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/src/main.js b/src/main.js index 64fba2e..8ee7e34 100644 --- a/src/main.js +++ b/src/main.js @@ -28,10 +28,10 @@ import * as filters from './filters' // global filters * Currently MockJs will be used in the production environment, * please remove it before going online ! ! ! */ -if (process.env.NODE_ENV !== 'production') { - const { mockXHR } = require('../mock') - mockXHR() -} +// if (process.env.NODE_ENV !== 'production') { +// const { mockXHR } = require('../mock') +// mockXHR() +// } Vue.use(Element, { size: Cookies.get('size') || 'small' // set element-ui default size diff --git a/src/permission.js b/src/permission.js index ff5eaad..3702c69 100644 --- a/src/permission.js +++ b/src/permission.js @@ -1,6 +1,6 @@ import router from './router' -import store from './store' -import { Message } from 'element-ui' +// import store from './store' +// import { Message } from 'element-ui' import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style import { getToken } from '@/utils/auth' // get token from cookie @@ -26,33 +26,34 @@ router.beforeEach(async(to, from, next) => { next({ path: '/' }) NProgress.done() // hack: https://github.com/PanJiaChen/vue-element-admin/pull/2939 } else { + next() // determine whether the user has obtained his permission roles through getInfo - const hasRoles = store.getters.roles && store.getters.roles.length > 0 - if (hasRoles) { - next() - } else { - try { - // get user info - // note: roles must be a object array! such as: ['admin'] or ,['developer','editor'] - const { roles } = await store.dispatch('user/getInfo') + // const hasRoles = store.getters.roles && store.getters.roles.length > 0 + // if (hasRoles) { + // next() + // } else { + // try { + // // get user info + // // note: roles must be a object array! such as: ['admin'] or ,['developer','editor'] + // const { roles } = await store.dispatch('user/getInfo') - // generate accessible routes map based on roles - const accessRoutes = await store.dispatch('permission/generateRoutes', roles) + // // generate accessible routes map based on roles + // const accessRoutes = await store.dispatch('permission/generateRoutes', roles) - // dynamically add accessible routes - router.addRoutes(accessRoutes) + // // dynamically add accessible routes + // router.addRoutes(accessRoutes) - // hack method to ensure that addRoutes is complete - // set the replace: true, so the navigation will not leave a history record - next({ ...to, replace: true }) - } catch (error) { - // remove token and go to login page to re-login - await store.dispatch('user/resetToken') - Message.error(error || 'Has Error') - next(`/login?redirect=${to.path}`) - NProgress.done() - } - } + // // hack method to ensure that addRoutes is complete + // // set the replace: true, so the navigation will not leave a history record + // next({ ...to, replace: true }) + // } catch (error) { + // // remove token and go to login page to re-login + // await store.dispatch('user/resetToken') + // Message.error(error || 'Has Error') + // next(`/login?redirect=${to.path}`) + // NProgress.done() + // } + // } } } else { /* has no token*/ diff --git a/src/router/index.js b/src/router/index.js index 26d4d64..f8f4786 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -70,19 +70,74 @@ export const constantRoutes = [ component: () => import('@/views/error-page/401'), hidden: true }, + // { + // path: '/', + // component: Layout, + // redirect: '/dashboard', + // children: [ + // { + // path: 'dashboard', + // component: () => import('@/views/dashboard/index'), + // name: 'Dashboard', + // meta: { title: 'Dashboard', icon: 'dashboard', affix: true } + // } + // ] + // }, + { path: '/', component: Layout, - redirect: '/dashboard', + redirect: 'overview', children: [ { - path: 'dashboard', - component: () => import('@/views/dashboard/index'), - name: 'Dashboard', - meta: { title: 'Dashboard', icon: 'dashboard', affix: true } + path: 'overview', + component: () => import('@/views/overview/index'), + name: 'Overview', + meta: { title: '概览', icon: 'dashboard', affix: true } } ] }, + { + path: '/nodeManagement', + component: Layout, + redirect: 'nodeManagement', + children: [ + { + path: 'nodeManagement', + component: () => import('@/views/nodeManagement/index'), + name: 'NodeManagement', + meta: { title: '节点管理', icon: 'el-icon-s-management', affix: true } + } + ] + }, + { + path: '/projectManagement', + component: Layout, + redirect: 'projectManagement', + children: [ + { + path: 'projectManagement', + component: () => import('@/views/projectManagement/index'), + name: 'ProjectManagement', + meta: { title: '项目管理', icon: 'el-icon-s-management', affix: true } + } + ] + }, + { + path: '/storageManagement', + component: Layout, + redirect: 'storageManagement', + children: [ + { + path: 'storageManagement', + component: () => import('@/views/storageManagement/index'), + name: 'StorageManagement', + meta: { title: '存储管理', icon: 'el-icon-s-management', affix: true } + } + ] + }, + // ], + // }, // { // path: '/documentation', // component: Layout, diff --git a/src/settings.js b/src/settings.js index 1ebc7f2..6e46003 100644 --- a/src/settings.js +++ b/src/settings.js @@ -5,7 +5,7 @@ module.exports = { * @type {boolean} true | false * @description Whether show the settings right-panel */ - showSettings: true, + showSettings: false, /** * @type {boolean} true | false diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 7800941..782c16b 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,4 +1,4 @@ -import { login, logout, getInfo } from '@/api/user' +import { login, getInfo } from '@/api/user' import { getToken, setToken, removeToken } from '@/utils/auth' import router, { resetRouter } from '@/router' @@ -33,10 +33,10 @@ const actions = { login({ commit }, userInfo) { const { username, password } = userInfo return new Promise((resolve, reject) => { - login({ username: username.trim(), password: password }).then(response => { - const { data } = response - commit('SET_TOKEN', data.token) - setToken(data.token) + login({ 'grant_type': 'password', 'username': username.trim(), 'password': password }).then(response => { + console.log(response) + commit('SET_TOKEN', response.access_token) + setToken(response.access_token) resolve() }).catch(error => { reject(error) @@ -75,20 +75,20 @@ const actions = { // user logout logout({ commit, state, dispatch }) { return new Promise((resolve, reject) => { - logout(state.token).then(() => { - commit('SET_TOKEN', '') - commit('SET_ROLES', []) - removeToken() - resetRouter() + // logout(state.token).then(() => { + commit('SET_TOKEN', '') + commit('SET_ROLES', []) + removeToken() + resetRouter() - // reset visited views and cached views - // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485 - dispatch('tagsView/delAllViews', null, { root: true }) + // reset visited views and cached views + // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485 + dispatch('tagsView/delAllViews', null, { root: true }) - resolve() - }).catch(error => { - reject(error) - }) + resolve() + // }).catch(error => { + // reject(error) + // }) }) }, diff --git a/src/styles/index.scss b/src/styles/index.scss index 96095ef..df319c6 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -24,6 +24,7 @@ html { #app { height: 100%; + color: #2c3e50; } *, @@ -189,3 +190,19 @@ aside { .multiselect--active { z-index: 1000 !important; } + +span.tips { + display: block; + line-height: 1em; + margin-top: 5px; + color: #999999; +} + +.chartCard .el-card__body { + padding: 0 20px; + height: 260px; +} + +.el-table th { + background: #F5F7FA; +} \ No newline at end of file diff --git a/src/utils/auth.js b/src/utils/auth.js index 08a43d6..8396c6a 100644 --- a/src/utils/auth.js +++ b/src/utils/auth.js @@ -1,6 +1,6 @@ import Cookies from 'js-cookie' -const TokenKey = 'Admin-Token' +const TokenKey = 'access_token' export function getToken() { return Cookies.get(TokenKey) diff --git a/src/utils/request.js b/src/utils/request.js index 2fb95ac..c867516 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,10 +1,13 @@ import axios from 'axios' -import { MessageBox, Message } from 'element-ui' +import { Message } from 'element-ui' import store from '@/store' import { getToken } from '@/utils/auth' // create an axios instance const service = axios.create({ + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url // withCredentials: true, // send cookies when cross-domain requests timeout: 5000 // request timeout @@ -16,10 +19,7 @@ service.interceptors.request.use( // do something before request is sent if (store.getters.token) { - // let each request carry token - // ['X-Token'] is a custom headers key - // please modify it according to the actual situation - config.headers['X-Token'] = getToken() + config.headers['Authorization'] = 'Bearer ' + getToken() } return config }, @@ -46,7 +46,7 @@ service.interceptors.response.use( const res = response.data // if the custom code is not 20000, it is judged as an error. - if (res.code !== 20000) { + if (response.status !== 200) { Message({ message: res.message || 'Error', type: 'error', @@ -54,18 +54,18 @@ service.interceptors.response.use( }) // 50008: Illegal token; 50012: Other clients logged in; 50014: Token expired; - if (res.code === 50008 || res.code === 50012 || res.code === 50014) { - // to re-login - MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', { - confirmButtonText: 'Re-Login', - cancelButtonText: 'Cancel', - type: 'warning' - }).then(() => { - store.dispatch('user/resetToken').then(() => { - location.reload() - }) - }) - } + // if (res.code === 50008 || res.code === 50012 || res.code === 50014) { + // // to re-login + // MessageBox.confirm('You have been logged out, you can cancel to stay on this page, or log in again', 'Confirm logout', { + // confirmButtonText: 'Re-Login', + // cancelButtonText: 'Cancel', + // type: 'warning' + // }).then(() => { + // store.dispatch('user/resetToken').then(() => { + // location.reload() + // }) + // }) + // } return Promise.reject(new Error(res.message || 'Error')) } else { return res diff --git a/src/views/error-page/401.vue b/src/views/error-page/401.vue index a52ed23..b014fb8 100644 --- a/src/views/error-page/401.vue +++ b/src/views/error-page/401.vue @@ -10,27 +10,19 @@ gif来源airbnb 页面

你没有权限去该页面

-
如有不满请联系你领导
Girl has dropped her ice cream. - - - diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 2590640..9355af6 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -47,42 +47,20 @@ Login -
-
- Username : admin - Password : any -
-
- Username : editor - Password : any -
- - - Or connect with - -
- - - Can not be simulated on local, so please combine you own business simulation! ! ! -
-
-
- -
diff --git a/src/views/nodeManagement/index.vue b/src/views/nodeManagement/index.vue new file mode 100644 index 0000000..3b9c60c --- /dev/null +++ b/src/views/nodeManagement/index.vue @@ -0,0 +1,54 @@ + + + + + diff --git a/src/views/overview/index.vue b/src/views/overview/index.vue new file mode 100644 index 0000000..ab9035a --- /dev/null +++ b/src/views/overview/index.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/views/projectManagement/index.vue b/src/views/projectManagement/index.vue new file mode 100644 index 0000000..d72d59e --- /dev/null +++ b/src/views/projectManagement/index.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/src/views/storageManagement/index.vue b/src/views/storageManagement/index.vue new file mode 100644 index 0000000..2980549 --- /dev/null +++ b/src/views/storageManagement/index.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/vue.config.js b/vue.config.js index 33a6348..0aa9379 100644 --- a/vue.config.js +++ b/vue.config.js @@ -36,7 +36,14 @@ module.exports = { warnings: false, errors: true }, - before: require('./mock/mock-server.js') + proxy: { + '/': { + ws: false, + target: 'http://192.168.0.86:30881/', + // changeOrigin: true, + }, + }, + // before: require('./mock/mock-server.js') }, configureWebpack: { // provide the app's title in webpack's name field, so that