Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
risk-monitor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
蔡建
risk-monitor
Commits
50a8c95b
提交
50a8c95b
authored
4月 22, 2026
作者:
张伊明
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat 智能翻译接入接口、部分优化
上级
7f1603ac
流水线
#581
已失败 于阶段
in 1 分 3 秒
变更
3
流水线
1
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
75 行增加
和
13 行删除
+75
-13
index.js
src/api/intelligentTranslation/index.js
+34
-0
documentCompare.vue
src/views/intelligentTranslation/documentCompare.vue
+0
-0
index.vue
src/views/intelligentTranslation/index.vue
+41
-13
没有找到文件。
src/api/intelligentTranslation/index.js
0 → 100644
浏览文件 @
50a8c95b
import
request
from
'@/api/request.js'
const
INTELLIGENT_TRANSLATION_BASE_URL
=
'/doc-detail-pdf-api'
const
INTELLIGENT_TRANSLATION_HEADERS
=
{
'Client-ID'
:
'test_client'
,
'X-API-Key'
:
'test_key'
}
export
function
submitTranslationTask
(
file
)
{
const
formData
=
new
FormData
()
formData
.
append
(
'files'
,
file
)
return
request
({
url
:
`
${
INTELLIGENT_TRANSLATION_BASE_URL
}
/submit`
,
method
:
'POST'
,
data
:
formData
,
headers
:
INTELLIGENT_TRANSLATION_HEADERS
})
}
export
function
queryTranslationTaskStatus
(
taskId
)
{
return
request
({
url
:
`
${
INTELLIGENT_TRANSLATION_BASE_URL
}
/status/
${
taskId
}
`
,
method
:
'GET'
,
headers
:
INTELLIGENT_TRANSLATION_HEADERS
})
}
export
function
queryTranslationTaskResult
(
taskId
)
{
return
request
({
url
:
`
${
INTELLIGENT_TRANSLATION_BASE_URL
}
/result/
${
taskId
}
`
,
method
:
'GET'
,
headers
:
INTELLIGENT_TRANSLATION_HEADERS
})
}
src/views/intelligentTranslation/documentCompare.vue
浏览文件 @
50a8c95b
差异被折叠。
点击展开。
src/views/intelligentTranslation/index.vue
浏览文件 @
50a8c95b
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
<img
class=
"workspace-toolbar-icon"
src=
"@/assets/icons/tool-item-icon2.png"
alt=
""
/>
<img
class=
"workspace-toolbar-icon"
src=
"@/assets/icons/tool-item-icon2.png"
alt=
""
/>
<span
class=
"workspace-toolbar-heading"
>
智能翻译
</span>
<span
class=
"workspace-toolbar-heading"
>
智能翻译
</span>
</div>
</div>
<button
class=
"translate-btn"
type=
"button"
@
click=
"onTranslate"
>
<button
class=
"translate-btn"
type=
"button"
:disabled=
"submitLoading"
@
click=
"onTranslate"
>
AI翻译
{{
submitLoading
?
'提交中...'
:
'AI翻译'
}}
</button>
</button>
</div>
</div>
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
<div
v-else
class=
"upload-file-panel"
>
<div
v-else
class=
"upload-file-panel"
>
<ul
class=
"upload-file-list"
>
<ul
class=
"upload-file-list"
>
<li
v-for=
"(file, index) in selectedFiles"
:key=
"`$
{file.name}-${
index
}`" class="upload-file-item">
<li
v-for=
"(file, index) in selectedFiles"
:key=
"`$
{file.name}-${
file.lastModified}-${file.size
}`" class="upload-file-item">
<img
class=
"upload-file-type-icon"
:src=
"fileTypeIconUrl"
alt=
""
/>
<img
class=
"upload-file-type-icon"
:src=
"fileTypeIconUrl"
alt=
""
/>
<span
class=
"upload-file-name"
>
{{
file
.
name
}}
</span>
<span
class=
"upload-file-name"
>
{{
file
.
name
}}
</span>
<button
type=
"button"
class=
"upload-file-item-delete"
aria-label=
"删除该文件"
@
click=
"removeFileAt(index)"
>
<button
type=
"button"
class=
"upload-file-item-delete"
aria-label=
"删除该文件"
@
click=
"removeFileAt(index)"
>
...
@@ -90,8 +90,10 @@
...
@@ -90,8 +90,10 @@
<
script
setup
>
<
script
setup
>
import
{
computed
,
ref
}
from
'vue'
import
{
computed
,
ref
}
from
'vue'
import
{
ElMessage
}
from
'element-plus'
import
{
useRouter
}
from
'vue-router'
import
{
useRouter
}
from
'vue-router'
import
IntelligenceLeftTabBar
from
'@/components/intelligenceLeftTabBar/index.vue'
import
IntelligenceLeftTabBar
from
'@/components/intelligenceLeftTabBar/index.vue'
import
{
submitTranslationTask
}
from
'@/api/intelligentTranslation/index'
import
{
uploadRecordMock
}
from
'./mock'
import
{
uploadRecordMock
}
from
'./mock'
import
fileTypeIconUrl
from
'./icons/file-type-icon.png'
import
fileTypeIconUrl
from
'./icons/file-type-icon.png'
import
lineUploadIconSvg
from
'./icons/Line_Upload.svg?raw'
import
lineUploadIconSvg
from
'./icons/Line_Upload.svg?raw'
...
@@ -106,24 +108,45 @@ const sourceText = ref('')
...
@@ -106,24 +108,45 @@ const sourceText = ref('')
const
translatedText
=
ref
(
'点击“翻译”后展示占位结果'
)
const
translatedText
=
ref
(
'点击“翻译”后展示占位结果'
)
const
selectedFiles
=
ref
([])
const
selectedFiles
=
ref
([])
const
uploadRecords
=
ref
(
uploadRecordMock
)
const
uploadRecords
=
ref
(
uploadRecordMock
)
const
submitLoading
=
ref
(
false
)
const
isTextMode
=
computed
(()
=>
selectedFiles
.
value
.
length
===
0
)
const
isTextMode
=
computed
(()
=>
selectedFiles
.
value
.
length
===
0
)
const
onTranslate
=
()
=>
{
const
onTranslate
=
async
()
=>
{
if
(
isTextMode
.
value
)
{
if
(
isTextMode
.
value
)
{
const
text
=
sourceText
.
value
.
trim
()
ElMessage
.
warning
(
'请先上传 PDF 文件后再发起翻译'
)
translatedText
.
value
=
text
?
`【Mock译文】
${
text
}
`
:
'【Mock译文】当前没有输入文本,请先填写原文内容。'
return
return
}
}
router
.
push
({
const
targetFile
=
selectedFiles
.
value
[
0
]
name
:
'intelligentTranslationDocument'
,
if
(
!
targetFile
)
{
query
:
{
ElMessage
.
warning
(
'请先上传 PDF 文件'
)
fileName
:
selectedFiles
.
value
[
0
]?.
name
||
''
return
}
if
(
submitLoading
.
value
)
{
return
}
submitLoading
.
value
=
true
try
{
const
response
=
await
submitTranslationTask
(
targetFile
)
const
taskId
=
response
?.
data
?.
task_id
||
response
?.
data
?.
task_ids
?.[
0
]
if
(
!
taskId
)
{
throw
new
Error
(
'未获取到任务ID'
)
}
}
})
router
.
push
({
name
:
'intelligentTranslationDocument'
,
query
:
{
taskId
,
fileName
:
targetFile
.
name
||
''
}
})
}
catch
(
error
)
{
ElMessage
.
error
(
error
?.
message
||
'翻译任务提交失败,请稍后重试'
)
}
finally
{
submitLoading
.
value
=
false
}
}
}
const
onFileChange
=
(
event
)
=>
{
const
onFileChange
=
(
event
)
=>
{
...
@@ -291,6 +314,11 @@ function formatRecordDateOnly(timeStr) {
...
@@ -291,6 +314,11 @@ function formatRecordDateOnly(timeStr) {
cursor
:
pointer
;
cursor
:
pointer
;
}
}
.translate-btn
:disabled
{
opacity
:
0
.7
;
cursor
:
not
-
allowed
;
}
.workspace-source-block
{
.workspace-source-block
{
box-sizing
:
border-box
;
box-sizing
:
border-box
;
flex
:
1
;
flex
:
1
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论