添加 LivePhoto 📷 功能
This commit is contained in:
parent
1275760960
commit
bbaa40d02d
66
public/assets/js/livephotoskit.js
Normal file
66
public/assets/js/livephotoskit.js
Normal file
File diff suppressed because one or more lines are too long
BIN
public/assets/livephoto/1.mp4
Normal file
BIN
public/assets/livephoto/1.mp4
Normal file
Binary file not shown.
BIN
public/assets/livephoto/1.webp
Normal file
BIN
public/assets/livephoto/1.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 53 KiB |
BIN
public/assets/livephoto/2.mp4
Normal file
BIN
public/assets/livephoto/2.mp4
Normal file
Binary file not shown.
BIN
public/assets/livephoto/2.webp
Normal file
BIN
public/assets/livephoto/2.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
@ -433,6 +433,19 @@ $\cup$、$\cap$、$\in$、$\notin$、$\ni$、$\subset$、$\subseteq$、$\supset$
|
|||||||

|

|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
### LivePhoto 组件
|
||||||
|
|
||||||
|
```md
|
||||||
|
<!-- 纵向图片 -->
|
||||||
|
::vhLivePhoto{photo="https://static.vvhan.com/img/1.webp" video="https://static.vvhan.com/img/1.mp4" type="y"}
|
||||||
|
<!-- 横向图片 -->
|
||||||
|
::vhLivePhoto{photo="https://static.vvhan.com/img/2.webp" video="https://static.vvhan.com/img/2.mp4"}
|
||||||
|
```
|
||||||
|
|
||||||
|
::vhLivePhoto{photo="/public/assets/livephoto/1.webp" video="/public/assets/livephoto/1.mp4" type="y"}
|
||||||
|
|
||||||
|
::vhLivePhoto{photo="/public/assets/livephoto/2.webp" video="/public/assets/livephoto/2.mp4"}
|
||||||
|
|
||||||
### Music 组件
|
### Music 组件
|
||||||
|
|
||||||
```md
|
```md
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import codeInit from "../scripts/Code";
|
|||||||
import videoInit from "../scripts/Video";
|
import videoInit from "../scripts/Video";
|
||||||
// 初始化音乐播放器
|
// 初始化音乐播放器
|
||||||
import musicInit from "../scripts/Music";
|
import musicInit from "../scripts/Music";
|
||||||
|
// 初始化 LivePhoto
|
||||||
|
import livePhotoInit from './LivePhoto'
|
||||||
// 初始化BackTop组件
|
// 初始化BackTop组件
|
||||||
import BackTopInitFn from "../scripts/BackTop";
|
import BackTopInitFn from "../scripts/BackTop";
|
||||||
// 搜索
|
// 搜索
|
||||||
@ -72,6 +74,8 @@ const indexInit = async (only: boolean = true) => {
|
|||||||
videoInit(videoList);
|
videoInit(videoList);
|
||||||
// 文章音乐播放器初始化
|
// 文章音乐播放器初始化
|
||||||
musicInit(MusicList);
|
musicInit(MusicList);
|
||||||
|
// 初始化 LivePhoto
|
||||||
|
livePhotoInit();
|
||||||
};
|
};
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
|||||||
15
src/scripts/LivePhoto.ts
Normal file
15
src/scripts/LivePhoto.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// SmoothScroll 滚动优化
|
||||||
|
import { LoadScript } from "../utils/index";
|
||||||
|
declare const LivePhotosKit: any;
|
||||||
|
export default async () => {
|
||||||
|
const livePhotoList = document.querySelectorAll('.vh-node.vh-vhLivePhoto');
|
||||||
|
if (!livePhotoList.length) return;
|
||||||
|
await LoadScript("/assets/js/livephotoskit.js");
|
||||||
|
livePhotoList.forEach((i: any) => {
|
||||||
|
const { photo, video } = i.dataset;
|
||||||
|
i.innerHTML = `<div class="live-raw"></div>`
|
||||||
|
const player = LivePhotosKit.Player(i.querySelector('.live-raw'));
|
||||||
|
player.photoSrc = photo;
|
||||||
|
player.videoSrc = video;
|
||||||
|
})
|
||||||
|
};
|
||||||
@ -547,6 +547,34 @@ section.vh-container {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ::vhLivePhoto
|
||||||
|
&.vh-vhLivePhoto {
|
||||||
|
box-sizing: border-box;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 16 / 9;
|
||||||
|
background: #fff url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' width='8' height='8' fill='none' stroke='rgb(0 0 0 / 0.1)'%3e%3cpath d='M0 .5H31.5V32'/%3e%3c/svg%3e");
|
||||||
|
|
||||||
|
&.vhLivePhoto-y {
|
||||||
|
aspect-ratio: 9 / 16;
|
||||||
|
max-height: 66vh;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&>div {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
:not(.lpk-live-photo-renderer) {
|
||||||
|
&>canvas {
|
||||||
|
z-index: 9 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面图片样式
|
// 页面图片样式
|
||||||
|
|||||||
@ -186,6 +186,7 @@
|
|||||||
bottom: -0.4rem;
|
bottom: -0.4rem;
|
||||||
width: 0.8rem;
|
width: 0.8rem;
|
||||||
height: 0.8rem;
|
height: 0.8rem;
|
||||||
|
border-radius: 50%;
|
||||||
background: #fff url("/public/assets/images/admin.svg") no-repeat;
|
background: #fff url("/public/assets/images/admin.svg") no-repeat;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,7 +31,7 @@ const fmtDate = (time: string | Date, hours_status = true) => {
|
|||||||
years && `${years}年`,
|
years && `${years}年`,
|
||||||
months && `${months}月`,
|
months && `${months}月`,
|
||||||
days && `${days}天`,
|
days && `${days}天`,
|
||||||
hours_status ? hours && !years && !months && `${hours}小时` : 0,
|
(hours_status || days === 0) ? hours && !years && !months && `${hours}小时` : 0,
|
||||||
hours_status ? minutes && !years && !months && !days && `${minutes}分` : '',
|
hours_status ? minutes && !years && !months && !days && `${minutes}分` : '',
|
||||||
hours_status ? seconds && !years && !months && !days && !hours && `${seconds}秒` : ''
|
hours_status ? seconds && !years && !months && !days && !hours && `${seconds}秒` : ''
|
||||||
].filter(Boolean).join('');
|
].filter(Boolean).join('');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user