所有接口使用代理。

This commit is contained in:
amass 2023-06-20 14:25:40 +08:00
parent 9e2fc3e6c2
commit 584950ce4d
4 changed files with 74 additions and 9 deletions

View File

@ -17,6 +17,9 @@ import { useNavigate } from "react-router-dom";
export default function () {
const avatarUrl = useSelector(state => state.user.avatarUrl);
const nickName = useSelector(state => state.user.nickName);
const userName = useSelector(state => state.user.userName);
const name = (nickName && nickName.length > 0) ? nickName : userName;
const [cookies, setCookie, removeCookie] = useCookies(['accessToken']);
const navigate = useNavigate();
const [anchorElUser, setAnchorElUser] = React.useState(null);
@ -50,9 +53,9 @@ export default function () {
alignItems: "center",
}} >
<IconButton onClick={handleOpenUserMenu} sx={{ p: 0 }}>
<Avatar alt={nickName} src={avatarUrl} />
<Avatar alt={name} src={avatarUrl} />
</IconButton>
<Typography sx={{ color: "#FFFFFF", paddingLeft: 2 }}>{nickName}</Typography>
<Typography onClick={handleOpenUserMenu} sx={{ color: "#FFFFFF", paddingLeft: 2 }}>{name}</Typography>
<Menu
sx={{ mt: '45px' }}
id="menu-appbar"

View File

@ -39,6 +39,14 @@ export default function ({ width, currentTime }) {
dispatch(togglePauseState());
};
const onDownload = () => {
if (recordList.length <= 0 || currentIndex < 0) return;
let link = document.createElement('a');
link.href = currentBlob;
link.download = recordList.at(currentIndex).name;
link.click();
};
const onDurationChange = (event) => {
setDuration(player.current.duration);
}
@ -65,7 +73,7 @@ export default function ({ width, currentTime }) {
alignItems: "center",
}}>
<Typography variant="h6" sx={{ flexGrow: 1 }} >{recordList.length > 0 ? recordList.at(currentIndex).editName : ""}</Typography>
<IconButton onClick={toggleState}>
<IconButton onClick={onDownload}>
<img src={downloadIcon} />
</IconButton>
</Container>

View File

@ -44,7 +44,7 @@ const yzs = {
body.timestamp = parseInt(new Date().getTime() / 1000);
body.flushToken = flushToken;
return fetch(`${accessServer}/rest/v2/token/get_access_token`, {
return fetch("/rest/v2/token/get_access_token", {
method: "POST",
body: constructParameter(body),
headers: {
@ -64,7 +64,7 @@ const yzs = {
body.timestamp = parseInt(new Date().getTime() / 1000);
body.accessToken = accessToken;
return fetch(`${accessServer}/rest/v2/token/refresh_access_token`, {
return fetch("/rest/v2/token/refresh_access_token", {
method: "POST",
body: constructParameter(body),
headers: {
@ -85,7 +85,7 @@ const yzs = {
body.timestamp = parseInt(new Date().getTime() / 1000);
body.accessToken = accessToken;
return fetch(`${accessServer}/rest/v2/user/get_user_info`, {
return fetch("/rest/v2/user/get_user_info", {
method: "POST",
body: constructParameter(body),
headers: {
@ -175,7 +175,7 @@ const yzs = {
body.account = account;
body.password = md5(password);
return fetch(`${accessServer}/rest/v2/user/login`, {
return fetch("/rest/v2/user/login", {
method: "POST",
body: constructParameter(body),
// mode: "no-cors",
@ -196,7 +196,7 @@ const yzs = {
body.timestamp = Math.round(new Date().getTime() / 1000);
body.userCell = userCell;
body.phoneCode = phoneCode;
return fetch(`${accessServer}/rest/v2/phone/login`, {
return fetch("/rest/v2/phone/login", {
method: "POST",
body: constructParameter(body),
// mode: "no-cors",
@ -217,7 +217,7 @@ const yzs = {
body.clientId = udid;
body.timestamp = Math.round(new Date().getTime() / 1000);
body.userCell = userCell;
return fetch(`${accessServer}/rest/v2/phone/send_phone_code`, {
return fetch("/rest/v2/phone/send_phone_code", {
method: "POST",
body: constructParameter(body),
// mode: "no-cors",

View File

@ -6,7 +6,61 @@ const { createProxyMiddleware } = require('http-proxy-middleware');
const appKey = "tp3szvq45m3yn6rdjhxlzrrikf6fc3a75t2yh3y3";
const server = "https://ai-api.hivoice.cn";
const accessServer = "https://uc.hivoice.cn";
module.exports = function (app) {
app.use(
'/rest/v2/phone/login',
createProxyMiddleware({
target: accessServer,
changeOrigin: true,
logger: console,
})
);
app.use(
'/rest/v2/phone/send_phone_code',
createProxyMiddleware({
target: accessServer,
changeOrigin: true,
logger: console,
})
);
app.use(
'/rest/v2/user/login',
createProxyMiddleware({
target: accessServer,
changeOrigin: true,
logger: console,
})
);
app.use(
'/rest/v2/user/get_user_info',
createProxyMiddleware({
target: accessServer,
changeOrigin: true,
logger: console,
})
);
app.use(
'/rest/v2/token/get_access_token',
createProxyMiddleware({
target: accessServer,
changeOrigin: true,
logger: console,
})
);
app.use(
'/rest/v2/token/refresh_access_token',
createProxyMiddleware({
target: accessServer,
changeOrigin: true,
logger: console,
})
);
app.use(
'/api/app/app-voice-recorder/rest/v1/trans/info/list',
createProxyMiddleware({