Commit 1ece117e7217d093e69cdbd592e2055117e17fa5
1 parent
e9b7eff8
fix: 修改产品目录urlbug
Showing
2 changed files
with
14 additions
and
67 deletions
components/CategoryList.vue
@@ -88,6 +88,7 @@ const productStore = useProductListStore(); | @@ -88,6 +88,7 @@ const productStore = useProductListStore(); | ||
88 | watchEffect(async () => { | 88 | watchEffect(async () => { |
89 | if (route.query.categories) { | 89 | if (route.query.categories) { |
90 | // 1. 提取 query.category 的内容 | 90 | // 1. 提取 query.category 的内容 |
91 | + productStore.updateKeyword(""); | ||
91 | const categories = route.query.categories.split(","); | 92 | const categories = route.query.categories.split(","); |
92 | const mainCategory = categories[0].trim(); // 取第一个值 | 93 | const mainCategory = categories[0].trim(); // 取第一个值 |
93 | const subCategoryName = categories[1] ? categories[1].trim() : null; // 取第二个值(如果存在) | 94 | const subCategoryName = categories[1] ? categories[1].trim() : null; // 取第二个值(如果存在) |
@@ -152,74 +153,10 @@ watchEffect(async () => { | @@ -152,74 +153,10 @@ watchEffect(async () => { | ||
152 | // categoryStore.updateFuncCategory(funcCategoryId); | 153 | // categoryStore.updateFuncCategory(funcCategoryId); |
153 | // } | 154 | // } |
154 | } | 155 | } |
155 | - } | ||
156 | - // else { | ||
157 | - // console.log(route.query, "5656mountedquery222"); | ||
158 | - | ||
159 | - // // 检查是否有默认的分类 | ||
160 | - // const defaultCategory = categoryStore.list[0]; // 假设第一个分类是默认的 | ||
161 | - // console.log(categoryStore.list[0], "5656mountedquery333"); | ||
162 | - | ||
163 | - // if (defaultCategory) { | ||
164 | - // console.log(defaultCategory, "5656mountedquery444"); | ||
165 | - | ||
166 | - // const defaultCategoryName = defaultCategory.categoryDisplayName; | ||
167 | - // const defaultSubCategory = defaultCategory.list[0]; // 假设第一个子分类为默认子分类 | ||
168 | - // const defaultFuncCategory = defaultCategory.productFunctions[0]; // 假设第一个功能分类为默认功能分类 | ||
169 | - | ||
170 | - // // 更新 store 和 URL | ||
171 | - // categoryStore.updateCategory(defaultCategoryName); | ||
172 | - // productStore.updatePageNo(1); | ||
173 | - | ||
174 | - // if (defaultSubCategory) { | ||
175 | - // categoryStore.updateSubCategory(defaultSubCategory.id); | ||
176 | - | ||
177 | - // // 如果有之前的值则使用之前的值,拼接新的子分类名 | ||
178 | - // const updatedCategory = | ||
179 | - // defaultCategoryName + "," + defaultSubCategory.name; | ||
180 | - | ||
181 | - // // 拼接设备类型到 URL | ||
182 | - // router.push({ | ||
183 | - // query: { | ||
184 | - // category: defaultCategoryName + "," + defaultSubCategory.name, | ||
185 | - // }, | ||
186 | - // }); | ||
187 | - // } | ||
188 | - | ||
189 | - // if (defaultFuncCategory) { | ||
190 | - // categoryStore.updateFuncCategory(defaultFuncCategory.id); | ||
191 | - // // 拼接功能类型到 URL | ||
192 | - // router.push({ | ||
193 | - // query: { | ||
194 | - // category: defaultCategoryName + "," + defaultSubCategory.name, | ||
195 | - // function: defaultFuncCategory.name, | ||
196 | - // }, | ||
197 | - // }); | ||
198 | - // } | ||
199 | - // } | ||
200 | - // } | ||
201 | -}); | ||
202 | -const seo = { | ||
203 | - "Energy materials": | ||
204 | - "Energy materials,Not specified,Battery accessories,Lithium-ion batteries,Capacitors,Sodium-ion batteries,Lithium-sulfur batteries,Potassium/magnesium/aluminum/zinc batteries,Air/fuel/solar,Analytical electrodes,Complete battery accessories", | ||
205 | - "Laboratory consumables": | ||
206 | - "Laboratory consumables,Not specified,Glass materials,Plastic materials,Metal materials,Ceramic materials,Paper film materials,Chemical materials,Tetrafluoro materials,Safety protection,Office supplies,Tools,Others", | ||
207 | - "Low-dimensional materials": | ||
208 | - ",Low-dimensional materialsNot specified,Zero-dimensional carbon materials,One-dimensional carbon materials,Two-dimensional carbon materials,Three-dimensional carbon materials,Inorganic nanomaterials,Organic nanomaterials,Metal nanomaterials,Others", | ||
209 | - Equipment: | ||
210 | - "Equipment,Not specified,Equipment,Accessories & fixtures,Fuel cell manufacturing and testing equipment", | ||
211 | -}; | ||
212 | - | ||
213 | -onMounted(() => { | ||
214 | - // console.log(route, "5656mountedroute"); | ||
215 | - // console.log(route.query, "5656mountedquery"); | ||
216 | - // console.log(route.fullPath, "5656mountedfullPath"); | ||
217 | - if (Object.keys(route.query).length === 0) { | ||
218 | - // if (route.fullPath === "/products") { | ||
219 | - // console.log(route.query, "5656mountedquery222"); | ||
220 | - | 156 | + } else if (Object.keys(route.query).length === 0) { |
221 | // 检查是否有默认的分类 | 157 | // 检查是否有默认的分类 |
222 | const defaultCategory = categoryStore.list[0]; // 假设第一个分类是默认的 | 158 | const defaultCategory = categoryStore.list[0]; // 假设第一个分类是默认的 |
159 | + | ||
223 | if (defaultCategory) { | 160 | if (defaultCategory) { |
224 | const defaultCategoryName = defaultCategory.categoryDisplayName; | 161 | const defaultCategoryName = defaultCategory.categoryDisplayName; |
225 | const defaultSubCategory = defaultCategory.list[0]; // 假设第一个子分类为默认子分类 | 162 | const defaultSubCategory = defaultCategory.list[0]; // 假设第一个子分类为默认子分类 |
@@ -257,6 +194,16 @@ onMounted(() => { | @@ -257,6 +194,16 @@ onMounted(() => { | ||
257 | } | 194 | } |
258 | } | 195 | } |
259 | }); | 196 | }); |
197 | +const seo = { | ||
198 | + "Energy materials": | ||
199 | + "Energy materials,Not specified,Battery accessories,Lithium-ion batteries,Capacitors,Sodium-ion batteries,Lithium-sulfur batteries,Potassium/magnesium/aluminum/zinc batteries,Air/fuel/solar,Analytical electrodes,Complete battery accessories", | ||
200 | + "Laboratory consumables": | ||
201 | + "Laboratory consumables,Not specified,Glass materials,Plastic materials,Metal materials,Ceramic materials,Paper film materials,Chemical materials,Tetrafluoro materials,Safety protection,Office supplies,Tools,Others", | ||
202 | + "Low-dimensional materials": | ||
203 | + ",Low-dimensional materialsNot specified,Zero-dimensional carbon materials,One-dimensional carbon materials,Two-dimensional carbon materials,Three-dimensional carbon materials,Inorganic nanomaterials,Organic nanomaterials,Metal nanomaterials,Others", | ||
204 | + Equipment: | ||
205 | + "Equipment,Not specified,Equipment,Accessories & fixtures,Fuel cell manufacturing and testing equipment", | ||
206 | +}; | ||
260 | 207 | ||
261 | const handleCategoryClick = (item: CategoryRootType) => { | 208 | const handleCategoryClick = (item: CategoryRootType) => { |
262 | categoryStore.updateCategory(item.categoryDisplayName); | 209 | categoryStore.updateCategory(item.categoryDisplayName); |
nuxt.config.ts
@@ -33,7 +33,7 @@ export default defineNuxtConfig({ | @@ -33,7 +33,7 @@ export default defineNuxtConfig({ | ||
33 | devProxy: { | 33 | devProxy: { |
34 | "/shop": { | 34 | "/shop": { |
35 | target: "http://47.89.254.121:8002/shop", // 线上代理地址 | 35 | target: "http://47.89.254.121:8002/shop", // 线上代理地址 |
36 | - // target: "http://127.0.0.1:8002/shop/**", | 36 | + // target: "http://127.0.0.1:8002/shop", |
37 | // target: process.env.BASE_URL || 'http://39.108.227.113:8002/shop', // 目标接口域名 | 37 | // target: process.env.BASE_URL || 'http://39.108.227.113:8002/shop', // 目标接口域名 |
38 | changeOrigin: true, // 表示是否跨域 | 38 | changeOrigin: true, // 表示是否跨域 |
39 | }, | 39 | }, |