Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
AI_BOOK_TOOL
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_BOOK_TOOL
Commits
cc0374ee
Commit
cc0374ee
authored
May 12, 2025
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat
parent
2371396a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
105 additions
and
7 deletions
+105
-7
index.html
form/index.html
+2
-2
index.js
form/index.js
+103
-5
No files found.
form/index.html
View file @
cc0374ee
...
...
@@ -36,7 +36,7 @@
<!-- 左侧图片编辑区域 -->
<el-col
:span=
"12"
>
<div
class=
"image-editor"
v-if=
"currentPage"
>
<div
class=
"image-container"
ref=
"imageContainer"
>
<div
class=
"image-container"
ref=
"imageContainer"
@
click=
"handleImageClick"
>
<div
class=
"image-wrapper"
>
<img
:src=
"currentPage.image_url"
ref=
"pageImage"
@
load=
"handleImageLoad"
>
<template
v-for=
"(group, groupIndex) in currentPage.groups"
>
...
...
@@ -84,7 +84,7 @@
<!-- 全屏浮层 -->
<div
class=
"fullscreen-editor"
v-if=
"isFullscreen"
@
click
.
self=
"toggleFullscreen"
>
<div
class=
"fullscreen-content"
>
<div
class=
"image-container"
ref=
"fullscreenContainer"
>
<div
class=
"image-container"
ref=
"fullscreenContainer"
@
click=
"handleFullscreenImageClick"
>
<div
class=
"image-wrapper"
>
<img
:src=
"currentPage.image_url"
ref=
"fullscreenImage"
@
load=
"handleFullscreenImageLoad"
>
<template
v-for=
"(group, groupIndex) in currentPage.groups"
>
...
...
form/index.js
View file @
cc0374ee
...
...
@@ -37,6 +37,10 @@ new Vue({
fullscreenImageWidth
:
0
,
fullscreenImageHeight
:
0
,
fullscreenImageRect
:
null
,
// 图片预加载相关
preloadedImages
:
{},
preloadProgress
:
0
,
},
mounted
()
{
...
...
@@ -71,6 +75,9 @@ new Vue({
this
.
currentPageIndex
=
1
;
this
.
currentPage
=
this
.
pages
[
0
];
// 开始预加载图片
this
.
preloadImages
();
this
.
loading
=
false
;
this
.
$message
.
success
(
'
数据加载成功
'
);
}
catch
(
error
)
{
...
...
@@ -81,6 +88,62 @@ new Vue({
}
},
// 预加载所有图片
preloadImages
()
{
if
(
!
this
.
pages
||
this
.
pages
.
length
===
0
)
return
;
let
loadedCount
=
0
;
const
totalImages
=
this
.
pages
.
length
;
// 创建加载提示
const
loadingInstance
=
this
.
$loading
({
lock
:
true
,
text
:
'
正在预加载图片 (0%)
'
,
spinner
:
'
el-icon-loading
'
,
background
:
'
rgba(0, 0, 0, 0.7)
'
});
this
.
pages
.
forEach
((
page
,
index
)
=>
{
if
(
!
page
.
image_url
)
return
;
const
img
=
new
Image
();
img
.
onload
=
()
=>
{
// 存储预加载的图片
this
.
preloadedImages
[
page
.
image_url
]
=
img
;
// 更新进度
loadedCount
++
;
this
.
preloadProgress
=
Math
.
floor
((
loadedCount
/
totalImages
)
*
100
);
// 更新加载提示文字
loadingInstance
.
text
=
`正在预加载图片 (
${
this
.
preloadProgress
}
%)`
;
// 所有图片加载完成
if
(
loadedCount
===
totalImages
)
{
loadingInstance
.
close
();
this
.
$message
.
success
(
'
图片预加载完成
'
);
}
};
img
.
onerror
=
()
=>
{
console
.
error
(
`Failed to load image:
${
page
.
image_url
}
`
);
// 即使加载失败也计入进度
loadedCount
++
;
this
.
preloadProgress
=
Math
.
floor
((
loadedCount
/
totalImages
)
*
100
);
loadingInstance
.
text
=
`正在预加载图片 (
${
this
.
preloadProgress
}
%)`
;
if
(
loadedCount
===
totalImages
)
{
loadingInstance
.
close
();
}
};
// 开始加载图片
img
.
src
=
page
.
image_url
;
});
},
// 初始化波形图
initWavesurfer
()
{
if
(
!
this
.
audioPoints
||
!
this
.
audioPoints
.
audio_url
)
{
...
...
@@ -332,20 +395,21 @@ new Vue({
return
Math
.
min
(
500
,
Math
.
max
(
1
,
Math
.
floor
(
100
/
duration
)));
},
//
图片加载完成后的处理
//
处理图片加载
handleImageLoad
()
{
const
img
=
this
.
$refs
.
pageImage
;
const
container
=
this
.
$refs
.
imageContainer
;
if
(
!
img
||
!
container
)
return
;
// 如果有预加载的图片,使用其原始尺寸
const
preloadedImg
=
this
.
preloadedImages
[
this
.
currentPage
.
image_url
];
const
imgNaturalWidth
=
preloadedImg
?
preloadedImg
.
naturalWidth
:
img
.
naturalWidth
;
const
imgNaturalHeight
=
preloadedImg
?
preloadedImg
.
naturalHeight
:
img
.
naturalHeight
;
// 获取容器的实际尺寸(减去内边距)
const
containerWidth
=
container
.
clientWidth
-
20
;
const
containerHeight
=
container
.
clientHeight
-
20
;
// 获取图片的原始尺寸
const
imgNaturalWidth
=
img
.
naturalWidth
;
const
imgNaturalHeight
=
img
.
naturalHeight
;
// 计算容器和图片的宽高比
const
containerRatio
=
containerWidth
/
containerHeight
;
const
imageRatio
=
imgNaturalWidth
/
imgNaturalHeight
;
...
...
@@ -835,6 +899,40 @@ new Vue({
this
.
updateAudioRegion
();
}
},
// 处理图片区域点击
handleImageClick
(
event
)
{
// 如果点击的是矩形框或其相关元素,不处理
if
(
event
.
target
.
closest
(
'
.text-rect
'
)
||
event
.
target
.
closest
(
'
.resize-handle
'
)
||
event
.
target
.
closest
(
'
.delete-rect-btn
'
)
||
event
.
target
.
closest
(
'
.add-rect-btn
'
)
||
event
.
target
.
closest
(
'
.fullscreen-btn
'
))
{
return
;
}
// 取消选中状态
this
.
selectedGroup
=
null
;
this
.
currentGroup
=
null
;
this
.
selectedItemIndex
=
null
;
},
// 处理全屏图片区域点击
handleFullscreenImageClick
(
event
)
{
// 如果点击的是矩形框或其相关元素,不处理
if
(
event
.
target
.
closest
(
'
.text-rect
'
)
||
event
.
target
.
closest
(
'
.resize-handle
'
)
||
event
.
target
.
closest
(
'
.delete-rect-btn
'
)
||
event
.
target
.
closest
(
'
.add-rect-btn
'
)
||
event
.
target
.
closest
(
'
.fullscreen-btn
'
))
{
return
;
}
// 取消选中状态
this
.
selectedGroup
=
null
;
this
.
currentGroup
=
null
;
this
.
selectedItemIndex
=
null
;
},
},
beforeDestroy
()
{
...
...
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