Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
live-management-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
live-management-web
Commits
f21881b9
Commit
f21881b9
authored
Aug 11, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异步洗稿
parent
5e4e82bd
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
249 additions
and
16 deletions
+249
-16
src/hooks/useConfuse.ts
+9
-0
src/hooks/useScript.ts
+0
-0
src/pages/InteractiveResponse/index.vue
+5
-0
src/pages/OnlyVideoLive/index.vue
+22
-1
src/pages/createLive/index.vue
+18
-6
src/service/Common.ts
+88
-1
src/service/CreateLive.ts
+0
-0
src/store/index.ts
+2
-0
src/store/modules/asyncCreateLive.ts
+52
-0
src/utils/audio.ts
+5
-2
src/utils/otherRequest.ts
+10
-3
src/utils/pyqt.ts
+11
-0
src/utils/request.ts
+6
-2
src/utils/tool.ts
+5
-0
src/utils/upLoadRequest.ts
+16
-1
No files found.
src/hooks/useConfuse.ts
View file @
f21881b9
import
{
liveContentRegenerate
,
liveContentRegenerateCallback
}
from
'@/utils/api/userApi'
;
import
{
liveContentRegenerate
,
liveContentRegenerateCallback
}
from
'@/utils/api/userApi'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
import
{
onBeforeUnmount
,
ref
}
from
'vue'
;
import
{
onBeforeUnmount
,
ref
}
from
'vue'
;
export
default
function
()
{
export
default
function
()
{
...
@@ -34,6 +35,10 @@ export default function () {
...
@@ -34,6 +35,10 @@ export default function () {
openConfuseInterval
(
''
);
openConfuseInterval
(
''
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'old 洗稿提交'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -53,6 +58,10 @@ export default function () {
...
@@ -53,6 +58,10 @@ export default function () {
console
.
log
(
res
.
data
);
console
.
log
(
res
.
data
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'old 洗稿回调'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
...
src/hooks/useScript.ts
View file @
f21881b9
This diff is collapsed.
Click to expand it.
src/pages/InteractiveResponse/index.vue
View file @
f21881b9
...
@@ -14,6 +14,7 @@ import { useRoute } from 'vue-router';
...
@@ -14,6 +14,7 @@ import { useRoute } from 'vue-router';
import
{
callPyjsInWindow
,
injectWindow
}
from
'@/utils/pyqt'
;
import
{
callPyjsInWindow
,
injectWindow
}
from
'@/utils/pyqt'
;
import
{
getliveTaskReply
,
getUserCookie
}
from
'@/utils/api/userApi'
;
import
{
getliveTaskReply
,
getUserCookie
}
from
'@/utils/api/userApi'
;
import
{
useStore
}
from
'vuex'
;
import
{
useStore
}
from
'vuex'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
// 互动回复
// 互动回复
...
@@ -155,6 +156,10 @@ const mergeCallback = (params: any) => {
...
@@ -155,6 +156,10 @@ const mergeCallback = (params: any) => {
addVideo
.
value
=
params
.
add_video
;
addVideo
.
value
=
params
.
add_video
;
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'mergeCallback error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
...
src/pages/OnlyVideoLive/index.vue
View file @
f21881b9
...
@@ -32,6 +32,7 @@ import useConfuse from '@/hooks/useConfuse';
...
@@ -32,6 +32,7 @@ import useConfuse from '@/hooks/useConfuse';
import
{
CONFUSE_STATUS
}
from
'@/service/Live'
;
import
{
CONFUSE_STATUS
}
from
'@/service/Live'
;
import
{
processTextCallback
}
from
'@/hooks/useScript'
;
import
{
processTextCallback
}
from
'@/hooks/useScript'
;
import
{
scriptTypeText
}
from
'@/service/CreateLive'
;
import
{
scriptTypeText
}
from
'@/service/CreateLive'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
const
{
currentConfuseId
,
confuseList
,
currentStartConfuse
,
openConfuseInterval
}
=
useConfuse
();
const
{
currentConfuseId
,
confuseList
,
currentStartConfuse
,
openConfuseInterval
}
=
useConfuse
();
const
{
openInterval
:
confuseInterval
}
=
processTextCallback
();
const
{
openInterval
:
confuseInterval
}
=
processTextCallback
();
...
@@ -375,6 +376,10 @@ const getLive = async () => {
...
@@ -375,6 +376,10 @@ const getLive = async () => {
addVideoList
.
value
=
addVideoList
.
value
.
concat
(
res
.
data
);
addVideoList
.
value
=
addVideoList
.
value
.
concat
(
res
.
data
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'getliveTaskReply 获取直播互动失败'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -395,6 +400,10 @@ const regenerate = async (list: any[]) => {
...
@@ -395,6 +400,10 @@ const regenerate = async (list: any[]) => {
console
.
log
(
'重新生成直播,已提交'
);
console
.
log
(
'重新生成直播,已提交'
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'only live regenerate error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -497,6 +506,10 @@ const getDetail = async (type: string = '') => {
...
@@ -497,6 +506,10 @@ const getDetail = async (type: string = '') => {
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'获取直播链接失败'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -523,7 +536,11 @@ const submitVideo = () => {
...
@@ -523,7 +536,11 @@ const submitVideo = () => {
show_message
(
'empty-1 py'
);
show_message
(
'empty-1 py'
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
show_message
(
e
.
message
);
console
.
log
(
e
);
writeLog
({
name
:
'only submitVideo error'
,
value
:
e
,
});
}
}
};
};
...
@@ -575,6 +592,10 @@ const mergeCallback = (params: any) => {
...
@@ -575,6 +592,10 @@ const mergeCallback = (params: any) => {
console
.
log
(
params
);
console
.
log
(
params
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'only mergeCallback error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
...
src/pages/createLive/index.vue
View file @
f21881b9
...
@@ -83,12 +83,12 @@ import {
...
@@ -83,12 +83,12 @@ import {
getFile
,
getFile
,
}
from
'@/utils/tool'
;
}
from
'@/utils/tool'
;
import
{
useStore
}
from
'vuex'
;
import
{
useStore
}
from
'vuex'
;
import
{
createLiveKeys
,
scriptTypeText
,
scriptTypePhonetics
,
mergeSameAudio
}
from
'@/service/CreateLive'
;
import
{
createLiveKeys
,
scriptTypeText
,
scriptTypePhonetics
,
mergeSameAudio
,
filterFiled
}
from
'@/service/CreateLive'
;
import
{
getLiveTaskInfo
,
createDrafts
,
getDraftsDetail
,
liveTts
,
createLiveTask
}
from
'@/utils/api/userApi'
;
import
{
getLiveTaskInfo
,
createDrafts
,
getDraftsDetail
,
liveTts
,
createLiveTask
}
from
'@/utils/api/userApi'
;
import
{
useRoute
,
onBeforeRouteLeave
}
from
'vue-router'
;
import
{
useRoute
,
onBeforeRouteLeave
}
from
'vue-router'
;
import
routerConfig
from
'@/router/tool'
;
import
routerConfig
from
'@/router/tool'
;
import
{
onUpdateLiveTask
}
from
'@/service/Common'
;
import
{
onUpdateLiveTask
}
from
'@/service/Common'
;
import
{
callPyjsInWindow
}
from
'@/utils/pyqt'
;
import
{
callPyjsInWindow
,
writeLog
}
from
'@/utils/pyqt'
;
import
{
useLiveInfoSubmit
}
from
'@/hooks/useStoreCommit'
;
import
{
useLiveInfoSubmit
}
from
'@/hooks/useStoreCommit'
;
import
{
processTextCallback
}
from
'@/hooks/useScript'
;
import
{
processTextCallback
}
from
'@/hooks/useScript'
;
import
CustomException
from
'@/utils/error'
;
import
CustomException
from
'@/utils/error'
;
...
@@ -101,7 +101,7 @@ const {
...
@@ -101,7 +101,7 @@ const {
live_task_id
,
live_task_id
,
audioStart
,
audioStart
,
openInterval
,
openInterval
,
filterFiled
,
getCreateLiveInfo
,
submitSuccessed
,
submitSuccessed
,
uploadToAly
,
uploadToAly
,
}
=
processTextCallback
();
}
=
processTextCallback
();
...
@@ -275,6 +275,10 @@ const getEditInfo = async (id: any, type: string) => {
...
@@ -275,6 +275,10 @@ const getEditInfo = async (id: any, type: string) => {
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'createLive getEditInfo error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
}
}
};
};
...
@@ -356,7 +360,7 @@ const onSave = () => {
...
@@ -356,7 +360,7 @@ const onSave = () => {
// 保存为草稿
// 保存为草稿
const
onSaveDrafts
=
async
()
=>
{
const
onSaveDrafts
=
async
()
=>
{
let
params
=
filterFiled
();
let
params
=
filterFiled
(
getCreateLiveInfo
()
);
try
{
try
{
loading
.
value
=
true
;
loading
.
value
=
true
;
let
res
:
any
=
await
createDrafts
(
params
);
let
res
:
any
=
await
createDrafts
(
params
);
...
@@ -379,7 +383,7 @@ const editAudioSave = async () => {
...
@@ -379,7 +383,7 @@ const editAudioSave = async () => {
try
{
try
{
loading
.
value
=
true
;
loading
.
value
=
true
;
await
audioSplit
();
await
audioSplit
();
let
params
=
filterFiled
();
let
params
=
filterFiled
(
getCreateLiveInfo
()
);
let
res
:
any
=
await
onUpdateLiveTask
(
route
.
query
.
id
,
params
);
let
res
:
any
=
await
onUpdateLiveTask
(
route
.
query
.
id
,
params
);
if
(
res
)
{
if
(
res
)
{
if
(
route
.
query
.
type
===
'edit'
)
{
if
(
route
.
query
.
type
===
'edit'
)
{
...
@@ -392,6 +396,10 @@ const editAudioSave = async () => {
...
@@ -392,6 +396,10 @@ const editAudioSave = async () => {
}
}
loading
.
value
=
false
;
loading
.
value
=
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'createLive editAudioSave error'
,
value
:
e
,
});
loading
.
value
=
false
;
loading
.
value
=
false
;
console
.
log
(
e
);
console
.
log
(
e
);
}
}
...
@@ -508,7 +516,7 @@ const audioSubmit = async () => {
...
@@ -508,7 +516,7 @@ const audioSubmit = async () => {
if
(
route
.
query
.
type
==
'edit_drafts'
)
{
if
(
route
.
query
.
type
==
'edit_drafts'
)
{
type
=
'edit_drafts'
;
type
=
'edit_drafts'
;
}
}
let
params
=
filterFiled
(
type
);
let
params
=
filterFiled
(
getCreateLiveInfo
(),
type
);
let
res
:
any
=
await
createLiveTask
(
params
);
let
res
:
any
=
await
createLiveTask
(
params
);
if
(
res
.
code
==
0
)
{
if
(
res
.
code
==
0
)
{
console
.
log
(
'创建成功-'
,
res
.
data
.
id
);
console
.
log
(
'创建成功-'
,
res
.
data
.
id
);
...
@@ -517,6 +525,10 @@ const audioSubmit = async () => {
...
@@ -517,6 +525,10 @@ const audioSubmit = async () => {
}
}
loading
.
value
=
false
;
loading
.
value
=
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'createLive audioSubmit error'
,
value
:
e
,
});
loading
.
value
=
false
;
loading
.
value
=
false
;
console
.
log
(
e
);
console
.
log
(
e
);
}
}
...
...
src/service/Common.ts
View file @
f21881b9
...
@@ -7,8 +7,11 @@ import {
...
@@ -7,8 +7,11 @@ import {
updateDrafts
,
updateDrafts
,
}
from
'@/utils/api/userApi'
;
}
from
'@/utils/api/userApi'
;
import
{
typeTones
,
typeSoundColor
}
from
'@/service/CreateLive'
;
import
{
typeTones
,
typeSoundColor
}
from
'@/service/CreateLive'
;
import
{
show_message
}
from
'@/utils/tool'
;
import
{
show_message
,
alyOssUpload
}
from
'@/utils/tool'
;
import
{
LIVE_AUDIT_STATUS
}
from
'./Live'
;
import
{
LIVE_AUDIT_STATUS
}
from
'./Live'
;
import
{
audioMerge
,
splitAudio
}
from
'@/utils/audio'
;
import
{
v4
}
from
'uuid'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
// 阿里云上传配置
// 阿里云上传配置
export
const
getUploadConfig
=
async
()
=>
{
export
const
getUploadConfig
=
async
()
=>
{
...
@@ -112,6 +115,10 @@ export const onUpdateLiveTask = async (id: any, data: any) => {
...
@@ -112,6 +115,10 @@ export const onUpdateLiveTask = async (id: any, data: any) => {
}
}
return
false
;
return
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'common onUpdateLiveTask error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
return
false
;
return
false
;
}
}
...
@@ -127,7 +134,87 @@ export const onUpdateDrafts = async (id: any, data: any) => {
...
@@ -127,7 +134,87 @@ export const onUpdateDrafts = async (id: any, data: any) => {
}
}
return
false
;
return
false
;
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'common onUpdateDrafts error'
,
value
:
e
,
});
console
.
log
(
e
);
console
.
log
(
e
);
return
false
;
return
false
;
}
}
};
};
// 音频合并切割
export
const
audioStart
=
async
(
list
:
any
[],
dimensional
:
boolean
=
true
)
=>
{
let
file
=
await
audioMerge
(
list
);
if
(
file
)
{
// 开始切割
let
split_list
=
await
splitAudio
(
file
,
300
);
// 合并后的文件上传
if
(
split_list
&&
split_list
.
length
)
{
let
result
=
await
uploadToAly
(
split_list
);
console
.
log
(
'上传完毕'
);
// 是否一维数组
if
(
dimensional
)
{
console
.
log
(
result
);
return
result
;
}
else
{
console
.
log
([
result
]);
return
[
result
];
}
}
}
else
{
console
.
log
(
'没有文件'
);
}
};
// 循环上传阿里云
export
const
uploadToAly
=
async
(
fileList
:
File
[])
=>
{
// 获取文件名
const
getFileName
=
(
file
:
any
)
=>
{
return
file
.
name
?
file
.
name
:
v4
();
};
const
uploadSuccess
=
(
name
:
string
,
url
:
string
)
=>
{
alyList
.
push
([
{
content
:
url
,
},
]);
};
// 每次上传前清空数组
let
alyList
=
[];
console
.
log
(
'任务数'
);
console
.
log
(
fileList
.
length
);
// 获取阿里云配置
let
config
=
await
getUploadConfig
();
for
(
let
i
=
0
;
i
<
fileList
.
length
;
i
++
)
{
let
file
=
fileList
[
i
];
let
retryNum
=
0
;
while
(
true
)
{
if
(
retryNum
>=
5
)
{
console
.
log
(
'音频块已经重试5次,跳过'
);
break
;
}
if
(
retryNum
)
{
config
=
await
getUploadConfig
();
}
try
{
// 上传阿里云
await
alyOssUpload
(
config
,
file
,
uploadSuccess
,
()
=>
false
,
getFileName
(
file
));
}
catch
(
e
)
{
writeLog
({
name
:
'common uploadToAly.alyOssUpload error'
,
value
:
e
,
});
if
(
e
&&
e
.
status
==
'error'
)
{
// 重新上传
console
.
log
(
'重新上传'
);
retryNum
+=
1
;
continue
;
}
}
break
;
}
}
// 上传完毕
return
alyList
;
};
src/service/CreateLive.ts
View file @
f21881b9
This diff is collapsed.
Click to expand it.
src/store/index.ts
View file @
f21881b9
...
@@ -5,6 +5,7 @@ import theme from './modules/theme';
...
@@ -5,6 +5,7 @@ import theme from './modules/theme';
import
language
from
'./modules/language'
;
import
language
from
'./modules/language'
;
import
live
from
'./modules/live'
;
import
live
from
'./modules/live'
;
import
navbar
from
'./modules/navbar'
;
import
navbar
from
'./modules/navbar'
;
import
asyncCreateLive
from
'./modules/asyncCreateLive'
;
export
const
store
=
createStore
({
export
const
store
=
createStore
({
modules
:
{
modules
:
{
...
@@ -14,6 +15,7 @@ export const store = createStore({
...
@@ -14,6 +15,7 @@ export const store = createStore({
language
,
language
,
live
,
live
,
navbar
,
navbar
,
asyncCreateLive
,
},
},
});
});
...
...
src/store/modules/asyncCreateLive.ts
0 → 100644
View file @
f21881b9
import
{
onRewriteCallback
,
submitAudioTask
,
getAudioCallback
}
from
'@/service/CreateLive'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
const
state
=
{
language
:
''
,
};
type
StateType
=
typeof
state
;
const
mutations
=
{
// setLang(state: StateType, info: string) {
// state.language = info;
// // 设置html 属性
// document.documentElement.setAttribute('lang', info);
// },
};
const
getters
=
{
// getLang: (state: StateType) => {
// return state.language;
// },
};
const
actions
=
{
// 洗稿
async
confuse
({
commit
},
params
)
{
const
{
user_id
,
live_task_id
,
task_id
,
audio_task_id
,
createLiveInfo
}
=
params
;
try
{
// 获取洗稿回调
let
confuseList
=
await
onRewriteCallback
(
task_id
);
// 提交音频任务
let
status
=
await
submitAudioTask
(
confuseList
,
createLiveInfo
,
audio_task_id
);
if
(
status
)
{
// 打开音频回调轮询
getAudioCallback
(
audio_task_id
,
confuseList
.
length
,
createLiveInfo
,
live_task_id
);
}
}
catch
(
e
)
{
writeLog
({
name
:
'dispatch confuse error'
,
value
:
e
,
});
console
.
log
(
e
);
}
},
};
export
default
{
namespaced
:
true
,
state
,
mutations
,
actions
,
getters
,
};
src/utils/audio.ts
View file @
f21881b9
import
audiobufferToWav
from
'audiobuffer-to-wav'
;
import
audiobufferToWav
from
'audiobuffer-to-wav'
;
import
request
from
'@/utils/upLoadRequest'
;
import
request
from
'@/utils/upLoadRequest'
;
import
{
writeLog
}
from
'@/utils/pyqt'
;
export
const
createAudioContext
=
()
=>
{
export
const
createAudioContext
=
()
=>
{
return
new
(
window
.
AudioContext
||
window
.
webkitAudioContext
)();
return
new
(
window
.
AudioContext
||
window
.
webkitAudioContext
)();
...
@@ -82,14 +83,16 @@ export async function audioMerge(filePaths) {
...
@@ -82,14 +83,16 @@ export async function audioMerge(filePaths) {
offset
+=
Math
.
round
(
buffer
.
duration
*
sampleRate
);
offset
+=
Math
.
round
(
buffer
.
duration
*
sampleRate
);
});
});
console
.
log
(
buffers
);
console
.
log
(
buffers
);
console
.
log
(
'zxl'
);
// 导出合并后的音频数据为 WAV 文件
// 导出合并后的音频数据为 WAV 文件
const
mergedData
=
exportBufferAsWav
(
mergedBuffer
);
const
mergedData
=
exportBufferAsWav
(
mergedBuffer
);
console
.
log
(
'通过了'
);
const
blob
=
new
Blob
([
mergedData
],
{
type
:
'audio/wav'
});
const
blob
=
new
Blob
([
mergedData
],
{
type
:
'audio/wav'
});
console
.
log
(
'合并完成'
,
blob
);
console
.
log
(
'合并完成'
,
blob
);
return
blob
;
return
blob
;
}
catch
(
error
)
{
}
catch
(
error
)
{
writeLog
({
name
:
'音频合并失败'
,
value
:
error
,
});
console
.
error
(
'音频文件合并失败:'
,
error
);
console
.
error
(
'音频文件合并失败:'
,
error
);
}
}
}
}
...
...
src/utils/otherRequest.ts
View file @
f21881b9
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
{
MessagePlugin
}
from
'tdesign-vue-next'
;
import
{
MessagePlugin
}
from
'tdesign-vue-next'
;
import
{
writeLog
}
from
'./pyqt'
;
const
instance
:
any
=
axios
.
create
({
const
instance
:
any
=
axios
.
create
({
timeout
:
60
*
60
*
1000
,
timeout
:
60
*
60
*
1000
,
...
@@ -19,7 +20,9 @@ instance.interceptors.response.use(
...
@@ -19,7 +20,9 @@ instance.interceptors.response.use(
if
(
data
.
code
===
0
)
{
if
(
data
.
code
===
0
)
{
return
data
;
return
data
;
}
else
{
}
else
{
MessagePlugin
.
error
(
data
.
msg
||
'请求错误'
);
let
message
=
data
.
msg
||
'请求错误'
;
MessagePlugin
.
error
(
message
);
writeLog
(
message
);
return
Promise
.
reject
(
data
.
msg
);
return
Promise
.
reject
(
data
.
msg
);
}
}
},
},
...
@@ -28,9 +31,13 @@ instance.interceptors.response.use(
...
@@ -28,9 +31,13 @@ instance.interceptors.response.use(
if
(
'response'
in
err
)
{
if
(
'response'
in
err
)
{
const
{
message
:
msg
}
=
err
.
response
.
data
;
const
{
message
:
msg
}
=
err
.
response
.
data
;
if
(
err
.
response
.
data
.
indexOf
(
'<Code>UserDisable</Code>'
)
!==
-
1
)
{
if
(
err
.
response
.
data
.
indexOf
(
'<Code>UserDisable</Code>'
)
!==
-
1
)
{
MessagePlugin
.
error
(
'阿里云可能欠费'
);
let
message
=
'阿里云可能欠费'
;
MessagePlugin
.
error
(
message
);
writeLog
(
message
);
}
else
{
}
else
{
MessagePlugin
.
error
(
msg
||
'请求错误'
);
let
message
=
msg
||
'请求错误'
;
MessagePlugin
.
error
(
message
);
writeLog
(
message
);
}
}
return
err
.
response
;
return
err
.
response
;
}
}
...
...
src/utils/pyqt.ts
View file @
f21881b9
...
@@ -40,6 +40,17 @@ export const callPyjsInWindow = (name: string, value: any = '', callback: boolea
...
@@ -40,6 +40,17 @@ export const callPyjsInWindow = (name: string, value: any = '', callback: boolea
}
}
return
window
.
pyjs
[
name
](
JSON
.
stringify
(
value
));
return
window
.
pyjs
[
name
](
JSON
.
stringify
(
value
));
}
catch
(
e
)
{
}
catch
(
e
)
{
writeLog
({
name
:
'call python error'
,
value
:
e
,
});
console
.
error
(
e
);
console
.
error
(
e
);
}
}
};
};
// 写入日志
export
const
writeLog
=
(
value
:
any
)
=>
{
if
(
window
.
pyjs
&&
window
.
pyjs
[
'writeLog'
])
{
window
.
pyjs
[
'writeLog'
](
JSON
.
stringify
(
value
));
}
};
src/utils/request.ts
View file @
f21881b9
...
@@ -2,7 +2,7 @@ import axios from 'axios';
...
@@ -2,7 +2,7 @@ import axios from 'axios';
import
{
store
}
from
'@/store/index'
;
import
{
store
}
from
'@/store/index'
;
import
router
from
'@/router'
;
import
router
from
'@/router'
;
import
{
show_message
,
isDev
}
from
'./tool'
;
import
{
show_message
,
isDev
}
from
'./tool'
;
import
{
callPyjsInWindow
}
from
'./pyqt'
;
import
{
callPyjsInWindow
,
writeLog
}
from
'./pyqt'
;
const
error_messaage
=
'请求错误'
;
const
error_messaage
=
'请求错误'
;
...
@@ -55,6 +55,7 @@ instance.interceptors.response.use(
...
@@ -55,6 +55,7 @@ instance.interceptors.response.use(
if
(
'response'
in
err
&&
err
[
'response'
])
{
if
(
'response'
in
err
&&
err
[
'response'
])
{
const
{
status
,
data
}
=
err
.
response
;
const
{
status
,
data
}
=
err
.
response
;
if
(
status
==
401
)
{
if
(
status
==
401
)
{
writeLog
(
'登录信息已失效'
);
router
.
push
({
router
.
push
({
path
:
'/login'
,
path
:
'/login'
,
});
});
...
@@ -63,12 +64,15 @@ instance.interceptors.response.use(
...
@@ -63,12 +64,15 @@ instance.interceptors.response.use(
store
.
commit
(
'user/removeUserInfo'
);
store
.
commit
(
'user/removeUserInfo'
);
return
;
return
;
}
}
show_message
(
data
.
message
||
error_messaage
,
'error'
);
let
message
=
data
.
message
||
error_messaage
;
show_message
(
message
,
'error'
);
writeLog
(
message
);
return
err
.
response
;
return
err
.
response
;
}
else
{
}
else
{
// 格式不一致的
// 格式不一致的
let
res
=
err
.
toJSON
();
let
res
=
err
.
toJSON
();
show_message
(
res
.
message
,
'error'
);
show_message
(
res
.
message
,
'error'
);
writeLog
(
res
.
message
);
return
;
return
;
}
}
},
},
...
...
src/utils/tool.ts
View file @
f21881b9
import
{
MessagePlugin
,
RequestMethodResponse
}
from
'tdesign-vue-next'
;
import
{
MessagePlugin
,
RequestMethodResponse
}
from
'tdesign-vue-next'
;
import
request
from
'@/utils/upLoadRequest'
;
import
request
from
'@/utils/upLoadRequest'
;
import
{
writeLog
}
from
'./pyqt'
;
// import JSZip from 'jszip';
// import JSZip from 'jszip';
// import { saveAs } from 'file-saver';
// import { saveAs } from 'file-saver';
...
@@ -249,6 +250,10 @@ export const alyOssUpload = (
...
@@ -249,6 +250,10 @@ export const alyOssUpload = (
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
);
console
.
log
(
e
);
writeLog
({
name
:
'tool aly upload error'
,
value
:
e
,
});
reject
({
reject
({
status
:
'error'
,
status
:
'error'
,
response
:
''
,
response
:
''
,
...
...
src/utils/upLoadRequest.ts
View file @
f21881b9
import
axios
from
'axios'
;
import
axios
from
'axios'
;
import
{
writeLog
}
from
'./pyqt'
;
const
instance
:
any
=
axios
.
create
({
const
instance
:
any
=
axios
.
create
({
timeout
:
60
*
60
*
1000
,
timeout
:
60
*
60
*
1000
,
...
@@ -18,11 +19,25 @@ instance.interceptors.response.use(
...
@@ -18,11 +19,25 @@ instance.interceptors.response.use(
if
(
data
.
code
===
0
)
{
if
(
data
.
code
===
0
)
{
return
data
;
return
data
;
}
}
// 状态不对的
writeLog
({
name
:
'upLoad request status error'
,
value
:
response
,
});
},
},
(
err
)
=>
{
(
err
)
=>
{
console
.
log
(
err
);
if
(
'response'
in
err
)
{
if
(
'response'
in
err
)
{
writeLog
({
name
:
'upLoad request status error'
,
value
:
err
.
response
,
});
return
err
.
response
;
return
err
.
response
;
}
else
{
writeLog
({
name
:
'upLoad request status error'
,
value
:
err
,
});
}
}
},
},
);
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment