refactor: Add redux, ConfigProvider

This commit is contained in:
王彦民 2018-11-18 23:17:22 +08:00
parent f8b03c321a
commit a1f6974690
37 changed files with 402 additions and 779 deletions

View File

@ -1,6 +1,5 @@
{
"presets": [
"env",
"react-app"
],
"plugins": [

View File

@ -40,14 +40,14 @@ module.exports = {
include: [resolve('src')],
}, {
test: /\.(js|jsx)$/,
exclude: /node_modules/,
include: [resolve('src')],
use: ['babel-loader'],
}, {
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
loader: 'url-loader',
options: {
limit: 10000,
name: '/images/[name].[hash:8].[ext]',
name: '/img/[name].[hash:8].[ext]',
},
}, {
test: /\.(ttf|woff|svg)$/,
@ -66,12 +66,10 @@ module.exports = {
template: './public/index.html',
minify: !isDev,
}),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../public'),
new CopyWebpackPlugin([{
from: resolve('public'),
to: './',
ignore: ['index.html'],
},
]),
}]),
],
};

View File

@ -67,11 +67,9 @@
"dependencies": {
"@alifd/next": "^1.9.19",
"axios": "^0.18.0",
"dva": "^2.4.1",
"jquery": "^3.3.1",
"moment": "^2.22.2",
"prop-types": "^15.6.2",
"query-string": "^6.2.0",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-redux": "^5.1.0",

View File

@ -28,7 +28,6 @@
<link rel="stylesheet" type="text/css" href="css/icon.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
<!-- 第三方css结束 -->
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
@ -49,9 +48,7 @@
<script src="js/diff_match_patch.js"></script>
<script src="js/merge.js"></script>
<script src="js/loader.js"></script>
<!-- 第三方js结束 -->
<script src="index.js"></script>
</body>
</html>

View File

@ -12,7 +12,8 @@
*/
import React from 'react';
import { aliwareIntl } from '../../globalLib';
import { aliwareIntl } from '@/globalLib';
import { isParentEdas } from '@/lib';
import './index.scss';
import { Balloon, Button, Dialog, Form, Icon, Select, Upload } from '@alifd/next';
@ -50,8 +51,6 @@ class ImportDialog extends React.Component {
};
}
componentDidMount() {}
openDialog(payload, callback) {
this.callback = callback;
this.setState({
@ -96,7 +95,7 @@ class ImportDialog extends React.Component {
this.state.tenant.id
}?policy=${this.state.policy}`;
if (window.globalConfig.isParentEdas()) {
if (isParentEdas()) {
uploadLink = `/authgw/${window.edasprefix}${uploadLink}`;
}
const helpTip = (

View File

@ -0,0 +1,5 @@
export const LANGUAGE_KEY = 'site_language';
export const LANGUAGE_SWITCH = 'LANGUAGE_SWITCH';
// TODO: 后端暂时没有统一成功失败标记
// export const SUCCESS_RESULT_CODE = 'SUCCESS';

View File

@ -1,109 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* 入口页
*/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'dva';
import MainLayout from '../layouts/MainLayout';
import { Message, Loading } from '@alifd/next';
import _menu from '../menu';
import { nacosEvent } from '../globalLib';
class App extends Component {
constructor(props) {
super(props);
this.state = {
shownotice: 'none',
noticecontent: '',
nacosLoading: {},
};
}
componentDidMount() {
// 监听loading事件
nacosEvent.listenAllTask('nacosLoadingEvent', nacosLoading => {
this.setState({
nacosLoading,
});
});
}
UNSAFE_componentWillUpdate(nextProps, nextState) {
const { errcode, errinfo } = nextProps;
if (errcode === 1) {
this.openErr(errinfo);
}
}
componentWillUnmount() {
nacosEvent.remove('nacosLoadingEvent');
}
openErr(message) {
const self = this;
setTimeout(() => {
self.props.dispatch({ type: 'error/clear' });
}, 3000);
}
getChildContext() {
return { history: this.props.history };
}
render() {
const { errcode, errinfo } = this.props;
return (
<Loading
className="nacos-loading"
shape="flower"
tip="loading..."
visible={false}
fullScreen
{...this.state.nacosLoading}
>
<MainLayout {...this.props} navList={_menu.data}>
{errcode === 1 ? (
<Message
title={errinfo}
closable
style={{
position: 'absolute',
zIndex: 99999,
width: 800,
left: '50%',
marginLeft: -400,
}}
/>
) : null}
{this.props.children}
</MainLayout>
</Loading>
);
}
}
App.propTypes = {};
App.childContextTypes = {
history: PropTypes.object,
};
function mapStateToProps(state) {
const { errinfo, errcode } = state.error;
return {
errinfo,
errcode,
};
}
export default connect(mapStateToProps)(App);

View File

@ -12,7 +12,6 @@
*/
import projectConfig from './config';
import serviceConfig from './serviceMock';
import moment from 'moment';
import $ from 'jquery';
import i18DocObj from './i18ndoc';
@ -455,8 +454,8 @@ const request = (function(_global) {
const middlewareList = [];
const middlewareBackList = [];
const serviceMap = {};
const serviceList = serviceConfig.serviceList || [];
const methodList = serviceConfig.method || [];
const serviceList = [];
const methodList = [];
/**
* 获取真实url信息
*/

View File

@ -11,23 +11,122 @@
* limitations under the License.
*/
import dva from 'dva';
import '@alifd/next/dist/next.css';
/**
* 入口页
*/
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore, combineReducers, compose, applyMiddleware } from 'redux';
import { routerReducer } from 'react-router-redux';
import thunk from 'redux-thunk';
import { Provider, connect } from 'react-redux';
import { HashRouter, Route, Switch, Redirect } from 'react-router-dom';
import { ConfigProvider, Loading } from '@alifd/next';
import _menu from './menu';
import Layout from './layouts/MainLayout';
import CookieHelp from './utils/cookie';
import { LANGUAGE_KEY } from './constants';
import Namespace from './pages/NameSpace';
import Newconfig from './pages/ConfigurationManagement/NewConfig';
import Configsync from './pages/ConfigurationManagement/ConfigSync';
import Configdetail from './pages/ConfigurationManagement/ConfigDetail';
import Configeditor from './pages/ConfigurationManagement/ConfigEditor';
import HistoryDetail from './pages/ConfigurationManagement/HistoryDetail';
import ConfigRollback from './pages/ConfigurationManagement/ConfigRollback';
import HistoryRollback from './pages/ConfigurationManagement/HistoryRollback';
import ListeningToQuery from './pages/ConfigurationManagement/ListeningToQuery';
import ConfigurationManagement from './pages/ConfigurationManagement/ConfigurationManagement';
import ServiceList from './pages/ServiceManagement/ServiceList';
import ServiceDetail from './pages/ServiceManagement/ServiceDetail';
import * as reducers from './reducers';
import { changeLanguage } from './reducers/locale';
import './index.scss';
import './index1.scss';
// 1. Initialize
const app = dva();
if (!CookieHelp.getValue(LANGUAGE_KEY)) {
CookieHelp.setValue(LANGUAGE_KEY, navigator.language === 'zh-CN' ? 'zh-CN' : 'en-US');
}
// 2. Plugins
// app.use({});
const reducer = combineReducers({
...reducers,
routing: routerReducer,
});
// 3. Model
// app.model(require('./models/example').default);
app.model(require('./models/error').default);
app.model(require('./models/loading').default);
// 4. Router
app.router(require('./router').default);
const store = createStore(
reducer,
compose(
applyMiddleware(thunk),
window.devToolsExtension ? window.devToolsExtension() : f => f
)
);
// 5. Start
app.start('#root');
@connect(
state => ({ ...state.locale }),
{ changeLanguage }
)
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
shownotice: 'none',
noticecontent: '',
nacosLoading: {},
};
}
componentDidMount() {
const language = CookieHelp.getValue(LANGUAGE_KEY);
this.props.changeLanguage(language);
}
generateRouter() {
return (
<HashRouter>
<Layout navList={_menu.data}>
<Switch>
<Route path="/" exact render={() => <Redirect to="/configurationManagement" />} />
<Route path="/namespace" component={Namespace} />
<Route path="/newconfig" component={Newconfig} />
<Route path="/configsync" component={Configsync} />
<Route path="/configdetail" component={Configdetail} />
<Route path="/configeditor" component={Configeditor} />
<Route path="/historyDetail" component={HistoryDetail} />
<Route path="/configRollback" component={ConfigRollback} />
<Route path="/historyRollback" component={HistoryRollback} />
<Route path="/listeningToQuery" component={ListeningToQuery} />
<Route path="/configurationManagement" component={ConfigurationManagement} />
<Route path="/serviceManagement" component={ServiceList} />
<Route path="/serviceDetail" component={ServiceDetail} />
</Switch>
</Layout>
</HashRouter>
);
}
render() {
const { locale } = this.props;
return (
<Loading
className="nacos-loading"
shape="flower"
tip="loading..."
visible={false}
fullScreen
{...this.state.nacosLoading}
>
<ConfigProvider locale={locale}>{this.generateRouter()}</ConfigProvider>
</Loading>
);
}
}
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
);

View File

@ -11,6 +11,57 @@
* limitations under the License.
*/
html,
body,
:global(#root) {
height: 100%;
}
:global(.mainwrapper) {
position: absolute !important;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
:global(.sideleft) {
float: left;
background-color: #eaedf1;
position: absolute;
top: 0px;
bottom: 0px;
z-index: 2;
overflow: hidden;
width: 180px;
}
:global(.sideleft .toptitle) {
width: 100%;
height: 70px;
line-height: 70px;
background: #d9dee4;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
text-indent: 20px;
}
:global(.maincontainer) {
position: absolute;
width: auto;
top: 0px;
bottom: 0px;
left: 180px;
right: 0px;
overflow: hidden;
overflow-y: auto;
-o-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
}
:global(.viewFramework-product-navbar .product-nav-list li .active) {
background-color: #fff !important;
}
.clearfix:after {
content: '.';
clear: both;

View File

@ -1,63 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
html,
body,
:global(#root) {
height: 100%;
}
:global(.mainwrapper) {
position: absolute !important;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
:global(.sideleft) {
float: left;
background-color: #eaedf1;
position: absolute;
top: 0px;
bottom: 0px;
z-index: 2;
overflow: hidden;
width: 180px;
}
:global(.sideleft .toptitle) {
width: 100%;
height: 70px;
line-height: 70px;
background: #d9dee4;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-weight: bold;
text-indent: 20px;
}
:global(.maincontainer) {
position: absolute;
width: auto;
top: 0px;
bottom: 0px;
left: 180px;
right: 0px;
overflow: hidden;
overflow-y: auto;
-o-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-webkit-transition: all 0.2s ease;
}
:global(.viewFramework-product-navbar .product-nav-list li .active) {
background-color: #fff !important;
}

View File

@ -62,15 +62,8 @@ class Header extends React.Component {
}
switchLang() {
let language;
if (this.state.language === 'zh-cn') {
language = 'en-us';
} else {
language = 'zh-cn';
}
this.setState({
language,
});
const language = this.state.language === 'zh-cn' ? 'en-us' : 'zh-cn';
this.setState({ language });
this.props.onLanguageChange(language);
}

View File

@ -12,6 +12,7 @@
*/
import React from 'react';
import { withRouter } from 'react-router-dom';
import PropTypes from 'prop-types';
import { Icon } from '@alifd/next';
import siteConfig from '../config';
@ -19,7 +20,8 @@ import Header from './Header';
import $ from 'jquery';
import { aliwareGetCookieByKeyName, setParams, aliwareIntl } from '../globalLib';
export default class MainLayout extends React.Component {
@withRouter
class MainLayout extends React.Component {
static propTypes = {
navList: PropTypes.array,
history: PropTypes.object,
@ -464,3 +466,5 @@ export default class MainLayout extends React.Component {
);
}
}
export default MainLayout;

View File

@ -16,15 +16,11 @@ let hasAlert = false;
window.edasprefix = 'acm'; // 固定的edas网关需要的项目名
export const isParentEdas = () =>
window.parent && window.parent.location.host.indexOf('edas') !== -1;
window.globalConfig = {
isParentEdas() {
try {
if (window.parent.location.host.indexOf('edas') !== -1) {
return true;
}
} catch (error) {}
return false;
},
isParentEdas,
};
request.middleWare((_config = {}) => {
@ -199,3 +195,5 @@ window.isIntel = function() {
const { host } = window.location;
return host.indexOf('alibabacloud.com') !== -1;
};
export default {};

View File

@ -0,0 +1,10 @@
const I18N_CONF = {
Header: {
home: 'HOME',
docs: 'DOCS',
blog: 'BLOG',
community: 'COMMUNITY',
languageSwitchButton: '中',
},
};
export default I18N_CONF;

View File

@ -0,0 +1,4 @@
import enUS from './en-US';
import zhCN from './zh-CN';
export default { enUS, zhCN };

View File

@ -0,0 +1,10 @@
const I18N_CONF = {
Header: {
home: '首页',
docs: '文档',
blog: '博客',
community: '社区',
languageSwitchButton: 'En',
},
};
export default I18N_CONF;

View File

@ -1,44 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
namespace: 'error',
state: {
errinfo: '未知错误',
errcode: 0,
erralert: false,
},
subscriptions: {
setup({ dispatch, history }) {
// eslint-disable-line
},
},
effects: {
*fetch({ payload }, { call, put }) {
// eslint-disable-line
yield put({ type: 'save' });
},
},
reducers: {
save(state, action) {
return { ...state, ...action.payload, errcode: 1 };
},
clear(state, action) {
return { ...state, errinfo: '', errcode: 0 };
},
},
};

View File

@ -1,37 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
namespace: 'example',
state: {},
subscriptions: {
setup({ dispatch, history }) {
// eslint-disable-line
},
},
effects: {
*fetch({ payload }, { call, put }) {
// eslint-disable-line
yield put({ type: 'save' });
},
},
reducers: {
save(state, action) {
return { ...state, ...action.payload };
},
},
};

View File

@ -1,49 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
namespace: 'loading',
state: {
loading: false,
},
subscriptions: {
setup({ dispatch, history }) {
// eslint-disable-line
},
},
effects: {
*open({ payload }, { call, put }) {
try {
yield put({ type: 'save', payload: { loading: true } });
} catch (e) {
yield put({ type: 'error/save', payload: { errinfo: e.message } });
}
},
*close({ payload }, { call, put }) {
try {
yield put({ type: 'save', payload: { loading: false } });
} catch (e) {
yield put({ type: 'error/save', payload: { errinfo: e.message } });
}
},
},
reducers: {
save(state, action) {
return { ...state, ...action.payload };
},
},
};

View File

@ -13,15 +13,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import BatchHandle from '../../../components/BatchHandle';
import RegionGroup from '../../../components/RegionGroup';
import ShowCodeing from '../../../components/ShowCodeing';
import DeleteDialog from '../../../components/DeleteDialog';
import CloneDialog from '../../../components/CloneDialog';
import ImportDialog from '../../../components/ImportDialog';
import ExportDialog from '../../../components/ExportDialog';
import BatchHandle from 'components/BatchHandle';
import RegionGroup from 'components/RegionGroup';
import ShowCodeing from 'components/ShowCodeing';
import DeleteDialog from 'components/DeleteDialog';
import CloneDialog from 'components/CloneDialog';
import ImportDialog from 'components/ImportDialog';
import ExportDialog from 'components/ExportDialog';
import { getParams, setParams, request, aliwareIntl } from '../../../globalLib';
import './index.scss';
import {
Balloon,
Button,
@ -41,6 +40,8 @@ import {
Table,
} from '@alifd/next';
import './index.scss';
const { Panel } = Collapse;
const DashboardCard = ({ data = {}, height }) => (

View File

@ -362,6 +362,7 @@ class HistoryRollback extends React.Component {
margin: 0,
paddingLeft: 10,
borderLeft: '3px solid #09c',
fontSize: 16,
}}
>
{aliwareIntl.get('com.alibaba.nacos.page.historyRollback.queryresult')}

View File

@ -281,6 +281,7 @@ class ListeningToQuery extends React.Component {
borderLeft: '3px solid #09c',
margin: 0,
marginBottom: 10,
fontSize: 16,
}}
>
{aliwareIntl.get('com.alibaba.nacos.page.listeningToQuery.query_results:_query')}

View File

@ -17,7 +17,6 @@ import { Button, Card, Form, Loading } from '@alifd/next';
import EditServiceDialog from './EditServiceDialog';
import EditClusterDialog from './EditClusterDialog';
import InstanceTable from './InstanceTable';
import queryString from 'query-string';
import { I18N } from './constant';
import './ServiceDetail.scss';
@ -31,7 +30,7 @@ class ServiceDetail extends React.Component {
constructor(props) {
super(props);
this.state = {
serviceName: queryString.parse(props.location.search).name,
serviceName: props.location.search.name,
loading: false,
currentPage: 1,
clusters: [],

View File

@ -0,0 +1,3 @@
import locale from './locale';
export default { locale };

View File

@ -0,0 +1,30 @@
import fusionEnUS from '@alifd/next/lib/locale/en-us';
import fusionZhCN from '@alifd/next/lib/locale/zh-cn';
import I18N from '../locales';
import { LANGUAGE_KEY, LANGUAGE_SWITCH } from '../constants';
import CookieHelp from '../utils/cookie';
const enUS = Object.assign({}, fusionEnUS, I18N.enUS);
const zhCN = Object.assign({}, fusionZhCN, I18N.zhCN);
const initialState = {
language: 'en-US',
locale: enUS,
};
const changeLanguage = lang => dispatch => {
const language = lang === 'zh-CN' ? 'zh-CN' : 'en-US';
CookieHelp.setValue(LANGUAGE_KEY, language);
dispatch({ type: LANGUAGE_SWITCH, language, locale: language === 'zh-CN' ? zhCN : enUS });
};
export default (state = initialState, action) => {
switch (action.type) {
case LANGUAGE_SWITCH:
return { ...state, ...action };
default:
return state;
}
};
export { changeLanguage };

View File

@ -1,58 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import PropTypes from 'prop-types';
import { Router, Route, Switch } from 'dva/router';
import './lib.js';
import App from './containers/App';
import Namespace from './pages/NameSpace';
import Newconfig from './pages/ConfigurationManagement/NewConfig';
import Configsync from './pages/ConfigurationManagement/ConfigSync';
import Configdetail from './pages/ConfigurationManagement/ConfigDetail';
import Configeditor from './pages/ConfigurationManagement/ConfigEditor';
import HistoryDetail from './pages/ConfigurationManagement/HistoryDetail';
import ConfigRollback from './pages/ConfigurationManagement/ConfigRollback';
import HistoryRollback from './pages/ConfigurationManagement/HistoryRollback';
import ListeningToQuery from './pages/ConfigurationManagement/ListeningToQuery';
import ConfigurationManagement from './pages/ConfigurationManagement/ConfigurationManagement';
import ServiceList from './pages/ServiceManagement/ServiceList';
import ServiceDetail from './pages/ServiceManagement/ServiceDetail';
function RouterConfig({ history }) {
return (
<Router history={history}>
<Switch>
<App history={history}>
<Route path="/Namespace" component={Namespace} />
<Route path="/Newconfig" component={Newconfig} />
<Route path="/Configsync" component={Configsync} />
<Route path="/Configdetail" component={Configdetail} />
<Route path="/Configeditor" component={Configeditor} />
<Route path="/HistoryDetail" component={HistoryDetail} />
<Route path="/ConfigRollback" component={ConfigRollback} />
<Route path="/HistoryRollback" component={HistoryRollback} />
<Route path="/ListeningToQuery" component={ListeningToQuery} />
<Route path="/ConfigurationManagement" component={ConfigurationManagement} />
<Route path="/ServiceManagement" component={ServiceList} />
<Route path="/ServiceDetail" component={ServiceDetail} />
</App>
</Switch>
</Router>
);
}
RouterConfig.propTypes = {
history: PropTypes.object,
};
export default RouterConfig;

View File

@ -1,40 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { connect } from 'dva';
import styles from './IndexPage.scss';
function IndexPage() {
return (
<div className={styles.normal}>
<div className="test" />
<h1 className={styles.title}>Yay! Welcome to dva!</h1>
<div className={styles.welcome} />
<ul className={styles.list}>
<li>
To get started, edit <code>src/index.js</code> and save to reload.
</li>
<li>
<a href="https://github.com/dvajs/dva-docs/blob/master/v1/en-us/getting-started.md">
Getting Started
</a>
</li>
</ul>
</div>
);
}
IndexPage.propTypes = {};
export default connect()(IndexPage);

View File

@ -1,41 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.normal {
font-family: Georgia, sans-serif;
margin-top: 3em;
text-align: center;
}
.title {
font-size: 2.5rem;
font-weight: normal;
letter-spacing: -1px;
}
.welcome {
height: 328px;
background: url(../assets/yay.jpg) no-repeat center 0;
background-size: 388px 328px;
}
.list {
font-size: 1.2em;
margin-top: 1.8em;
list-style: none;
line-height: 1.5em;
}
.list code {
background: #f7f7f7;
}

View File

@ -1,207 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = {
method: ['get', 'post', 'put', 'delete', 'patch'],
serviceList: [
{
registerName: 'com.alibaba.nacos.service.dashlist',
name: '',
registerTo: null,
url: '/diamond-ops/info',
defaults: '{}',
params: '{}',
config: null,
initialize: null,
share: 0,
exports: null,
proxy: '',
serviceDoc: null,
ctime: '2018-05-19T07:24:01.000Z',
mtime: '2018-08-28T10:19:46.000Z',
author_id: 23,
project_id: 'nacos',
is_mock: 0,
method: 0,
is_param: 0,
is_proxy: 0,
cookie: '{}',
header: '{}',
isJsonData: 0,
paramsType: '[]',
autoLoading: 0,
},
{
registerName: 'com.alibaba.nacos.service.getLink',
name: 'getLink',
registerTo: null,
url: '/diamond-ops/viper/getLink',
defaults: '{}',
params: '{}',
config: null,
initialize: null,
share: 0,
exports: null,
proxy: '',
serviceDoc: null,
ctime: '2017-12-03T07:38:56.000Z',
mtime: '2018-08-28T10:19:46.000Z',
author_id: 23,
project_id: 'nacos',
is_mock: 0,
method: 0,
is_param: 0,
is_proxy: 0,
cookie: '{}',
header: '{}',
isJsonData: 0,
paramsType: '[]',
autoLoading: 0,
},
{
registerName: 'com.alibaba.nacos.service.getLinks',
name: 'getLinks',
registerTo: null,
url: '/diamond-ops/viper/getLinks',
defaults: '{}',
params: '{}',
config: null,
initialize: null,
share: 0,
exports: null,
proxy: '',
serviceDoc: null,
ctime: '2017-12-03T07:38:56.000Z',
mtime: '2018-08-28T10:19:46.000Z',
author_id: 23,
project_id: 'nacos',
is_mock: 0,
method: 0,
is_param: 0,
is_proxy: 0,
cookie: '{}',
header: '{}',
isJsonData: 0,
paramsType: '[]',
autoLoading: 0,
},
{
registerName: 'com.alibaba.nacos.service.deleteNameSpace',
name: '删除命名空间',
registerTo: null,
url: '/diamond-ops/service/serverId/{serverId}/namespace/{namespace}',
defaults: '{}',
params: '{}',
config: null,
initialize: null,
share: 0,
exports: null,
proxy: '',
serviceDoc: null,
ctime: '2017-12-03T07:38:56.000Z',
mtime: '2018-08-28T10:19:46.000Z',
author_id: 23,
project_id: 'nacos',
is_mock: 0,
method: 3,
is_param: 0,
is_proxy: 0,
cookie: '{}',
header: '{}',
isJsonData: 0,
paramsType: '[]',
autoLoading: 0,
},
{
registerName: 'com.alibaba.nacos.service.getMetaData',
name: '获取metaData',
registerTo: null,
url: '/diamond-ops/meta/data',
defaults: '{}',
params: '{}',
config: null,
initialize: null,
share: 0,
exports: null,
proxy: '',
serviceDoc: null,
ctime: '2017-12-03T07:38:56.000Z',
mtime: '2018-08-28T10:19:46.000Z',
author_id: 23,
project_id: 'nacos',
is_mock: 0,
method: 0,
is_param: 0,
is_proxy: 0,
cookie: '{}',
header: '{}',
isJsonData: 0,
paramsType: '[]',
autoLoading: 0,
},
{
registerName: 'com.alibaba.nacos.service.sendVerifyCode',
name: '发送验证码',
registerTo: null,
url: '/diamond-ops/meta/sendVerifyCode',
defaults: '{}',
params: '{}',
config: null,
initialize: null,
share: 0,
exports: null,
proxy: '',
serviceDoc: null,
ctime: '2017-12-03T07:38:56.000Z',
mtime: '2018-08-28T10:19:46.000Z',
author_id: 23,
project_id: 'nacos',
is_mock: 0,
method: 0,
is_param: 0,
is_proxy: 0,
cookie: '{}',
header: '{}',
isJsonData: 0,
paramsType: '[]',
autoLoading: 0,
},
{
registerName: 'com.alibaba.nacos.service.getDomain',
name: '获取region',
registerTo: null,
url: '/diamond-ops/env/domain',
defaults: '{}',
params: '{}',
config: null,
initialize: null,
share: 0,
exports: null,
proxy: '',
serviceDoc: null,
ctime: '2017-12-03T07:38:56.000Z',
mtime: '2018-08-28T10:19:46.000Z',
author_id: 23,
project_id: 'nacos',
is_mock: 0,
method: 0,
is_param: 0,
is_proxy: 0,
cookie: '{}',
header: '{}',
isJsonData: 0,
paramsType: '[]',
autoLoading: 0,
},
],
};

View File

@ -1,18 +0,0 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import request from '../utils/request';
export function query() {
return request('/api/users');
}

View File

@ -0,0 +1,15 @@
function getValue(key) {
if (!document.cookie) return null;
const list = document.cookie.split(';') || [];
for (const item of list) {
const [k, v] = item.split('=');
if (k === key) return v;
}
return null;
}
function setValue(key, value) {
document.cookie = `${key}=${value}`;
}
export default { getValue, setValue };

View File

@ -1,43 +1,33 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import axios from 'axios';
import { Message } from '@alifd/next';
// import { SUCCESS_RESULT_CODE } from '../constants';
import fetch from 'dva/fetch';
const API_GENERAL_ERROR_MESSAGE = 'Request error, please try again later!';
function parseJSON(response) {
return response.json();
}
const request = () => {
const instance = axios.create();
function checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
return response;
instance.interceptors.response.use(
response => {
const { success, resultCode, resultMessage = API_GENERAL_ERROR_MESSAGE } = response.data;
// if (!success && resultCode !== SUCCESS_RESULT_CODE) {
// Message.error(resultMessage);
// return Promise.reject(new Error(resultMessage));
// }
return response.data;
},
error => {
if (error.response) {
const { status } = error.response;
Message.error(`HTTP ERROR: ${status}`);
} else {
Message.error(API_GENERAL_ERROR_MESSAGE);
}
return Promise.reject(error);
}
);
const error = new Error(response.statusText);
error.response = response;
throw error;
}
return instance;
};
/**
* Requests a URL, returning a promise.
*
* @param {string} url The URL we want to request
* @param {object} [options] The options we want to pass to "fetch"
* @return {object} An object containing either "data" or "err"
*/
export default function request(url, options) {
return fetch(url, options)
.then(checkStatus)
.then(parseJSON)
.then(data => ({ data }))
.catch(err => ({ err }));
}
export default request();

File diff suppressed because one or more lines are too long

View File

@ -16,10 +16,10 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Nacos</title>
<link rel="shortcut icon" href="//www.aliyun.com/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="//www.aliyun.com/favicon.ico" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/console1412.css">
<!-- 第三方css开始 -->
@ -28,8 +28,7 @@
<link rel="stylesheet" type="text/css" href="css/icon.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
<!-- 第三方css结束 -->
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<link href="./css/main.dc6c05f1.css" rel="stylesheet"></head>
<body>
<div id="root" style="overflow:hidden"></div>
@ -49,9 +48,7 @@
<script src="js/diff_match_patch.js"></script>
<script src="js/merge.js"></script>
<script src="js/loader.js"></script>
<!-- 第三方js结束 -->
<script src="index.js"></script>
</body>
<script type="text/javascript" src="./js/main.196fdd00.js"></script></body>
</html>

File diff suppressed because one or more lines are too long