113 lines
4.6 KiB
JavaScript
113 lines
4.6 KiB
JavaScript
export default {
|
||
/**
|
||
*
|
||
ssr: true + target: 'server' → SSR
|
||
ssr: true + target: 'static' → 静态生成(SSG)
|
||
ssr: false → SPA 模式
|
||
*/
|
||
ssr: true,
|
||
target: 'server',
|
||
|
||
// publicPath: process.env.NUXT_ENV_PUBLIC_PATH || '/', //服务器资源路径是否有前缀
|
||
|
||
loading: false, //是否在路由切换或者asyncData/Fetch异步请求期间出现进度条 ,可自定义,详情见:https://v2.nuxt.com/docs/features/loading#loading
|
||
|
||
// Global page headers: https://go.nuxtjs.dev/config-head
|
||
//全局配置项,设置一些基础不会变动的东西
|
||
head: {
|
||
title: 'AIProdLaunch', //设置标签页名字
|
||
htmlAttrs: {
|
||
lang: 'zh-CN' //设置语言为中文 英文:en
|
||
},
|
||
meta: [
|
||
{ charset: 'utf-8' }, //字符集
|
||
{ name: 'viewport', content: 'width=device-width, initial-scale=1' }, //完美视口
|
||
{ hid: 'description', name: 'description', content: '网站的默认描述' }, //设置描述
|
||
{ hid: 'keywords', name: 'keywords', content: 'default' }, //设置关键词
|
||
{ name: 'format-detection', content: 'telephone=no' },
|
||
{ property: 'og:type', content: 'website' }, // 分享在平台时告诉平台这是网站类型的页面
|
||
{ property: 'og:site_name', content: '我的网站' }, //分享在平台时告诉平台这个页面属于哪个网站
|
||
{ property: 'og:image', content: 'https://www.example.com/logo.png' } //定义网页在分享时的描述信息
|
||
],
|
||
link: [
|
||
{ rel: 'icon', type: 'image/x-icon', href: '/logo.png' }
|
||
]
|
||
},
|
||
|
||
// 设置页面级或者layouts的head,供参考
|
||
// head() {
|
||
// return {
|
||
// title: '关于我们',
|
||
// meta: [
|
||
// { hid: 'description', name: 'description', content: '默认描述' },
|
||
// { hid: 'keywords', name: 'keywords', content: 'example' },
|
||
// { property: 'og:title', content: '关于我们 - 我的网站' }, //定义网页在分享时的标题
|
||
// { property: 'og:description', content: '这是关于我们的详细信息' } //定义网页在分享时的描述信息
|
||
// ]
|
||
// }
|
||
// }
|
||
|
||
// Global CSS: https://go.nuxtjs.dev/config-css
|
||
css: [
|
||
'normalize.css/normalize.css', // 引入
|
||
'@/styles/index.scss', //引入全局样式
|
||
'@/styles/text.scss'
|
||
],
|
||
|
||
// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
|
||
plugins: [
|
||
'@/plugins/router.js', //给路由进行全局路由配置
|
||
'@/plugins/axios.js', //设置请求和拦截响应器
|
||
'@/plugins/api.js', //将api注入到全局
|
||
'@/plugins/element.js',
|
||
'@/plugins/global-function.js',
|
||
],
|
||
|
||
// Auto import components: https://go.nuxtjs.dev/config-components
|
||
components: true,
|
||
|
||
// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
|
||
buildModules: [
|
||
'@nuxtjs/style-resources' //导入样式引入模块
|
||
],
|
||
|
||
styleResources: {
|
||
scss: [
|
||
'@/styles/variables.scss', //全局变量 、全局混入 、全局函数等放这里全局引入
|
||
'@/styles/mixins.scss'
|
||
]
|
||
},
|
||
|
||
// Modules: https://go.nuxtjs.dev/config-modules
|
||
modules: [
|
||
'@nuxtjs/router', //导入路由模块,不使用默认的路由,使用自己写的路由,路由写在router.js里面
|
||
'cookie-universal-nuxt', //导入cookie模块,能够得到$cookie
|
||
'@nuxtjs/axios', //导入nuxtjs/axios模块,能够得到$axios
|
||
['@nuxtjs/dotenv', { filename: `.env.${process.env.NODE_ENV}` }], //导入模块,能够使之读取环境变量
|
||
],
|
||
|
||
routerModule: {
|
||
keepDefaultRouter: false //true:保留默认路由,和默认路由合并 false:不保留默认路由,完全使用router.js里面的路由
|
||
},
|
||
|
||
// Build Configuration: https://go.nuxtjs.dev/config-build
|
||
build: {
|
||
},
|
||
|
||
axios: {
|
||
baseURL: process.env.NUXT_ENV_BASE_API || 'https://api.example.com', // API 根地址
|
||
credentials: true, // 是否跨域请求时携带 cookie
|
||
timeout: 30000, // 请求超时时间(ms)
|
||
// proxy:true, //开启代理
|
||
},
|
||
|
||
//代理
|
||
// proxy: {
|
||
// '/api': { // 需要转发代理的请求前缀
|
||
// target: 'http://localhost:3000', // 代理的目标地址
|
||
// pathRewrite: { '^/api/': '' }, // 重写路径:去掉 /api 前缀
|
||
// changeOrigin: true // 是否改变请求源
|
||
// },
|
||
// }
|
||
}
|