diff --git a/src/components/Header/index.js b/src/components/Header/index.js
index ddc45d3..dbb4fa9 100644
--- a/src/components/Header/index.js
+++ b/src/components/Header/index.js
@@ -1,30 +1,29 @@
import React from 'react';
-import {Icon, Menu, Dropdown} from 'antd';
-import globalConfig from 'config';
+import { Icon, Menu, Dropdown } from 'antd';
+import { config, ajax, signOut } from '../../utils/lib.js'
import './index.less';
-const SubMenu = Menu.SubMenu; // 为了使用方便
-
-/**
- * 定义Header组件, 包括登录/注销的链接, 以及一些自定义链接
- */
-class Header extends React.Component {
+const SubMenu = Menu.SubMenu;
+let Header = React.createClass({
+ signOut(){
+ ajax({
+ url:config.user.signOut
+ })
+ },
render() {
return (
- {/*定义header中的菜单*/}
);
}
+})
-}
-
-export default Header;
+module.exports = Header
diff --git a/src/config.js b/src/config.js
index b38f513..b0577f8 100644
--- a/src/config.js
+++ b/src/config.js
@@ -5,97 +5,17 @@ module.exports = {
logoText:'Ant Design',
debug: true,
logLevel: 'debug',
- needLogin:false,
+ needLogin:true,
api: {
- host: 'http://localhost',
+ host: 'http://localhost:8080',
path: '/api',
timeout: 15000,
},
- login: {
- getCurrentUser: '/getCurrentUser',
- sso: '',
- validate: '/login',
- logout: '/logout',
- },
-
- /**
- * 是否要跨域请求
- *
- * @returns {boolean}
- */
- isCrossDomain: function () {
- if (this.api.host && this.api.host !== '') {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * 是否单点登录
- *
- * @returns {boolean}
- */
- isSSO: function () {
- if (this.login.sso && this.login.sso !== '') {
- return true;
- } else {
- return false;
- }
- },
-
- /**
- * 获得api请求的路径
- *
- * @returns {*}
- */
- getAPIPath: function () {
- if (this.tmpApiPath) { // 缓存
- return this.tmpApiPath;
- }
-
- const paths = [];
-
- // js的字符串处理真是麻烦
- if (this.isCrossDomain()) {
- // 去除结尾的'/'
- const tmp = this.api.host;
- let index = tmp.length - 1;
- // 如果超出指定的 index 范围,charAt返回一个空字符串
- while (tmp.charAt(index) === '/') {
- index--;
- }
- if (index < 0)
- paths.push('');
- else
- paths.push(tmp.substring(0, index + 1));
- } else {
- paths.push('');
- }
-
- if (this.api.path) {
- const tmp = this.api.path;
- let begin = 0;
- let end = tmp.length - 1;
-
- while (tmp.charAt(begin) === '/') {
- begin++;
- }
- while (tmp.charAt(end) === '/') {
- end--;
- }
- if (begin > end)
- paths.push('');
- else
- paths.push(tmp.substring(begin, end + 1));
- } else {
- paths.push('');
- }
-
- const tmpApiPath = paths.join('/');
- this.tmpApiPath = tmpApiPath;
- return tmpApiPath;
+ user: {
+ info: '/getInfo',
+ signIn: '/signIn',
+ signOut:'/signOut',
},
};
diff --git a/src/index.html b/src/index.html
index e857d8f..f77f60c 100644
--- a/src/index.html
+++ b/src/index.html
@@ -8,7 +8,7 @@
-
+