### 优化与修复

1. 优化加载动画:调整加载动画的时长设置,以增强用户体验。由500毫秒调整至1000毫秒,确保页面完全加载后动画再消失。
2. 修复图片路径引用:在`model-coupon-setting`组件中,修正图片路径引用方式。使用`ref`来异步获取图片路径,并解决在`onBeforeMount`钩子中设置路径的问题。
3. 调整文件输出路径:在`vite.config.ts`中,修改文件的输出路径以优化资源管理。将`chunk`和`entryFileNames`的路径从`static/admin/default/diy`调整为`static/diy`,以适应最新的资源组织结构。
4. 重构布局模板:在`layout/index.vue`中,对布局模板进行重构,以提高代码的可读性和维护性。通过`loading_content`状态管理加载动画的显示与隐藏,更清晰地控制页面的渲染流程。

通过这些改进,系统性能和稳定性得到进一步提升,同时也优化了开发和维护的便利性。
v1.0.0
sws 2024-09-06 13:40:59 +08:00
parent e42a05140b
commit 4332aa1e32
3 changed files with 22 additions and 15 deletions

View File

@ -20,7 +20,7 @@ const props = defineProps({
default: () => {},
},
});
const new_url = await online_url('/static/plugins/coupon/images/diy/').then((res) => res);
const new_url = ref('');
const form = ref(props.value);
const default_config = {
style: {
@ -196,7 +196,7 @@ const default_config = {
background_img: [],
},
theme_2: {
background_img: [{ url: new_url + 'theme-2-bg.png' }],
background_img: [{ url: new_url.value + 'theme-2-bg.png' }],
},
},
};
@ -210,4 +210,7 @@ const change_theme = (val: string) => {
form.value.style = Object.assign({}, form.value.style, (<arrayIndex>default_config.style)[`theme_${Number(val)}`]);
}
};
onBeforeMount(async () => {
new_url.value = await online_url('/static/plugins/coupon/images/diy/').then((res) => res);
});
</script>

View File

@ -1,5 +1,6 @@
<template>
<div v-loading.fullscreen.lock="loading" class="app-wrapper no-copy" element-loading-background="rgba(255,255,255,1)" element-loading-custom-class="loading-custom">
<template v-if="!loading_content">
<template v-if="!is_empty">
<navbar v-model="form.model" @preview="preview" @save="save" @save-close="save_close" />
<div class="app-wrapper-content flex-row">
@ -10,6 +11,7 @@
<template v-else>
<no-data height="100vh" img-width="260px" size="16px" text="编辑数据有误"></no-data>
</template>
</template>
</div>
</template>
@ -135,11 +137,13 @@ const common_init = () => {
};
//
const loading = ref(true);
const loading_content = ref(true);
const loading_event = (count: number) => {
if (count == 2) {
loading_content.value = false;
setTimeout(() => {
loading.value = false;
}, 500);
}, 1000);
}
};
//#endregion ---------------------end

View File

@ -113,11 +113,11 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
rollupOptions: {
output: {
// 自定义 chunk 文件的输出路径和文件名格式
chunkFileNames: 'static/admin/default/diy/js/chunk/[name]-[hash].js',
chunkFileNames: 'static/diy/js/chunk/[name]-[hash].js',
// 自定义 entry chunk 的输出路径和文件名格式
entryFileNames: 'static/admin/default/diy/js/entry/[name]-[hash].js',
entryFileNames: 'static/diy/js/entry/[name]-[hash].js',
//非js文件夹按照文件类型分类css,png,jpg
assetFileNames: 'static/admin/default/diy/[ext]/[name]-[hash].[ext]',
assetFileNames: 'static/diy/[ext]/[name]-[hash].[ext]',
},
},
},