188 lines
4.2 KiB
Vue
Raw Normal View History

2025-08-10 23:09:36 +08:00
<script setup lang="ts">
2025-08-28 03:26:25 +08:00
import { onMounted, computed } from 'vue'
import { RouterView, useRoute } from 'vue-router'
2025-08-10 23:09:36 +08:00
import { useUserStore } from '@/stores/user'
import AppLayout from '@/components/layout/AppLayout.vue'
import { NConfigProvider, NMessageProvider, NDialogProvider, zhCN, dateZhCN, enUS, dateEnUS } from 'naive-ui'
import type { GlobalThemeOverrides } from 'naive-ui';
import { useI18n } from 'vue-i18n'
const { locale } = useI18n()
// 响应式获取naive-ui语言包
const naiveLocale = computed(() => locale.value === 'en' ? enUS : zhCN)
const naiveDateLocale = computed(() => locale.value === 'en' ? dateEnUS : dateZhCN)
// 自定义naive-ui主题颜色
const themeOverrides: GlobalThemeOverrides = {
common: {
primaryColor: '#0288D1',
primaryColorHover: '#0277BD', // A slightly darker shade for hover
primaryColorPressed: '#01579B', // A darker shade for pressed
errorColor: '#FF4D4F',
errorColorHover: '#E54547',
errorColorPressed: '#C0383A',
},
Button: {
// For ghost primary buttons
textColorGhostPrimary: '#0288D1',
borderPrimary: '1px solid #0288D1',
// For ghost error buttons
textColorGhostError: '#FF4D4F',
borderError: '1px solid #FF4D4F',
},
Tag: {
colorPrimary: '#0288D1',
colorPrimaryHover: '#0277BD',
colorPrimaryPressed: '#01579B',
textColorPrimary: '#ffffff',
},
Card: {
borderColor: '#E6E6E6',
},
Input: {
borderHover: '#0288D1',
borderFocus: '#0288D1',
boxShadowFocus: '0 0 0 1px rgba(2, 136, 209, 0.5)',
},
InputNumber: {
borderHover: '#0288D1',
borderFocus: '#0288D1',
boxShadowFocus: '0 0 0 1px rgba(2, 136, 209, 0.5)',
},
Select: {
borderHover: '#0288D1',
borderFocus: '#0288D1',
boxShadowFocus: '0 0 0 1px rgba(2, 136, 209, 0.5)',
},
Modal: {
borderRadius: '8px',
},
Dialog: {
borderRadius: '8px',
}
};
2025-08-10 23:09:36 +08:00
const userStore = useUserStore()
2025-08-28 03:26:25 +08:00
const route = useRoute()
// 检查是否为登录页面
const isLoginPage = computed(() => route.name === 'Login')
2025-08-10 23:09:36 +08:00
onMounted(() => {
// 初始化用户认证状态
userStore.initializeAuth()
})
</script>
<template>
<div id="app">
<n-config-provider :theme-overrides="themeOverrides" :locale="naiveLocale" :date-locale="naiveDateLocale">
<n-dialog-provider>
<!-- 登录页面不使用 AppLayout但需要 message provider -->
<template v-if="isLoginPage">
<n-message-provider>
<RouterView />
</n-message-provider>
</template>
<!-- 其他页面使用 AppLayout -->
<template v-else>
<AppLayout>
<RouterView />
</AppLayout>
</template>
</n-dialog-provider>
</n-config-provider>
2025-08-10 23:09:36 +08:00
</div>
</template>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* 确保在所有缩放级别下都能正常显示 */
html {
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
text-size-adjust: 100%;
zoom: 1;
}
/* 移除全屏相关样式,使用正常布局 */
html, body {
height: 100vh;
width: 100vw;
margin: 0;
padding: 0;
overflow-x: hidden;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
line-height: 1.6;
color: #333;
background-color: #f5f5f5;
}
#app {
min-height: 100vh;
width: 100vw;
display: block;
position: relative;
}
/* 确保导航栏和横幅可见 */
.header {
display: flex !important;
visibility: visible !important;
opacity: 1 !important;
position: relative !important;
z-index: 1000 !important;
}
.hero-banner {
display: flex !important;
visibility: visible !important;
opacity: 1 !important;
position: relative !important;
z-index: 1 !important;
}
/* 响应式容器 */
.container {
width: 100%;
margin: 0 auto;
}
/* 工具类 */
.text-center {
text-align: center;
}
.mb-4 {
margin-bottom: 1rem;
}
.mt-4 {
margin-top: 1rem;
}
.p-4 {
padding: 1rem;
}
/* 响应式显示工具类 */
.d-none {
display: none !important;
}
.d-block {
display: block !important;
}
</style>