Showing
4 changed files
with
35 additions
and
13 deletions
| ... | @@ -29,6 +29,9 @@ | ... | @@ -29,6 +29,9 @@ |
| 29 | "sass": "1.55.0", | 29 | "sass": "1.55.0", |
| 30 | "sitemap": "^8.0.0", | 30 | "sitemap": "^8.0.0", |
| 31 | "swiper": "5", | 31 | "swiper": "5", |
| 32 | + "vite-plugin-html": "^3.2.2", | ||
| 33 | + "vite-plugin-pages": "^0.32.3", | ||
| 34 | + "vite-plugin-pages-sitemap": "^1.7.1", | ||
| 32 | "vite-plugin-sitemap": "^0.7.1", | 35 | "vite-plugin-sitemap": "^0.7.1", |
| 33 | "vue": "2.7.13", | 36 | "vue": "2.7.13", |
| 34 | "vue-awesome-swiper": "4.1.1", | 37 | "vue-awesome-swiper": "4.1.1", | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-26 13:36:06 | 2 | * @Date: 2024-09-26 13:36:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-11-04 13:11:08 | 4 | + * @LastEditTime: 2024-11-04 14:02:06 |
| 5 | * @FilePath: /hager/src/App.vue | 5 | * @FilePath: /hager/src/App.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -26,7 +26,7 @@ export default { | ... | @@ -26,7 +26,7 @@ export default { |
| 26 | title: '海格电气官方网站', | 26 | title: '海格电气官方网站', |
| 27 | meta: [ | 27 | meta: [ |
| 28 | { name: 'keyword', content: '海格集团是全球领先的电气及智能化解决方案和服务提供商,应用领域涵盖住宅、商业建筑、公共建筑和工业。海格电气品牌代表了集团的核心业务,覆盖配电系统、电缆管理系统,KNX 智能控制系统和开关面板、楼宇自动化和安防系统。' }, | 28 | { name: 'keyword', content: '海格集团是全球领先的电气及智能化解决方案和服务提供商,应用领域涵盖住宅、商业建筑、公共建筑和工业。海格电气品牌代表了集团的核心业务,覆盖配电系统、电缆管理系统,KNX 智能控制系统和开关面板、楼宇自动化和安防系统。' }, |
| 29 | - { name: 'description', content: '构建未来电气世界 让人们的生活更安全、更清洁、更愉悦' }, | 29 | + { name: 'description', content: '构建未来电气世界 让人们的生活更安全、更清洁、更愉悦。' }, |
| 30 | ] | 30 | ] |
| 31 | }, | 31 | }, |
| 32 | components: { hagerHeader, hagerFooter }, | 32 | components: { hagerHeader, hagerFooter }, | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2024-08-26 10:12:56 | 2 | * @Date: 2024-08-26 10:12:56 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-11-04 12:49:23 | 4 | + * @LastEditTime: 2024-11-04 14:56:26 |
| 5 | * @FilePath: /hager/vite.config.js | 5 | * @FilePath: /hager/vite.config.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -15,6 +15,7 @@ import Components from 'unplugin-vue-components/vite'; | ... | @@ -15,6 +15,7 @@ import Components from 'unplugin-vue-components/vite'; |
| 15 | import { ElementUiResolver } from 'unplugin-vue-components/resolvers'; | 15 | import { ElementUiResolver } from 'unplugin-vue-components/resolvers'; |
| 16 | import commonjs from 'vite-plugin-commonjs'; | 16 | import commonjs from 'vite-plugin-commonjs'; |
| 17 | import sitemap from 'vite-plugin-sitemap'; // 生成网站的站点地图,以便搜索引擎可以更容易地抓取网站上的页面 | 17 | import sitemap from 'vite-plugin-sitemap'; // 生成网站的站点地图,以便搜索引擎可以更容易地抓取网站上的页面 |
| 18 | +import { createHtmlPlugin } from 'vite-plugin-html'; | ||
| 18 | 19 | ||
| 19 | // var path = require('path'); | 20 | // var path = require('path'); |
| 20 | import path from 'path-browserify'; | 21 | import path from 'path-browserify'; |
| ... | @@ -89,16 +90,34 @@ return defineConfig({ | ... | @@ -89,16 +90,34 @@ return defineConfig({ |
| 89 | priority: 0.7, | 90 | priority: 0.7, |
| 90 | ignore: ['**/*.json', '**/*.md'], | 91 | ignore: ['**/*.json', '**/*.md'], |
| 91 | dynamicRoutes, | 92 | dynamicRoutes, |
| 92 | - routes: [ | 93 | + generateRobotsTxt: false, // 禁用 robots.txt 生成 |
| 93 | - '/', | 94 | + readable: true, |
| 94 | - '/product/index', | 95 | + }), |
| 95 | - '/product/detail', | 96 | + createHtmlPlugin({ |
| 96 | - '/solution/index', | 97 | + minify: false, |
| 97 | - '/solution/detail', | 98 | + inject: { |
| 98 | - '/solution/case', | 99 | + data: { |
| 99 | - '/about', | 100 | + sitemapUrl: '/f/hager/sitemap.xml' |
| 100 | - ], | 101 | + }, |
| 101 | - generateRobotsTxt: false // 禁用 robots.txt 生成 | 102 | + tags: [ |
| 103 | + { | ||
| 104 | + tag: 'link', | ||
| 105 | + attrs: { | ||
| 106 | + rel: 'sitemap', | ||
| 107 | + type: 'application/xml', | ||
| 108 | + title: 'Sitemap', | ||
| 109 | + href: '/f/hager/sitemap.xml' | ||
| 110 | + } | ||
| 111 | + } | ||
| 112 | + ] | ||
| 113 | + }, | ||
| 114 | + // 只修改特定的标签,不覆盖其他插件的插入 | ||
| 115 | + transformIndexHtml: (html, ctx) => { | ||
| 116 | + return html.replace( | ||
| 117 | + /<link rel="sitemap" type="application\/xml" title="Sitemap" href="\/sitemap\.xml">/, | ||
| 118 | + `<link rel="sitemap" type="application/xml" title="Sitemap" href="${ctx.data.sitemapUrl}">` | ||
| 119 | + ); | ||
| 120 | + } | ||
| 102 | }) | 121 | }) |
| 103 | ], | 122 | ], |
| 104 | publicDir: 'public', // 作为静态资源服务的文件夹。这个目录中的文件会在开发中被服务于 /,在开发模式时,会被拷贝到 outDir 的根目录,并没有转换,永远只是复制到这里。该值可以是文件系统的绝对路径,也可以是相对于项目的根目录路径。 | 123 | publicDir: 'public', // 作为静态资源服务的文件夹。这个目录中的文件会在开发中被服务于 /,在开发模式时,会被拷贝到 outDir 的根目录,并没有转换,永远只是复制到这里。该值可以是文件系统的绝对路径,也可以是相对于项目的根目录路径。 | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment