mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-04-23 15:11:26 +00:00
fix problem with file name
This commit is contained in:
parent
fe3aa51bd5
commit
7908cbad4f
@ -53,10 +53,10 @@ export function isApiSuccess (response) {
|
|||||||
return response.status === 'success';
|
return response.status === 'success';
|
||||||
}
|
}
|
||||||
|
|
||||||
const ApiUtil = {
|
const apiUtil = {
|
||||||
getJSON,
|
getJSON,
|
||||||
postJSON,
|
postJSON,
|
||||||
isApiSuccess
|
isApiSuccess
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ApiUtil;
|
export default apiUtil;
|
||||||
|
@ -39,3 +39,4 @@ export function initWs(wsPort = location.port, path = 'do-not-proxy') {
|
|||||||
export default {
|
export default {
|
||||||
initWs: initWs
|
initWs: initWs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
62
web/src/common/apiUtil.js
Normal file
62
web/src/common/apiUtil.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
* AJAX操作工具类
|
||||||
|
*/
|
||||||
|
import PromiseUtil from './promiseUtil';
|
||||||
|
export function getJSON(url, data) {
|
||||||
|
const d = PromiseUtil.defer();
|
||||||
|
fetch(url + serializeQuery(data))
|
||||||
|
.then((data) => {
|
||||||
|
d.resolve(data.json());
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
d.reject(error);
|
||||||
|
});
|
||||||
|
return d.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function postJSON(url, data) {
|
||||||
|
const d = PromiseUtil.defer();
|
||||||
|
fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
|
||||||
|
d.resolve(data.json());
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
d.reject(error);
|
||||||
|
});
|
||||||
|
return d.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
function serializeQuery (data = {}) {
|
||||||
|
data['__t'] = Date.now();// disable the cache
|
||||||
|
const queryArray = [];
|
||||||
|
|
||||||
|
for (let key in data) {
|
||||||
|
queryArray.push(`${key}=${data[key]}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryStr = queryArray.join('&');
|
||||||
|
|
||||||
|
return queryStr ? '?' + queryStr : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isApiSuccess (response) {
|
||||||
|
return response.status === 'success';
|
||||||
|
}
|
||||||
|
|
||||||
|
const apiUtil = {
|
||||||
|
getJSON,
|
||||||
|
postJSON,
|
||||||
|
isApiSuccess
|
||||||
|
};
|
||||||
|
|
||||||
|
export default apiUtil;
|
9
web/src/common/constant.js
Normal file
9
web/src/common/constant.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* define all constant variables here
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports.MenuKeyMap = {
|
||||||
|
RECORD_FILTER: 'RECORD_FILTER',
|
||||||
|
MAP_LOCAL: 'MAP_LOCAL',
|
||||||
|
ROOT_CA: 'ROOT_CA'
|
||||||
|
};
|
42
web/src/common/wsUtil.js
Normal file
42
web/src/common/wsUtil.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Utility for websocket
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
import { message } from 'antd';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiate a ws connection.
|
||||||
|
* The default path `do-not-proxy` means the ws do not need to be proxied.
|
||||||
|
* This is very important for AnyProxy‘s own server, such as WEB UI,
|
||||||
|
* and the websocket detail panel in it, to prevent a recursive proxy.
|
||||||
|
* @param {wsPort} wsPort the port of websocket
|
||||||
|
* @param {key} path the path of the ws url
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
export function initWs(wsPort = location.port, path = 'do-not-proxy') {
|
||||||
|
if(!WebSocket){
|
||||||
|
throw (new Error('WebSocket is not supported on this browser'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const wsClient = new WebSocket(`ws://${location.hostname}:${wsPort}/${path}`);
|
||||||
|
|
||||||
|
wsClient.onerror = (error) => {
|
||||||
|
console.error(error);
|
||||||
|
message.error('error happened when setup websocket');
|
||||||
|
};
|
||||||
|
|
||||||
|
wsClient.onopen = (e) => {
|
||||||
|
console.info('websocket opened: ', e);
|
||||||
|
};
|
||||||
|
|
||||||
|
wsClient.onclose = (e) => {
|
||||||
|
console.info('websocket closed: ', e);
|
||||||
|
};
|
||||||
|
|
||||||
|
return wsClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
initWs: initWs
|
||||||
|
};
|
||||||
|
|
@ -11,7 +11,7 @@ import { message, Button, Spin } from 'antd';
|
|||||||
import ResizablePanel from 'component/resizable-panel';
|
import ResizablePanel from 'component/resizable-panel';
|
||||||
import { hideRootCA, updateIsRootCAExists } from 'action/globalStatusAction';
|
import { hideRootCA, updateIsRootCAExists } from 'action/globalStatusAction';
|
||||||
import { MenuKeyMap } from 'common/constant';
|
import { MenuKeyMap } from 'common/constant';
|
||||||
import { getJSON, ajaxGet, postJSON } from 'common/ApiUtil';
|
import { getJSON, ajaxGet, postJSON } from 'common/apiUtil';
|
||||||
|
|
||||||
import Style from './download-root-ca.less';
|
import Style from './download-root-ca.less';
|
||||||
import CommonStyle from '../style/common.less';
|
import CommonStyle from '../style/common.less';
|
||||||
|
@ -27,7 +27,7 @@ const {
|
|||||||
RECORD_FILTER: RECORD_FILTER_MENU_KEY
|
RECORD_FILTER: RECORD_FILTER_MENU_KEY
|
||||||
} = MenuKeyMap;
|
} = MenuKeyMap;
|
||||||
|
|
||||||
import { getJSON } from 'common/ApiUtil';
|
import { getJSON } from 'common/apiUtil';
|
||||||
|
|
||||||
import Style from './header-menu.less';
|
import Style from './header-menu.less';
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import { message, Button, Icon } from 'antd';
|
import { message, Button, Icon } from 'antd';
|
||||||
import { formatDate } from 'common/commonUtil';
|
import { formatDate } from 'common/commonUtil';
|
||||||
import { initWs } from 'common/WsUtil';
|
import { initWs } from 'common/wsUtil';
|
||||||
import ClassBind from 'classnames/bind';
|
import ClassBind from 'classnames/bind';
|
||||||
|
|
||||||
import Style from './record-ws-message-detail.less';
|
import Style from './record-ws-message-detail.less';
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
|
|
||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
import { initWs } from 'common/WsUtil';
|
import { initWs } from 'common/wsUtil';
|
||||||
import { updateWholeRequest } from 'action/recordAction';
|
import { updateWholeRequest } from 'action/recordAction';
|
||||||
import {
|
import {
|
||||||
updateShouldClearRecord,
|
updateShouldClearRecord,
|
||||||
updateShowNewRecordTip
|
updateShowNewRecordTip
|
||||||
} from 'action/globalStatusAction';
|
} from 'action/globalStatusAction';
|
||||||
const RecordWorker = require('worker-loader?inline!./record-worker.jsx');
|
const RecordWorker = require('worker-loader?inline!./record-worker.jsx');
|
||||||
import { getJSON } from 'common/ApiUtil';
|
import { getJSON } from 'common/apiUtil';
|
||||||
|
|
||||||
const myRecordWorker = new RecordWorker(window.URL.createObjectURL(new Blob([RecordWorker.toString()])));
|
const myRecordWorker = new RecordWorker(window.URL.createObjectURL(new Blob([RecordWorker.toString()])));
|
||||||
const fetchLatestLog = function () {
|
const fetchLatestLog = function () {
|
||||||
|
@ -29,7 +29,7 @@ import {
|
|||||||
updateLocalGlobalProxyFlag
|
updateLocalGlobalProxyFlag
|
||||||
} from 'action/globalStatusAction';
|
} from 'action/globalStatusAction';
|
||||||
|
|
||||||
import { getJSON, postJSON, isApiSuccess } from 'common/ApiUtil';
|
import { getJSON, postJSON, isApiSuccess } from 'common/apiUtil';
|
||||||
|
|
||||||
function* doFetchRequestList() {
|
function* doFetchRequestList() {
|
||||||
const data = yield call(getJSON, '/latestLog');
|
const data = yield call(getJSON, '/latestLog');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user