Showing
5 changed files
with
16 additions
and
27 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-26 13:42:11 | 2 | * @Date: 2024-09-26 13:42:11 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-12-12 13:39:46 | 4 | + * @LastEditTime: 2024-12-12 14:53:44 |
| 5 | * @FilePath: /hager/src/components/common/hagerHeader.vue | 5 | * @FilePath: /hager/src/components/common/hagerHeader.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -185,7 +185,7 @@ export default { | ... | @@ -185,7 +185,7 @@ export default { |
| 185 | }, | 185 | }, |
| 186 | watch: { | 186 | watch: { |
| 187 | // 监听路由参数变化时,更新输入框的值 | 187 | // 监听路由参数变化时,更新输入框的值 |
| 188 | - '$route.query.keyword': function(newKeyword) { | 188 | + '$route.params.keyword': function(newKeyword) { |
| 189 | this.keyword = newKeyword || ''; | 189 | this.keyword = newKeyword || ''; |
| 190 | }, | 190 | }, |
| 191 | '$route' (to, from) { | 191 | '$route' (to, from) { |
| ... | @@ -421,18 +421,14 @@ export default { | ... | @@ -421,18 +421,14 @@ export default { |
| 421 | } | 421 | } |
| 422 | }, | 422 | }, |
| 423 | updateURL() { | 423 | updateURL() { |
| 424 | - const currentKeyword = this.$route.query.keyword; | 424 | + const currentKeyword = this.$route.params.keyword; |
| 425 | 425 | ||
| 426 | // 如果输入的 keyword 和当前路由的 keyword 相同,不做更新 | 426 | // 如果输入的 keyword 和当前路由的 keyword 相同,不做更新 |
| 427 | if (this.keyword === currentKeyword) return; | 427 | if (this.keyword === currentKeyword) return; |
| 428 | 428 | ||
| 429 | // 使用 Vue Router 动态更新 URL 中的 keyword 参数 | 429 | // 使用 Vue Router 动态更新 URL 中的 keyword 参数 |
| 430 | this.$router.replace({ | 430 | this.$router.replace({ |
| 431 | - path: '/search', // 确保路径不变 | 431 | + path: `/search/${this.keyword}` |
| 432 | - query: { | ||
| 433 | - ...this.$route.query, // 保留其他可能存在的 query 参数 | ||
| 434 | - keyword: this.keyword // 更新 keyword 参数 | ||
| 435 | - } | ||
| 436 | }); | 432 | }); |
| 437 | } | 433 | } |
| 438 | } | 434 | } | ... | ... |
| 1 | /* | 1 | /* |
| 2 | * @Date: 2024-08-26 10:42:15 | 2 | * @Date: 2024-08-26 10:42:15 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-12-12 14:03:26 | 4 | + * @LastEditTime: 2024-12-12 14:54:14 |
| 5 | * @FilePath: /hager/src/route.js | 5 | * @FilePath: /hager/src/route.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -78,7 +78,7 @@ export default [{ | ... | @@ -78,7 +78,7 @@ export default [{ |
| 78 | }, | 78 | }, |
| 79 | children: [] | 79 | children: [] |
| 80 | }, { | 80 | }, { |
| 81 | - path: '/solution/case', | 81 | + path: '/solution/case/:id/:current_index?', |
| 82 | name: '成功案例', | 82 | name: '成功案例', |
| 83 | component: () => import('@/views/solution/case'), | 83 | component: () => import('@/views/solution/case'), |
| 84 | meta: { | 84 | meta: { |
| ... | @@ -232,7 +232,7 @@ export default [{ | ... | @@ -232,7 +232,7 @@ export default [{ |
| 232 | }, | 232 | }, |
| 233 | ] | 233 | ] |
| 234 | }, { | 234 | }, { |
| 235 | - path: '/search', | 235 | + path: '/search/:keyword?', |
| 236 | name: '搜索结果', | 236 | name: '搜索结果', |
| 237 | component: () => import('@/views/search'), | 237 | component: () => import('@/views/search'), |
| 238 | meta: { | 238 | meta: { | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-10-20 16:57:48 | 2 | * @Date: 2024-10-20 16:57:48 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-12-12 14:14:55 | 4 | + * @LastEditTime: 2024-12-12 14:54:04 |
| 5 | * @FilePath: /hager/src/views/search.vue | 5 | * @FilePath: /hager/src/views/search.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -92,7 +92,7 @@ export default { | ... | @@ -92,7 +92,7 @@ export default { |
| 92 | data () { | 92 | data () { |
| 93 | return { | 93 | return { |
| 94 | activeName: 'product', | 94 | activeName: 'product', |
| 95 | - keyword: this.$route.query.keyword, | 95 | + keyword: this.$route.params.keyword, |
| 96 | news_list: [], | 96 | news_list: [], |
| 97 | case_list: [], | 97 | case_list: [], |
| 98 | count_news: 0, | 98 | count_news: 0, |
| ... | @@ -110,7 +110,7 @@ export default { | ... | @@ -110,7 +110,7 @@ export default { |
| 110 | } | 110 | } |
| 111 | }, | 111 | }, |
| 112 | watch: { | 112 | watch: { |
| 113 | - '$route.query.keyword': function(newKeyword, oldKeyword) { | 113 | + '$route.params.keyword': function(newKeyword, oldKeyword) { |
| 114 | this.keyword = newKeyword || ''; | 114 | this.keyword = newKeyword || ''; |
| 115 | if (newKeyword !== oldKeyword) { // 关键词变化时,重新搜索 | 115 | if (newKeyword !== oldKeyword) { // 关键词变化时,重新搜索 |
| 116 | this.activeName = 'product'; | 116 | this.activeName = 'product'; |
| ... | @@ -258,10 +258,7 @@ export default { | ... | @@ -258,10 +258,7 @@ export default { |
| 258 | }, | 258 | }, |
| 259 | goToSuccess (v) { // 跳转成功案例 | 259 | goToSuccess (v) { // 跳转成功案例 |
| 260 | this.$router.push({ | 260 | this.$router.push({ |
| 261 | - path: '/solution/case', | 261 | + path: `/solution/case/${v}}`, |
| 262 | - query: { | ||
| 263 | - id: v | ||
| 264 | - } | ||
| 265 | }); | 262 | }); |
| 266 | } | 263 | } |
| 267 | } | 264 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-10-18 12:06:09 | 2 | * @Date: 2024-10-18 12:06:09 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-12-09 13:41:51 | 4 | + * @LastEditTime: 2024-12-12 14:26:37 |
| 5 | * @FilePath: /hager/src/views/solution/case.vue | 5 | * @FilePath: /hager/src/views/solution/case.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -157,7 +157,7 @@ export default { | ... | @@ -157,7 +157,7 @@ export default { |
| 157 | }, | 157 | }, |
| 158 | computed: { | 158 | computed: { |
| 159 | casePath () { | 159 | casePath () { |
| 160 | - return `/solution/detail/${this.success_info.category_id}/${this.$route.query.current_index}/${Date.now()}`; | 160 | + return `/solution/detail/${this.success_info.category_id}/${this.$route.params.current_index}/${Date.now()}`; |
| 161 | } | 161 | } |
| 162 | }, | 162 | }, |
| 163 | watch: { | 163 | watch: { |
| ... | @@ -166,7 +166,7 @@ export default { | ... | @@ -166,7 +166,7 @@ export default { |
| 166 | } | 166 | } |
| 167 | }, | 167 | }, |
| 168 | async mounted () { | 168 | async mounted () { |
| 169 | - const { code, data } = await getSolutionDetailAPI({ id: this.$route.query.id }); | 169 | + const { code, data } = await getSolutionDetailAPI({ id: this.$route.params.id }); |
| 170 | if (code) { | 170 | if (code) { |
| 171 | this.success_info = data; | 171 | this.success_info = data; |
| 172 | this.top_banner = this.success_info.file?.top_img ? this.success_info.file?.top_img[0]['value'] : ''; | 172 | this.top_banner = this.success_info.file?.top_img ? this.success_info.file?.top_img[0]['value'] : ''; | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-09-29 15:49:27 | 2 | * @Date: 2024-09-29 15:49:27 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-12-12 14:21:31 | 4 | + * @LastEditTime: 2024-12-12 14:34:05 |
| 5 | * @FilePath: /hager/src/views/solution/detail.vue | 5 | * @FilePath: /hager/src/views/solution/detail.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -255,11 +255,7 @@ export default { | ... | @@ -255,11 +255,7 @@ export default { |
| 255 | }, | 255 | }, |
| 256 | goToCase (v) { | 256 | goToCase (v) { |
| 257 | this.$router.push({ | 257 | this.$router.push({ |
| 258 | - path: '/solution/case', | 258 | + path: `/solution/case/${v.id}/${this.current_index}`, |
| 259 | - query: { | ||
| 260 | - id: v.id, | ||
| 261 | - current_index: this.current_index | ||
| 262 | - } | ||
| 263 | }); | 259 | }); |
| 264 | }, | 260 | }, |
| 265 | prevProductBtn () { | 261 | prevProductBtn () { | ... | ... |
-
Please register or login to post a comment