优化加载页面
This commit is contained in:
@@ -5,7 +5,7 @@ import global from "@/constants/global";
|
||||
const service = axios.create();
|
||||
import { ElMessage } from 'element-plus'
|
||||
service.interceptors.request.use(config => {
|
||||
console.log('config', config);
|
||||
// console.log('config', config);
|
||||
return config;
|
||||
}, error => {
|
||||
Promise.reject(error);
|
||||
@@ -13,7 +13,7 @@ service.interceptors.request.use(config => {
|
||||
|
||||
service.interceptors.response.use(res => {
|
||||
userLogout(res.headers[global.NEED_LOGOUT.toLowerCase()]);
|
||||
console.log('res.data', res);
|
||||
// console.log('res.data', res);
|
||||
// if (res.data.code == 200) {
|
||||
// ElMessage({
|
||||
// message: "成功",
|
||||
|
@@ -135,7 +135,11 @@
|
||||
:id="`svga-player${scope.row.id}`"
|
||||
style="width: 300px; max-height: 300px; display: block"
|
||||
>
|
||||
{{ initSVGAList(scope.row.effect, scope.row.id) }}
|
||||
{{
|
||||
scope.row.effect && scope.row.id
|
||||
? initSVGAList(scope.row.effect, scope.row.id)
|
||||
: ""
|
||||
}}
|
||||
<!-- <img style="width: 100px; height: 100px; display: block" src="/Uploads/article/original_img/1487053722.jpg" alt="">
|
||||
<el-image src=""></el-image> -->
|
||||
</div>
|
||||
@@ -669,24 +673,34 @@ export default {
|
||||
|
||||
const initSVGA = (url) => {
|
||||
nextTick(() => {
|
||||
const container = document.getElementById("svga-player");
|
||||
if (container) {
|
||||
const player = new SVGA.Player(container);
|
||||
const parser = new SVGA.Parser();
|
||||
parser.load(url, (videoItem) => {
|
||||
player.setVideoItem(videoItem);
|
||||
player.startAnimation();
|
||||
});
|
||||
}
|
||||
setTimeout(function () {
|
||||
const container = document.getElementById("svga-player");
|
||||
if (container) {
|
||||
const player = new SVGA.Player(container);
|
||||
const parser = new SVGA.Parser();
|
||||
parser.load(
|
||||
url,
|
||||
(videoItem) => {
|
||||
player.setVideoItem(videoItem);
|
||||
player.startAnimation();
|
||||
},
|
||||
(error) => {
|
||||
console.log("SVGA失败", error);
|
||||
}
|
||||
);
|
||||
}
|
||||
}, 10);
|
||||
});
|
||||
};
|
||||
|
||||
const initializedIds = new Set();
|
||||
const initSVGAList = (url, id) => {
|
||||
if (initializedIds.has(id)) return; // 避免重复初始化
|
||||
console.log('SVGASVGASVGASVGASVGASVGA',url,id);
|
||||
nextTick(() => {
|
||||
const container = document.getElementById("svga-player" + id);
|
||||
if (!container) {
|
||||
console.error(`SVGA container for ID ${id} not found`);
|
||||
return; // 终止后续操作
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const player = new SVGA.Player(container);
|
||||
@@ -695,6 +709,7 @@ export default {
|
||||
player.setVideoItem(videoItem);
|
||||
player.startAnimation();
|
||||
});
|
||||
initializedIds.add(id); // 标记已初始化
|
||||
} catch (error) {
|
||||
console.error("SVGA initialization failed:", error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user