mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 01:10:16 +08:00
更新应用程序配置,修改图标和标题,优化截图加载逻辑,移除懒加载初始化
This commit is contained in:
21
src/App.vue
21
src/App.vue
@@ -122,7 +122,7 @@ const openDetail = (app) => {
|
||||
const loadScreenshots = (app) => {
|
||||
screenshots.value = [];
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
const screenshotUrl = `./${app._category}/${app.Pkgname}/screen_${i}.png`;
|
||||
const screenshotUrl = `${APM_STORE_BASE_URL}/${APM_STORE_ARCHITECTURE}/${app._category}/${app.Pkgname}/screen_${i}.png`;
|
||||
const img = new Image();
|
||||
img.src = screenshotUrl;
|
||||
img.onload = () => {
|
||||
@@ -242,24 +242,6 @@ const escapeHtml = (s) => {
|
||||
})[c]);
|
||||
};
|
||||
|
||||
const initLazyLoad = () => {
|
||||
if ('IntersectionObserver' in window) {
|
||||
observer.value = new IntersectionObserver((entries) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
const img = entry.target;
|
||||
img.src = img.dataset.src;
|
||||
img.classList.remove('lazy');
|
||||
observer.value.unobserve(img);
|
||||
}
|
||||
});
|
||||
}, {
|
||||
rootMargin: '50px 0px',
|
||||
threshold: 0.1
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const loadCategories = async () => {
|
||||
try {
|
||||
const response = await axiosInstance.get(`/${APM_STORE_ARCHITECTURE}/categories.json`);
|
||||
@@ -305,7 +287,6 @@ const handleSearchInput = (e) => {
|
||||
// 生命周期钩子
|
||||
onMounted(async () => {
|
||||
initTheme();
|
||||
initLazyLoad();
|
||||
|
||||
await loadCategories();
|
||||
await loadApps();
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, defineProps, defineEmits, onMounted, onBeforeUnmount, ref } from 'vue';
|
||||
import { computed, defineProps, defineEmits, onMounted, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { APM_STORE_ARCHITECTURE, APM_STORE_BASE_URL } from '../global/StoreConfig';
|
||||
|
||||
const props = defineProps({
|
||||
@@ -86,6 +86,16 @@ onMounted(() => {
|
||||
}
|
||||
});
|
||||
|
||||
// 当 app 变更时重置懒加载状态并重新观察
|
||||
watch(iconPath, () => {
|
||||
loadedIcon.value = 'data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"%3E%3Crect fill="%23f0f0f0" width="100" height="100"/%3E%3C/svg%3E';
|
||||
isLoaded.value = false;
|
||||
if (observer && iconImg.value) {
|
||||
observer.unobserve(iconImg.value);
|
||||
observer.observe(iconImg.value);
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
// 清理 observer
|
||||
if (observer && iconImg.value) {
|
||||
|
||||
Reference in New Issue
Block a user