website-client-Nigeria/nuxt.config.ts

84 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export default defineNuxtConfig({
compatibilityDate: '2025-08-22',
devtools: { enabled: true },
srcDir: 'src',
alias: {
'@': '~/',
},
app: {
head: {
title: '明阳良光',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ name: 'description', content: '明阳良光' },
{ name: 'theme-color', content: '#4f8cef' }
],
link: [
{ rel: 'icon', href: '/favicon.ico' }
]
}
},
// 静态生成配置
nitro: {
preset: 'static'
},
// 预渲染配置
routeRules: {
'/': { prerender: true },
'/about-us': { prerender: true },
'/contact-us': { prerender: true },
'/product': { prerender: true },
'/product/detail': { prerender: true },
'/product/rich-detail': { prerender: true },
'/privacy-policy': { prerender: true },
'/thanks': { prerender: true },
// 中文路由预渲染(因为默认是英文,所以中文需要前缀)
'/cn': { prerender: true },
'/cn/about-us': { prerender: true },
'/cn/contact-us': { prerender: true },
'/cn/product': { prerender: true },
'/cn/product/detail': { prerender: true },
'/cn/product/rich-detail': { prerender: true },
'/cn/privacy-policy': { prerender: true },
'/cn/thanks': { prerender: true }
},
plugins: [
'~/plugins/vue-lazyload.js',
{ src: '~/plugins/aos-client.js', mode: 'client' },
'~/plugins/vue-dompurify-html.js',
'~/plugins/image-path.js',
{ src: '~/plugins/static-data.client.js', mode: 'client' },
{ src: '~/plugins/language-init.client.js', mode: 'client' }
],
devServer: {
port: 1100,
},
modules: ['@nuxtjs/i18n', '@pinia/nuxt'],
i18n: {
locales: [
{ code: 'en', name: 'English', file: 'en.json' },
{ code: 'cn', name: '简体中文', file: 'cn.json' }
],
defaultLocale: 'en',
detectBrowserLanguage: {
// 启用 Nuxt i18n 的自动检测
useCookie: true, // 使用 cookie 保存语言选择
cookieKey: 'i18n_redirected',
redirectOn: 'root', // 只在根路径时重定向
alwaysRedirect: true,
fallbackLocale: 'en'
},
strategy: 'prefix_except_default',
vueI18n: '~/i18n.config.ts',
langDir: 'locale', // 修正路径相对于src目录
debug: false // 关闭调试模式,减少控制台输出
},
// Axios配置
runtimeConfig: {
public: {
apiBaseUrl: process.env.API_BASE_URL || 'https://api.example.com'
}
}
})