chore: 移动端基本适配完成
This commit is contained in:
34
src/main.js
34
src/main.js
@@ -4,41 +4,11 @@ import App from './App.vue'
|
||||
import router from './router'
|
||||
import { getBackgroundConfig } from './services/configService'
|
||||
|
||||
// 设置页面背景
|
||||
const setupBackground = async () => {
|
||||
try {
|
||||
const backgroundConfig = await getBackgroundConfig();
|
||||
|
||||
// 如果配置了使用背景图片
|
||||
if (backgroundConfig.useBackgroundImage && backgroundConfig.backgroundImage) {
|
||||
document.body.style.backgroundImage = `url(${backgroundConfig.backgroundImage})`;
|
||||
document.body.style.backgroundSize = backgroundConfig.backgroundSize || 'cover';
|
||||
document.body.style.backgroundPosition = backgroundConfig.backgroundPosition || 'center';
|
||||
document.body.style.backgroundRepeat = 'no-repeat';
|
||||
document.body.style.backgroundAttachment = 'fixed';
|
||||
} else if (backgroundConfig.backgroundColor) {
|
||||
// 使用纯色背景
|
||||
document.body.style.backgroundColor = backgroundConfig.backgroundColor;
|
||||
document.body.style.backgroundImage = 'none';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('设置背景失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 设置默认背景(立即应用)
|
||||
document.body.style.backgroundImage = 'url(/battle-background.jpg)';
|
||||
document.body.style.backgroundSize = 'contain';
|
||||
document.body.style.backgroundPosition = 'center';
|
||||
document.body.style.backgroundRepeat = 'no-repeat';
|
||||
document.body.style.backgroundAttachment = 'fixed';
|
||||
// 背景设置已移至样式表 style.css 中定义
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
// 使用路由
|
||||
app.use(router)
|
||||
|
||||
// 挂载应用前设置背景
|
||||
setupBackground().then(() => {
|
||||
app.mount('#app');
|
||||
});
|
||||
app.mount('#app');
|
||||
|
||||
Reference in New Issue
Block a user