nuxt.config.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import AutoImport from 'unplugin-auto-import/vite'
  2. import Components from 'unplugin-vue-components/vite'
  3. import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
  4. import path from 'path'
  5. // https://nuxt.com/docs/api/configuration/nuxt-config
  6. export default defineNuxtConfig({
  7. ssr: true,
  8. app: {
  9. head: {
  10. title: '百谏方略',//网站地址栏位置的标题
  11. meta: [
  12. { charset: 'utf-8' },
  13. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  14. { name: 'format-detection', content: 'telephone=yes' },//添加移动端调用手机拨号功能
  15. { name: 'viewport', content: 'width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0' }
  16. ],
  17. link: [
  18. // { rel: "resource", type: "application/110n", href: "/_nuxt/viewer.properties" }
  19. ],
  20. // <script type="text/javascript" src="/static/js/wow.js"></script>
  21. script: [
  22. // { type: 'text/javascript', src: "https://webapi.amap.com/maps?v=2.0&key=4784a307149172798267bd43856ba7b9" },
  23. // { type: 'text/javascript', src: "wow.js" },
  24. ]
  25. },
  26. },
  27. nitro: {
  28. // 代理
  29. devProxy: {
  30. '/api': {
  31. target: 'https://www.dirmarketresearch.com/api',
  32. // target: 'http://192.168.0.70:8980/js/a/api',
  33. // target: 'http://192.168.0.132//js/a/api',
  34. changeOrigin: true,
  35. prependPath: true,
  36. secure: false,
  37. },
  38. },
  39. },
  40. runtimeConfig: {
  41. // apiSecret 只能在服务器端上访问
  42. // apiSecret: '123',
  43. // public 命名空间中定义的,在服务器端和客户端都可以普遍访问
  44. public: {
  45. apiBase: process.env.NUXT_PUBLIC_API_BASE,
  46. baseUrl: process.env.NUXT_PUBLIC_API_BASEURL
  47. }
  48. },
  49. devtools: { enabled: true },
  50. devServer: {
  51. host: "0.0.0.0"
  52. },
  53. plugins: [
  54. { src: './public/wow.js', mode: 'client' },
  55. // { src: './public/myWow.js', mode: 'client' },
  56. '~/plugins/pinia.js',
  57. ],
  58. css: [
  59. '@/assets/css/root.scss',
  60. // 直接加载一个 Node.js 模块。(在这里它是一个 Sass 文件)
  61. // 'bulma',
  62. // 项目里要使用的 SCSS 文件
  63. '@/assets/css/common.scss',
  64. // 'animate.css',
  65. // '@/assets/styles/animate.css',
  66. 'github-markdown-css/github-markdown.css'
  67. ],
  68. modules: ["nuxtjs-naive-ui", '@nuxtjs/i18n', '@pinia/nuxt'],
  69. i18n: {
  70. locales: ['en', 'zh'],
  71. defaultLocale: 'en',
  72. vueI18n: './lang/i18n.ts',
  73. customRoutes: 'config',
  74. // parsePages: false,
  75. strategy: 'prefix_except_default',
  76. detectBrowserLanguage: false, // 禁用浏览器检测
  77. pages: {
  78. // 'news/index': {
  79. // en: '/en/news-categories/:activeIndustryType?/:keyword?',
  80. // zh: '/news-categories/:activeIndustryType?/:keyword?'
  81. // },
  82. 'report-industries/detail': {
  83. zh: '/reports/[webTitle]',
  84. en: '/reports/[webTitle]'
  85. },
  86. 'news-categories/detail': {
  87. zh: '/news/[webTitle]',
  88. en: '/news/[webTitle]'
  89. },
  90. 'contact/index': {
  91. zh: '/contactUs',
  92. en: '/contactUs'
  93. }
  94. }
  95. },
  96. vite: {
  97. plugins: [
  98. AutoImport({
  99. imports: [
  100. {
  101. 'naive-ui': [
  102. 'NCarousel',
  103. ]
  104. }
  105. ]
  106. }),
  107. Components({
  108. resolvers: [NaiveUiResolver()]
  109. })
  110. ],
  111. },
  112. build: {
  113. transpile:
  114. process.env.NODE_ENV === 'production'
  115. ? [
  116. 'naive-ui',
  117. 'vueuc',
  118. '@css-render/vue3-ssr',
  119. '@juggle/resize-observer'
  120. ]
  121. : ['@juggle/resize-observer'],
  122. },
  123. compatibilityDate: '2025-02-20'
  124. })