Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ai_fundub
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
template admin
ai_fundub
Commits
6a7a8121
Commit
6a7a8121
authored
Jul 29, 2026
by
Jeff nan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
04f2dc2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
12 deletions
+83
-12
index.js
form/index.js
+83
-12
No files found.
form/index.js
View file @
6a7a8121
...
...
@@ -700,12 +700,14 @@ function initVueApp(savedData) {
// 兼容数据根可能不是数组(深度搜索)
const
subtitleList
=
this
.
extractArrayFromJson
(
subtitleJson
,
'
subtitle
'
);
const
translatedList
=
this
.
extractArrayFromJson
(
translatedJson
,
'
translated
'
);
// 打开编辑器:只对齐「界面上」看到的时间(末词/翻译末段 → 句子 end)
// 打开编辑器:只对齐「界面上」看到的时间
// start: 首词/翻译首段 → 句子 start;end: 末词/翻译末段 → 句子 end
// 真正写回文件要等「覆盖上传并重新生成」
this
.
calibrateSubtitleWordEndTimes
(
subtitleList
);
this
.
subtitleEditor
.
subtitleList
=
subtitleList
||
[];
this
.
subtitleEditor
.
translatedList
=
translatedList
||
[];
this
.
subtitleEditor
.
mergedList
=
this
.
buildMergedList
(
this
.
subtitleEditor
.
subtitleList
,
this
.
subtitleEditor
.
translatedList
);
this
.
alignEditorViewStartTimes
(
this
.
subtitleEditor
.
mergedList
);
this
.
alignEditorViewEndTimes
(
this
.
subtitleEditor
.
mergedList
);
}
catch
(
e
)
{
console
.
error
(
e
);
...
...
@@ -926,10 +928,9 @@ function initVueApp(savedData) {
const
display
=
this
.
formatTime
(
total
);
if
(
d
.
type
===
'
sentence-start
'
)
{
// 句子 start ↔ 首词 start ↔ 翻译首段 start 保持一致
item
.
start
=
display
;
if
(
words
[
0
])
{
this
.
$set
(
words
[
0
],
'
start
'
,
this
.
serializeTimeByFormat
(
total
,
this
.
timeWriteFormat
(
words
[
0
])));
}
this
.
syncSentenceStartToFirstSegments
(
item
,
total
);
}
else
if
(
d
.
type
===
'
sentence-end
'
)
{
// 句子 end ↔ 末词 end ↔ 翻译末段 end 保持一致
item
.
end
=
display
;
...
...
@@ -941,7 +942,11 @@ function initVueApp(savedData) {
return
;
}
this
.
$set
(
word
,
'
start
'
,
this
.
serializeTimeByFormat
(
total
,
this
.
timeWriteFormat
(
word
)));
if
(
d
.
wordIndex
===
0
)
item
.
start
=
display
;
// 改的是第一个单词:同步句子 start + 翻译首段 start
if
(
d
.
wordIndex
===
0
)
{
item
.
start
=
display
;
this
.
syncSentenceStartToFirstSegments
(
item
,
total
,
{
skipWords
:
true
});
}
}
else
if
(
d
.
type
===
'
word-end
'
)
{
const
word
=
words
[
d
.
wordIndex
];
if
(
!
word
)
{
...
...
@@ -963,6 +968,29 @@ function initVueApp(savedData) {
this
.
$message
.
success
(
'
时间已更新
'
);
},
// 编辑过程中:句子 start 同步到界面上的首词 / 翻译首段
syncSentenceStartToFirstSegments
(
item
,
startSec
,
options
=
{})
{
if
(
!
item
||
isNaN
(
startSec
))
return
;
const
skipWords
=
!!
(
options
&&
options
.
skipWords
);
const
skipTranslated
=
!!
(
options
&&
options
.
skipTranslated
);
const
words
=
Array
.
isArray
(
item
.
sWordsRef
)
?
item
.
sWordsRef
:
[];
if
(
!
skipWords
&&
words
.
length
)
{
const
first
=
words
[
0
];
if
(
first
)
{
this
.
$set
(
first
,
'
start
'
,
this
.
serializeTimeByFormat
(
startSec
,
this
.
timeWriteFormat
(
first
)));
}
}
if
(
!
skipTranslated
)
{
const
tSegs
=
Array
.
isArray
(
item
.
tItemsRef
)
?
item
.
tItemsRef
:
[];
if
(
tSegs
.
length
)
{
const
firstT
=
tSegs
[
0
];
if
(
firstT
)
{
this
.
$set
(
firstT
,
'
start
'
,
this
.
serializeTimeByFormat
(
startSec
,
this
.
timeWriteFormat
(
firstT
)));
}
}
}
},
// 编辑过程中:句子 end 同步到界面上的末词 / 翻译末段
syncSentenceEndToLastSegments
(
item
,
endSec
,
options
=
{})
{
if
(
!
item
||
isNaN
(
endSec
))
return
;
...
...
@@ -986,6 +1014,36 @@ function initVueApp(savedData) {
}
},
// 打开编辑器:按界面句子 start,对齐原文首词 / 翻译首段(仅编辑视图,不落盘)
alignEditorViewStartTimes
(
mergedList
)
{
let
fixed
=
0
;
(
mergedList
||
[]).
forEach
((
item
)
=>
{
if
(
!
item
)
return
;
const
startSec
=
this
.
parseTimeToSeconds
(
item
.
start
);
if
(
isNaN
(
startSec
))
return
;
let
changed
=
false
;
const
words
=
Array
.
isArray
(
item
.
sWordsRef
)
?
item
.
sWordsRef
:
[];
if
(
words
.
length
)
{
const
first
=
words
[
0
];
const
wordStartSec
=
this
.
parseTimeToSeconds
(
first
&&
first
.
start
);
if
(
isNaN
(
wordStartSec
)
||
Math
.
abs
(
wordStartSec
-
startSec
)
>=
0.001
)
changed
=
true
;
}
const
tSegs
=
Array
.
isArray
(
item
.
tItemsRef
)
?
item
.
tItemsRef
:
[];
if
(
tSegs
.
length
)
{
const
firstT
=
tSegs
[
0
];
const
tStartSec
=
this
.
parseTimeToSeconds
(
firstT
&&
firstT
.
start
);
if
(
isNaN
(
tStartSec
)
||
Math
.
abs
(
tStartSec
-
startSec
)
>=
0.001
)
changed
=
true
;
}
if
(
!
changed
)
return
;
this
.
syncSentenceStartToFirstSegments
(
item
,
startSec
);
fixed
+=
1
;
});
if
(
fixed
>
0
)
{
console
.
info
(
`[编辑视图] 已按句子 start 对齐
${
fixed
}
句的首词/翻译首段`
);
}
return
fixed
;
},
// 打开编辑器:按界面句子 end,对齐原文末词 / 翻译末段(仅编辑视图,不落盘)
alignEditorViewEndTimes
(
mergedList
)
{
let
fixed
=
0
;
...
...
@@ -1417,14 +1475,28 @@ function initVueApp(savedData) {
const
sWords
=
Array
.
isArray
(
m
.
sWordsRef
)
?
m
.
sWordsRef
.
slice
()
:
[];
const
tSegs
=
Array
.
isArray
(
m
.
tItemsRef
)
?
m
.
tItemsRef
.
slice
()
:
[];
// 以界面句子时间为准;保存时强制末词/翻译末段与之对齐
let
sStartSec
=
this
.
parseTimeToSeconds
(
sWords
.
length
?
sWords
[
0
].
start
:
m
.
start
);
// 以界面句子时间为准;保存时强制首/末词、翻译首/末段与之对齐
let
sStartSec
=
this
.
parseTimeToSeconds
(
m
.
start
);
if
(
isNaN
(
sStartSec
)
&&
sWords
.
length
)
{
sStartSec
=
this
.
parseTimeToSeconds
(
sWords
[
0
].
start
);
}
let
sEndSec
=
this
.
parseTimeToSeconds
(
m
.
end
);
if
(
isNaN
(
sEndSec
)
&&
sWords
.
length
)
{
sEndSec
=
this
.
parseTimeToSeconds
(
sWords
[
sWords
.
length
-
1
].
end
);
}
if
(
isNaN
(
sStartSec
)
&&
!
isNaN
(
this
.
parseTimeToSeconds
(
m
.
start
)))
{
sStartSec
=
this
.
parseTimeToSeconds
(
m
.
start
);
if
(
!
isNaN
(
sStartSec
))
{
if
(
sWords
.
length
)
{
const
first
=
sWords
[
0
];
sWords
[
0
]
=
Object
.
assign
({},
first
,
{
start
:
this
.
serializeTimeByFormat
(
sStartSec
,
this
.
timeWriteFormat
(
first
)),
});
}
if
(
tSegs
.
length
)
{
const
firstT
=
tSegs
[
0
];
tSegs
[
0
]
=
Object
.
assign
({},
firstT
,
{
start
:
this
.
serializeTimeByFormat
(
sStartSec
,
this
.
timeWriteFormat
(
firstT
)),
});
}
}
if
(
!
isNaN
(
sEndSec
))
{
if
(
sWords
.
length
)
{
...
...
@@ -1450,9 +1522,8 @@ function initVueApp(savedData) {
text
:
this
.
buildSentenceFromWords
(
sWords
),
});
let
tStartSec
=
this
.
parseTimeToSeconds
(
tSegs
.
length
?
tSegs
[
0
].
start
:
sStartSec
);
if
(
isNaN
(
tStartSec
))
tStartSec
=
sStartSec
;
// 翻译条目 end 与句子 end 实际对齐(同一时间)
// 翻译条目 start/end 与句子 start/end 实际对齐
const
tStartSec
=
!
isNaN
(
sStartSec
)
?
sStartSec
:
this
.
parseTimeToSeconds
(
tSegs
.
length
?
tSegs
[
0
].
start
:
sStartSec
);
const
tEndSec
=
!
isNaN
(
sEndSec
)
?
sEndSec
:
this
.
parseTimeToSeconds
(
tSegs
.
length
?
tSegs
[
tSegs
.
length
-
1
].
end
:
sEndSec
);
const
tStartOut
=
this
.
serializeTimeByFormat
(
tStartSec
,
tFmt
);
const
tEndOut
=
this
.
serializeTimeByFormat
(
tEndSec
,
tFmt
);
...
...
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