選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

135 行
5.6 KiB

  1. import { fileURLToPath } from 'node:url'
  2. // https://nuxt.com/docs/api/configuration/nuxt-config
  3. export default defineNuxtConfig({
  4. compatibilityDate: '2025-07-15',
  5. devtools: { enabled: true },
  6. devServer: { port: 6888, host: '0.0.0.0' },
  7. modules: ['@nuxt/ui'],
  8. css: ['~/assets/css/main.css'],
  9. /**
  10. * 暗色模式:@nuxtjs/color-mode 由 @nuxt/ui 自带(classSuffix 已被置空,即 <html class="dark">)。
  11. * 默认保持亮色,不跟随系统;用户在页头手动切换后写入 cookie 持久化。
  12. */
  13. colorMode: {
  14. preference: 'light',
  15. fallback: 'light',
  16. classSuffix: '',
  17. storage: 'cookie',
  18. storageKey: 'ai-color-mode',
  19. },
  20. // 禁用 @nuxt/fonts 远程字体提供商(内网环境无法访问 Google Fonts)
  21. ui: {
  22. fonts: false,
  23. },
  24. // 运行时公开配置(客户端可访问)
  25. runtimeConfig: {
  26. public: {
  27. // ThinkJS ai_api 地址,按环境覆盖
  28. apiBase: process.env.API_BASE || 'http://192.168.31.168:16888',
  29. // 邀请链接正式域名;未配置时自动使用当前访问域名。
  30. siteUrl: process.env.NUXT_PUBLIC_SITE_URL || '',
  31. },
  32. },
  33. // SSR / SEO
  34. ssr: true,
  35. /**
  36. * 兼容原 PC 站的自定义路由(SEO 不断链)
  37. * 原站分页形式:/info2、/info/new2、/info/course2、/info/what2。
  38. * 已迁移工具继续以旧站已收录路径作为主入口。
  39. */
  40. hooks: {
  41. 'pages:extend'(pages) {
  42. /*
  43. Windows 下长时间运行的 dev 进程偶尔会漏掉新增页面文件的 add 事件,
  44. 表现为:SSR 已命中页面并吐出内容,客户端水合后 vue-router 匹配不到而进入 404。
  45. 这里对所有新增页面显式兜底;已被自动扫描到的路径会跳过,不会重复注册。
  46. 新增 app/pages 下的页面时,记得同步加到这个清单里。
  47. */
  48. const fallbackPages = [
  49. { name: 'invite', path: '/invite', file: './app/pages/invite/index.vue' },
  50. { name: 'invite-landing', path: '/invite/landing', file: './app/pages/invite/landing.vue' },
  51. { name: 'invite-records', path: '/invite/records', file: './app/pages/invite/records.vue' },
  52. { name: 'terms', path: '/terms', file: './app/pages/terms.vue' },
  53. { name: 'privacy', path: '/privacy', file: './app/pages/privacy.vue' },
  54. { name: 'earn-points', path: '/earn-points', file: './app/pages/earn-points.vue' },
  55. { name: 'portrait-photo', path: '/portrait-photo', file: './app/pages/portrait-photo.vue' },
  56. { name: 'old-photo', path: '/old-photo', file: './app/pages/old-photo.vue' },
  57. { name: 'id-photo', path: '/id-photo', file: './app/pages/id-photo.vue' },
  58. { name: 'recharge', path: '/recharge', file: './app/pages/recharge.vue' },
  59. { name: 'bill', path: '/bill', file: './app/pages/bill.vue' },
  60. { name: 'works', path: '/works', file: './app/pages/works.vue' },
  61. ]
  62. for (const page of fallbackPages) {
  63. if (pages.some(item => item.path === page.path)) continue
  64. pages.push({
  65. ...page,
  66. file: fileURLToPath(new URL(page.file, import.meta.url)),
  67. })
  68. }
  69. // 复用已有页面组件,追加原站的分页路径(/info2 = 第 2 页)
  70. const legacy = [
  71. { base: '/info', name: 'legacy-info-page' },
  72. { base: '/info/new', name: 'legacy-info-new-page' },
  73. { base: '/info/course', name: 'legacy-info-course-page' },
  74. { base: '/info/what', name: 'legacy-info-what-page' },
  75. ]
  76. for (const item of legacy) {
  77. const origin = pages.find(p => p.path === item.base)
  78. if (!origin) continue
  79. pages.push({
  80. name: item.name,
  81. path: `${item.base}:page(\\d+)`,
  82. file: origin.file,
  83. children: [],
  84. })
  85. pages.push({
  86. name: `${item.name}-html`,
  87. path: `${item.base}:page(\\d+).html`,
  88. file: origin.file,
  89. children: [],
  90. })
  91. }
  92. },
  93. },
  94. // 旧 ThinkJS 自动 controller 地址及重构早期地址统一 301 到已收录主路径。
  95. routeRules: {
  96. '/ai-name': { redirect: { to: '/writing/naming/', statusCode: 301 } },
  97. '/anime-avatar': { redirect: { to: '/draw/anime/', statusCode: 301 } },
  98. '/writing/naming.html': { redirect: { to: '/writing/naming/', statusCode: 301 } },
  99. '/draw/anime.html': { redirect: { to: '/draw/anime/', statusCode: 301 } },
  100. '/index.html': { redirect: { to: '/', statusCode: 301 } },
  101. '/anime/index.html': { redirect: { to: '/draw/anime/', statusCode: 301 } },
  102. '/pic/index.html': { redirect: { to: '/pic/', statusCode: 301 } },
  103. '/news/index.html': { redirect: { to: '/info', statusCode: 301 } },
  104. '/news/list.html': { redirect: { to: '/info/new', statusCode: 301 } },
  105. '/news/course.html': { redirect: { to: '/info/course', statusCode: 301 } },
  106. '/news/ask.html': { redirect: { to: '/info/what', statusCode: 301 } },
  107. '/my/invite.html': { redirect: { to: '/invite', statusCode: 301 } },
  108. },
  109. app: {
  110. head: {
  111. titleTemplate: '%s',
  112. title: 'AI在线网站-你的AI伙伴让创作更简单',
  113. meta: [
  114. { charset: 'utf-8' },
  115. { name: 'viewport', content: 'width=device-width, initial-scale=1' },
  116. { name: 'description', content: 'AI在线是一个 AI 工具的集合地,可以找到各种各样的 AI 工具,满足你的不同需求。无论你是想翻译一段文字,还是想生成一篇文章,或者是想制作一张图片,AI在线都能为你提供帮助, AI 工具大全宝库!' },
  117. { name: 'keywords', content: 'AI,AI在线,AI伙伴,免费AI网站' },
  118. ],
  119. link: [{ rel: 'icon', type: 'image/png', href: '/logo.png' }],
  120. },
  121. },
  122. })