Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
aitools
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周成波
aitools
Commits
2aba034b
Commit
2aba034b
authored
Nov 13, 2025
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复报错
parent
afd50a86
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
29 deletions
+49
-29
index.vue
src/views/sample_handle_v3/index.vue
+49
-29
No files found.
src/views/sample_handle_v3/index.vue
View file @
2aba034b
...
@@ -14,6 +14,7 @@ import {
...
@@ -14,6 +14,7 @@ import {
Star
,
Star
,
}
from
'@element-plus/icons-vue'
}
from
'@element-plus/icons-vue'
import
aitoolsService
from
'@/api/service/aitoolsService'
import
aitoolsService
from
'@/api/service/aitoolsService'
import
type
{
ElTree
}
from
'element-plus'
const
title
=
ref
(
'元芒数字'
)
const
title
=
ref
(
'元芒数字'
)
...
@@ -118,10 +119,17 @@ const onCheckClipVideoBtnClick = (dir_name: string) => {
...
@@ -118,10 +119,17 @@ const onCheckClipVideoBtnClick = (dir_name: string) => {
import
axios
from
'axios'
import
axios
from
'axios'
const
folderInput
=
ref
<
HTMLInputElement
|
null
>
(
null
)
const
folderInput
=
ref
<
HTMLInputElement
|
null
>
(
null
)
const
treeRef
=
ref
(
null
)
const
treeRef
=
ref
<
InstanceType
<
typeof
ElTree
>
|
null
>
(
null
)
const
treeData
=
ref
([])
interface
TreeNode
{
const
expandedKeys
=
ref
([])
id
:
number
const
selectedFile
=
ref
(
null
)
// 当前选中的文件节点
label
:
string
relativePath
:
string
isLeaf
:
boolean
children
:
TreeNode
[]
}
const
treeData
=
ref
<
TreeNode
[]
>
([])
const
expandedKeys
=
ref
<
number
[]
>
([])
const
selectedFile
=
ref
<
TreeNode
|
null
>
(
null
)
// 当前选中的文件节点
const
fileMap
=
new
Map
()
// 相对路径 -> File 对象
const
fileMap
=
new
Map
()
// 相对路径 -> File 对象
const
defaultProps
=
{
children
:
'children'
,
label
:
'label'
,
disabled
:
'disabled'
,
}
const
defaultProps
=
{
children
:
'children'
,
label
:
'label'
,
disabled
:
'disabled'
,
}
// 定义 handledFiles 中每个对象的结构
// 定义 handledFiles 中每个对象的结构
...
@@ -136,7 +144,6 @@ interface HandledFile {
...
@@ -136,7 +144,6 @@ interface HandledFile {
box_range
:
string
;
box_range
:
string
;
classes_select
:
string
;
classes_select
:
string
;
target_fps
:
string
;
target_fps
:
string
;
sample_path
:
string
;
}
}
// 使用定义的接口类型
// 使用定义的接口类型
const
handledFiles
=
ref
<
HandledFile
[]
>
([]);
const
handledFiles
=
ref
<
HandledFile
[]
>
([]);
...
@@ -165,17 +172,17 @@ function handleFolderSelect(event: any) {
...
@@ -165,17 +172,17 @@ function handleFolderSelect(event: any) {
/** 构建树结构 */
/** 构建树结构 */
function
buildTreeFromFiles
(
files
:
any
[])
{
function
buildTreeFromFiles
(
files
:
any
[])
{
const
root
=
{}
const
root
:
Record
<
string
,
any
>
=
{}
let
nodeId
=
1
let
nodeId
=
1
files
.
forEach
(
file
=>
{
files
.
forEach
(
file
=>
{
const
relPath
=
file
.
webkitRelativePath
const
relPath
=
file
.
webkitRelativePath
const
pathParts
=
relPath
.
split
(
'/'
)
const
pathParts
=
relPath
.
split
(
'/'
)
// 过滤点开头的
// 过滤点开头的
if
(
pathParts
.
some
(
p
=>
p
.
startsWith
(
'.'
)))
return
if
(
pathParts
.
some
(
(
p
:
any
)
=>
p
.
startsWith
(
'.'
)))
return
let
current
=
root
let
current
=
root
pathParts
.
forEach
((
part
,
index
)
=>
{
pathParts
.
forEach
((
part
:
string
,
index
:
number
)
=>
{
if
(
!
current
[
part
])
{
if
(
!
current
[
part
])
{
current
[
part
]
=
{
current
[
part
]
=
{
__isFile
:
index
===
pathParts
.
length
-
1
,
__isFile
:
index
===
pathParts
.
length
-
1
,
...
@@ -187,14 +194,27 @@ function buildTreeFromFiles(files: any[]) {
...
@@ -187,14 +194,27 @@ function buildTreeFromFiles(files: any[]) {
})
})
})
})
const
traverse
=
obj
=>
interface
TreeNodeRaw
{
__isFile
:
boolean
__children
:
Record
<
string
,
TreeNodeRaw
>
__path
:
string
}
interface
TreeNode
{
id
:
number
label
:
string
relativePath
:
string
isLeaf
:
boolean
children
:
TreeNode
[]
}
const
traverse
=
(
obj
:
Record
<
string
,
TreeNodeRaw
>
):
TreeNode
[]
=>
Object
.
entries
(
obj
).
map
(([
name
,
node
])
=>
({
Object
.
entries
(
obj
).
map
(([
name
,
node
])
=>
({
id
:
nodeId
++
,
id
:
nodeId
++
,
label
:
name
,
label
:
name
,
relativePath
:
node
.
__path
,
relativePath
:
node
.
__path
,
isLeaf
:
node
.
__isFile
,
isLeaf
:
node
.
__isFile
,
children
:
node
.
__isFile
?
[]
:
traverse
(
node
.
__children
),
children
:
node
.
__isFile
?
[]
:
traverse
(
node
.
__children
),
handled
:
'未处理'
,
}))
}))
return
traverse
(
root
)
return
traverse
(
root
)
...
@@ -214,7 +234,7 @@ function collectAllIds(nodes: any[]) {
...
@@ -214,7 +234,7 @@ function collectAllIds(nodes: any[]) {
}
}
/** 勾选状态变化 */
/** 勾选状态变化 */
function
handleCheckChange
(
node
,
checked
)
{
function
handleCheckChange
(
node
:
TreeNode
,
checked
:
boolean
)
{
if
(
!
node
.
isLeaf
)
{
if
(
!
node
.
isLeaf
)
{
treeRef
.
value
?.
setChecked
(
node
,
false
,
false
)
treeRef
.
value
?.
setChecked
(
node
,
false
,
false
)
return
return
...
@@ -224,7 +244,7 @@ function handleCheckChange(node, checked) {
...
@@ -224,7 +244,7 @@ function handleCheckChange(node, checked) {
// 单选逻辑:取消其他勾选
// 单选逻辑:取消其他勾选
const
checkedKeys
=
treeRef
.
value
?.
getCheckedKeys
()
||
[]
const
checkedKeys
=
treeRef
.
value
?.
getCheckedKeys
()
||
[]
checkedKeys
.
forEach
(
key
=>
{
checkedKeys
.
forEach
(
key
=>
{
if
(
key
!==
node
.
id
)
treeRef
.
value
.
setChecked
(
key
,
false
,
false
)
if
(
key
!==
node
.
id
)
treeRef
.
value
?
.
setChecked
(
key
,
false
,
false
)
})
})
selectedFile
.
value
=
node
selectedFile
.
value
=
node
// console.log(selectedFile.value)
// console.log(selectedFile.value)
...
@@ -235,7 +255,7 @@ function handleCheckChange(node, checked) {
...
@@ -235,7 +255,7 @@ function handleCheckChange(node, checked) {
}
}
// 如果整棵树都没有被选择节点
// 如果整棵树都没有被选择节点
const
anyChecked
=
treeRef
.
value
?.
getCheckedKeys
()
.
length
>
0
const
anyChecked
=
treeRef
.
value
&&
treeRef
.
value
.
getCheckedKeys
()?
.
length
>
0
if
(
!
anyChecked
)
{
if
(
!
anyChecked
)
{
// console.log('❌ 整棵树都没有被选择节点')
// console.log('❌ 整棵树都没有被选择节点')
selectedFile
.
value
=
null
selectedFile
.
value
=
null
...
@@ -290,6 +310,7 @@ async function uploadSelectedFile() {
...
@@ -290,6 +310,7 @@ async function uploadSelectedFile() {
}
}
}
}
const
continue_to_negative
=
()
=>
{
const
continue_to_negative
=
()
=>
{
if
(
!
selectedFile
.
value
)
return
;
// 添加非空校验
// 保存已处理的信息
// 保存已处理的信息
handledFiles
.
value
.
push
({
handledFiles
.
value
.
push
({
id
:
selectedFile
.
value
.
id
,
id
:
selectedFile
.
value
.
id
,
...
@@ -306,9 +327,9 @@ const continue_to_negative = () => {
...
@@ -306,9 +327,9 @@ const continue_to_negative = () => {
console
.
log
(
'handledFiles ='
,
handledFiles
.
value
)
console
.
log
(
'handledFiles ='
,
handledFiles
.
value
)
// 将已处理文件置灰
// 将已处理文件置灰
treeData
.
value
=
treeData
.
value
.
map
(
node
=>
{
treeData
.
value
=
treeData
.
value
.
map
(
node
=>
{
const
disableNode
=
(
n
)
=>
{
const
disableNode
=
(
n
:
any
)
=>
{
if
(
n
.
relativePath
===
selectedFile
.
value
.
relativePath
)
{
if
(
n
.
relativePath
===
selectedFile
.
value
?
.
relativePath
)
{
return
{
...
n
,
disabled
:
true
,
handled
:
'已处理'
}
return
{
...
n
,
disabled
:
true
}
}
}
if
(
n
.
children
?.
length
)
{
if
(
n
.
children
?.
length
)
{
return
{
...
n
,
children
:
n
.
children
.
map
(
disableNode
)
}
return
{
...
n
,
children
:
n
.
children
.
map
(
disableNode
)
}
...
@@ -396,7 +417,6 @@ const downloadAllSamples = async () => {
...
@@ -396,7 +417,6 @@ const downloadAllSamples = async () => {
<div
class=
"folder-viewer"
v-if=
"steps_active === -1"
v-loading=
"file_loading"
>
<div
class=
"folder-viewer"
v-if=
"steps_active === -1"
v-loading=
"file_loading"
>
<div
class=
"toolbar"
>
<div
class=
"toolbar"
>
<el-button
type=
"primary"
@
click=
"chooseFolder"
>
选择文件夹
</el-button>
<el-button
type=
"primary"
@
click=
"chooseFolder"
>
选择文件夹
</el-button>
</div>
</div>
<div
class=
"toolbar"
>
<div
class=
"toolbar"
>
<el-tree
<el-tree
...
@@ -602,9 +622,9 @@ const downloadAllSamples = async () => {
...
@@ -602,9 +622,9 @@ const downloadAllSamples = async () => {
</main>
</main>
<el-dialog
v-model=
"dialogVisible"
title=
"视频片段(如果挡住后面的图,按这里可以移动)"
draggable
width=
"30%"
>
<el-dialog
v-model=
"dialogVisible"
title=
"视频片段(如果挡住后面的图,按这里可以移动)"
draggable
width=
"30%"
>
<video
id=
"clip-video"
controls
style=
"width: 100%;"
autoplay
></video>
<video
id=
"clip-video"
controls
style=
"width: 100%;"
autoplay
></video>
</el-dialog>
</el-dialog>
</template>
</template>
...
...
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