Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
lls_program
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-09-01 13:59:10 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fe0affaee884476023e4efd09ad87b17fe412735
fe0affae
1 parent
266f8f70
style(useMediaPreview): 移除多余空行并保持代码格式一致
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
src/composables/useMediaPreview.js
src/composables/useMediaPreview.js
View file @
fe0affa
...
...
@@ -10,12 +10,12 @@ export function useMediaPreview() {
const
previewVisible
=
ref
(
false
);
const
previewImages
=
ref
([]);
const
previewIndex
=
ref
(
0
);
// 视频预览相关状态
const
videoVisible
=
ref
(
false
);
const
currentVideo
=
ref
(
null
);
const
videoId
=
ref
(
Date
.
now
());
/**
* 处理媒体项目点击事件
* @param {Object} item - 媒体项目
...
...
@@ -26,7 +26,7 @@ export function useMediaPreview() {
// 图片预览
const
imageItems
=
mediaList
.
filter
(
media
=>
media
.
type
===
'image'
);
previewImages
.
value
=
imageItems
.
map
(
img
=>
({
src
:
img
.
url
}));
// 计算当前图片在图片列表中的索引
const
imageIndex
=
imageItems
.
findIndex
(
img
=>
img
.
url
===
item
.
url
);
previewIndex
.
value
=
imageIndex
>=
0
?
imageIndex
:
0
;
...
...
@@ -38,7 +38,7 @@ export function useMediaPreview() {
videoVisible
.
value
=
true
;
}
};
/**
* 预览单张图片
* @param {string} imageUrl - 图片URL
...
...
@@ -48,7 +48,7 @@ export function useMediaPreview() {
previewIndex
.
value
=
0
;
previewVisible
.
value
=
true
;
};
/**
* 预览多张图片
* @param {Array} images - 图片URL数组
...
...
@@ -59,7 +59,7 @@ export function useMediaPreview() {
previewIndex
.
value
=
index
;
previewVisible
.
value
=
true
;
};
/**
* 播放视频
* @param {Object} video - 视频对象 {url, thumbnail, duration}
...
...
@@ -69,14 +69,14 @@ export function useMediaPreview() {
videoId
.
value
=
Date
.
now
();
videoVisible
.
value
=
true
;
};
/**
* 关闭图片预览
*/
const
closePreview
=
()
=>
{
previewVisible
.
value
=
false
;
};
/**
* 关闭视频播放
*/
...
...
@@ -84,28 +84,28 @@ export function useMediaPreview() {
videoVisible
.
value
=
false
;
currentVideo
.
value
=
null
;
};
/**
* 处理视频播放
*/
const
handleVideoPlay
=
()
=>
{
// 视频开始播放
};
/**
* 处理视频暂停
*/
const
handleVideoPause
=
()
=>
{
// 视频暂停播放
};
/**
* 处理全屏状态变化
*/
const
handleFullscreenChange
=
()
=>
{
// 全屏状态变化
};
/**
* 处理视频播放错误
* @param {Event} error - 错误事件
...
...
@@ -120,7 +120,7 @@ export function useMediaPreview() {
// 关闭视频弹框
closeVideo
();
};
/**
* 格式化视频时长
* @param {number} seconds - 秒数
...
...
@@ -131,7 +131,7 @@ export function useMediaPreview() {
const
remainingSeconds
=
seconds
%
60
;
return
`
${
minutes
}
:
${
remainingSeconds
.
toString
().
padStart
(
2
,
'0'
)}
`
;
};
return
{
// 状态
previewVisible
,
...
...
@@ -140,7 +140,7 @@ export function useMediaPreview() {
videoVisible
,
currentVideo
,
videoId
,
// 方法
handleMediaClick
,
previewSingleImage
,
...
...
@@ -154,4 +154,4 @@ export function useMediaPreview() {
handleVideoError
,
formatDuration
};
}
\ No newline at end of file
}
...
...
Please
register
or
login
to post a comment