- {lyrics.map((lyric, index) => {
+ {currentLyric.map((lyric, index) => {
return
- {lyric.original}
+ {lyric.text}
{lyric.translation}
})}
diff --git a/src/business/recorderSlice.js b/src/business/recorderSlice.js
index e500fd2..054db87 100644
--- a/src/business/recorderSlice.js
+++ b/src/business/recorderSlice.js
@@ -1,18 +1,26 @@
import { createSlice } from '@reduxjs/toolkit'
export const recorderSlice = createSlice({
- name: 'user',
+ name: 'recorder',
initialState: {
list: [],
+ currentIndex: 0,
+ currentLyric: [],
},
reducers: {
setList: (state, action) => {
state.list = action.payload;
+ },
+ setCurrentIndex: (state, action) => {
+ state.currentIndex = action.payload;
+ },
+ setCurrentLyric: (state, action) => {
+ state.currentLyric = action.payload;
}
}
})
// Action creators are generated for each case reducer function
-export const { setList } = recorderSlice.actions
+export const { setCurrentIndex, setList, setCurrentLyric } = recorderSlice.actions
export default recorderSlice.reducer
\ No newline at end of file
diff --git a/src/business/request.js b/src/business/request.js
index 0c97a14..b42b556 100644
--- a/src/business/request.js
+++ b/src/business/request.js
@@ -1,3 +1,5 @@
+import { json } from 'react-router-dom';
+
const appKey = "k5hfiei5eevouvjohkapjaudpk2gakpaxha22fiy";
const appSecret = "e65ffb25148b08207088148d5bce114d";
@@ -83,9 +85,8 @@ const yzs = {
},
}).then(response => response.json()).then((json) => {
console.log(json);
+ if (json.returnCode != "uc_0000") throw json;
return json.result;
- }).catch(error => {
- console.log(error);
});
},
user_select: function (ip, accessToken) {
@@ -104,12 +105,9 @@ const yzs = {
'timestamp': timestamp,
'signature': sig,
},
- }).then(response => {
- console.log(response);
- response.text()
- }).then((json) => {
+ }).then(response => response.json()).then((json) => {
console.log(json)
- return json;
+ return json.result;
});
},
@@ -117,7 +115,7 @@ const yzs = {
let sha256 = require('sha256');
let timestamp = new Date().getTime();
let sig = appKey + timestamp.toString() + appSecret;
- sig = sha256(sig).toUpperCase();;
+ sig = sha256(sig).toUpperCase();
let url = `/api/app/app-voice-recorder/rest/v1/trans/info/list?accessToken=${encodeURIComponent(accessToken)}&passportId=${passportId}`;
@@ -129,12 +127,33 @@ const yzs = {
'timestamp': timestamp,
'signature': sig,
},
- }).then(response => response.json()
- ).then((json) => {
+ }).then(response => response.json()).then((json) => {
console.log(json)
return json;
});
},
+ download: function (accessToken, url) {
+ let sha256 = require('sha256');
+ let timestamp = new Date().getTime();
+ let sig = appKey + timestamp.toString() + appSecret;
+ sig = sha256(sig).toUpperCase();
+
+ let body = {
+ url: url,
+ accessToken: accessToken,
+ };
+
+ return fetch("/api/app/app-voice-recorder/rest/v1/trans/info/download", {
+ method: "POST",
+ headers: {
+ 'appKey': appKey,
+ 'timestamp': timestamp,
+ 'signature': sig,
+ 'Content-Type': 'application/json; charset=utf-8',
+ },
+ body: JSON.stringify(body),
+ }).then(response => response.blob());
+ },
login: function (udid, account, password) {
let md5 = require('md5');
diff --git a/src/business/userSlice.js b/src/business/userSlice.js
index 8d57ec6..ec87eef 100644
--- a/src/business/userSlice.js
+++ b/src/business/userSlice.js
@@ -9,6 +9,8 @@ export const userSlice = createSlice({
passportId: 0,
createTime: "",
userName: "",
+ nickName: "",
+ avatarUrl: "",
agreeAgreement: true,
account: "13682423271",
password: "yzs123456",
@@ -19,19 +21,19 @@ export const userSlice = createSlice({
state.udid = action.payload;
},
setFlushToken: (state, token) => {
- // Redux Toolkit allows us to write "mutating" logic in reducers. It
- // doesn't actually mutate the state because it uses the Immer library,
- // which detects changes to a "draft state" and produces a brand new
- // immutable state based off those changes
state.flushToken = token.payload;
},
setAccessToken: (state, token) => {
state.accessToken = token.payload;
},
- setUserInfo: (state, info) => {
- state.passportId = info.payload.passportId
- state.createTime = info.payload.createTime
- state.userName = info.payload.userName
+ setUserInfo: (state, action) => {
+ state.passportId = action.payload.passportId
+ state.createTime = action.payload.createTime
+ state.userName = action.payload.userName
+ },
+ setSelectInfo: (state, action) => {
+ state.nickName = action.payload.nickName;
+ state.avatarUrl = action.payload.avatarUrl;
},
setAccount: (state, action) => {
state.account = action.payload;
@@ -46,6 +48,6 @@ export const userSlice = createSlice({
})
// Action creators are generated for each case reducer function
-export const { setUdid, setFlushToken, setAccessToken, setUserInfo, setAccount, setPassword, setVerificationCode } = userSlice.actions
+export const { setUdid, setFlushToken, setAccessToken, setUserInfo, setSelectInfo, setAccount, setPassword, setVerificationCode } = userSlice.actions
export default userSlice.reducer
\ No newline at end of file
diff --git a/src/setupProxy.js b/src/setupProxy.js
index 4cbd576..3712d4e 100644
--- a/src/setupProxy.js
+++ b/src/setupProxy.js
@@ -24,4 +24,15 @@ module.exports = function (app) {
},
})
);
+ app.use(
+ '/api/app/app-voice-recorder/rest/v1/trans/info/download',
+ createProxyMiddleware({
+ target: 'http://ai-api.uat.hivoice.cn',
+ changeOrigin: true,
+ logger: console,
+ onProxyReq: (proxyReq, req, res) => {
+ proxyReq.setHeader('appKey', 'k5hfiei5eevouvjohkapjaudpk2gakpaxha22fiy');
+ },
+ })
+ );
};
\ No newline at end of file