Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/webpack.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const baseConfig = {
},
resolve: {
alias: {
// unfetch: "unfetch/dist/unfetch.js",
process: "process/browser",
"aelf-sdk": "aelf-sdk/dist/aelf.umd.js",
"react-use": "react-use/lib",
Expand Down
29 changes: 6 additions & 23 deletions build/webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,29 +71,12 @@ const devConfig = {
// inline: false,
historyApiFallback: true,
proxy: proxyServer,
// before(app) {
// app.all("*", (req, res, next) => {
// let mockFile = mockMapper[req.path];
// if (isObject(mockFile)) {
// mockFile = mockFile[req.query.path];
// }
// if (mockFile && devMode === "local") {
// res.sendFile(
// path.resolve(__dirname, mockFile),
// {
// headers: {
// "Content-Type": "application/json; charset=utf-8",
// },
// },
// (err) => {
// err && console.error(err);
// }
// );
// } else {
// next();
// }
// });
// },
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*",
"Access-Control-Allow-Credentials": "true"
},
},
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"dependencies": {
"@aelf-react/core": "^0.1.19",
"@ant-design/icons": "^4.1.0",
"@ant-design/icons": "4.8.1",
"@babel/preset-typescript": "^7.21.0",
"@babel/runtime": "^7.7.2",
"@hot-loader/react-dom": "^17.0.2",
Expand Down Expand Up @@ -112,6 +112,7 @@
"socket.io-client": "^2.2.0",
"tslib": "^2.5.1",
"uglifyjs-webpack-plugin": "^2.2.0",
"unfetch": "4.2.0",
"vconsole": "^3.15.1",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0",
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function App() {
return (
<Suspense fallback={null}>
<div className="App">
<BrowserRouter>
<BrowserRouter basename={window.__MICRO_APP_BASE_ROUTE__ || "/"}>
<BrowserHeader />
<HeaderBlank />
<BrowserBreadcrumb />
Expand Down
40 changes: 23 additions & 17 deletions src/common/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
* @file 请求方法
* @author atom-yang
*/
import axios from 'axios';
import { omitBy } from 'lodash/fp';
import { isObject } from 'lodash';
import axios from "axios";
import { omitBy } from "lodash/fp";
import { isObject } from "lodash";

const defaultRequestOptions = {
headers: {
'Content-Type': 'application/json;charset=utf-8',
"Content-Type": "application/json;charset=utf-8",
},
withCredentials: true,
method: 'POST',
// withCredentials: true,
method: "POST",
};

const http = axios.create(defaultRequestOptions);

const needPurify = (rawData) => (isObject(rawData) && !Array.isArray(rawData));
const purify = (rawData) => (needPurify(rawData)
? omitBy((value) => value === null
|| value === undefined
|| value === '')(rawData)
: rawData);
const needPurify = (rawData) => isObject(rawData) && !Array.isArray(rawData);
const purify = (rawData) =>
needPurify(rawData)
? omitBy((value) => value === null || value === undefined || value === "")(
rawData
)
: rawData;

/**
* @desc 处理xhr status 200,但是数据status不为200的情况
Expand Down Expand Up @@ -54,12 +55,15 @@ const makeRequestConfig = (url, params, { headers = {}, ...extraOptions }) => {
...extraOptions,
};

if (config.method.toUpperCase() === 'GET') {
if (config.method.toUpperCase() === "GET") {
config.params = data;
} else if (config.method.toUpperCase() === 'POST') {
} else if (config.method.toUpperCase() === "POST") {
config.data = data;
} else {
throw new Error(`don\'t support http method ${config.method.toUpperCase()}`);
throw new Error(
// eslint-disable-next-line no-useless-escape
`don\'t support http method ${config.method.toUpperCase()}`
);
}

return config;
Expand All @@ -71,5 +75,7 @@ const makeRequestConfig = (url, params, { headers = {}, ...extraOptions }) => {
* @param {Object} params 参数
* @param {Object} extraOptions 额外的参数
*/
export const request = (url, params, extraOptions = {}) => http.request(makeRequestConfig(url, params, extraOptions))
.then((res) => handleInvalidError(res), handleRequestError);
export const request = (url, params, extraOptions = {}) =>
http
.request(makeRequestConfig(url, params, extraOptions))
.then((res) => handleInvalidError(res), handleRequestError);
9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author huangzongzhe,longyue,zhouminghui
*/
import React from "react";
import ReactDOM from "react-dom";
import ReactDOM, { unmountComponentAtNode } from "react-dom";
import { Provider } from "react-redux";
import Cookies from "js-cookie";
import VConsole from "vconsole";
Expand All @@ -25,7 +25,7 @@ import "./index.less";
import "./portkey.less";

import "./common/webLoginConfig";

import "./public-path";
import App from "./App";
import { WALLET_IMG } from "./common/constants";
import { isPhoneCheck } from "./common/utils";
Expand Down Expand Up @@ -59,9 +59,14 @@ getNodesInfo();
if (module.hot) {
module.hot.accept();
}
window.addEventListener("unmount", () => {
const root = document.getElementById("app");
root && unmountComponentAtNode(root);
});

const container = document.getElementById("app");
const isMobile = isPhoneCheck();

ReactDOM.render(
<ConfigProvider locale={en_US}>
<Provider store={store}>
Expand Down
10 changes: 5 additions & 5 deletions src/pages/Proposal/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ const App = () => {
const isLogged = useMemo(() => logStatus === LOG_STATUS.LOGGED, [logStatus]);
const { loginState } = useWebLogin();

useEffect(() => {
sendMessage({
href,
});
}, [href]);
// useEffect(() => {
// sendMessage({
// href,
// });
// }, [href]);

// useEffect(() => {
// walletInstance.isExist
Expand Down
39 changes: 34 additions & 5 deletions src/pages/Proposal/containers/OrganizationList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import React, { useEffect, useState } from "react";
import { useSelector, useDispatch, shallowEqual } from "react-redux";
import { useNavigate, Link, useLocation } from "react-router-dom";
import { useEffectOnce } from "react-use";
import {
Tabs,
Pagination,
Expand Down Expand Up @@ -91,24 +92,52 @@ const OrganizationList = () => {
const handleTabChange = (key) => {
if (key === proposalTypes.PARLIAMENT) {
removeHash();
fetchList({
...params,
pageNum: 1,
proposalType: key,
search: "",
});
setActiveKey(proposalTypes.PARLIAMENT);
} else {
const index = Object.values(keyFromHash).findIndex((ele) => ele === key);
window.location.hash = Object.keys(keyFromHash)[index];
}
};

const changeKey = () => {
const { hash } = window.location;
const key = keyFromHash[hash];
setActiveKey(key || proposalTypes.PARLIAMENT);
return key || proposalTypes.PARLIAMENT;
};

useEffectOnce(() => {
const key = changeKey();
fetchList({
...params,
pageNum: 1,
proposalType: key,
search: "",
});
};
window.addEventListener("hashchange", () => {
const { hash } = window.location;
const key = keyFromHash[hash];
setActiveKey(key || proposalTypes.PARLIAMENT);
});

useEffect(() => {
const onHashChange = () => {
const key = changeKey();
fetchList({
...params,
pageNum: 1,
proposalType: key,
search: "",
});
};
window.addEventListener("hashchange", onHashChange);
return () => {
window.removeEventListener("hashchange", onHashChange);
};
}, []);

const editOrganization = (orgAddress) => {
const org = list.filter((item) => item.orgAddress === orgAddress)[0];
Modal.confirm({
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Proposal/containers/ProposalList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ const ProposalList = () => {
const handleTabChange = (key) => {
if (key === proposalTypes.PARLIAMENT) {
removeHash();
fetchList({
...params,
pageNum: 1,
proposalType: key,
status: proposalStatus.ALL,
isContract: 0,
search: "",
});
setActiveKey(proposalTypes.PARLIAMENT);
} else {
const index = Object.values(keyFromHash).findIndex((ele) => ele === key);
Expand Down
4 changes: 4 additions & 0 deletions src/public-path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
if (window.__MICRO_APP_ENVIRONMENT__) {
// eslint-disable-next-line
__webpack_public_path__ = window.__MICRO_APP_PUBLIC_PATH__;
}
Loading