后期修改完善,上线版本

This commit is contained in:
2025-11-12 18:11:11 +08:00
parent c54f9c9976
commit 8f57683dd5
98 changed files with 2110 additions and 867 deletions

View File

@ -5,7 +5,7 @@
</div>
<div class="line">
</div>
<div class="toolbar" v-for="tool in toolsGroup">
<div class="toolbar" v-for="tool in processedToolsGroup" :key="tool.categoryId">
<Toolbar :tool="tool" :id="`tool-${tool.categoryName}`" :category-slug="tool.categorySlug || ''"></Toolbar>
</div>
</div>
@ -22,6 +22,14 @@ export default {
fullscreenLoading: false,
categoryList: [],
toolsGroup: [],
processedToolsGroup: [] // 处理后的工具列表
}
},
computed: {
// 计算属性,用于获取处理后的工具列表
getProcessedTools() {
this.processData();
return this.processedToolsGroup;
}
},
methods: {
@ -48,6 +56,8 @@ export default {
const {code, data} = res;
if (code === 0 && data.list) {
this.toolsGroup = data.list;
// 数据获取完成后处理数据
this.processData();
}
},
async onLoad() {
@ -55,6 +65,38 @@ export default {
await this.getCategoryAsyncData();
await this.getToolsGroupAsyncData();
this.fullscreenLoading = false;
},
// 处理数据的核心逻辑
processData() {
// 确保工具列表已加载
if (!this.toolsGroup.length) {
return;
}
// 1. 分离一级分类parentId === 0和二级分类parentId !== 0
const mainTools = this.toolsGroup.filter(tool => tool.parentId === 0);
const subTools = this.toolsGroup.filter(tool => tool.parentId !== 0);
// 2. 创建一个映射,方便快速查找一级分类
const mainToolMap = {};
mainTools.forEach(tool => {
// 去除tools属性添加tagList属性
mainToolMap[tool.categoryId] = {
...tool,
tagList: [] // 初始化空的tagList
};
});
// 3. 将二级分类添加到对应的一级分类的tagList中
subTools.forEach(subTool => {
const parentTool = mainToolMap[subTool.parentId];
if (parentTool) {
parentTool.tagList.push(subTool);
}
});
// 4. 获取处理后的工具列表(值的数组)
this.processedToolsGroup = Object.values(mainToolMap);
}
},
created() {

View File

@ -47,6 +47,7 @@ export default {
const slug = to.query.category_slug;
if (slug) {
this.category_slug = slug;
this.tagName = to.query.tag_name;
this.getToolsByTag(slug);
}
}
@ -54,9 +55,11 @@ export default {
mounted() {
// 组件挂载时也检查一次路由参数
const slug = this.$route.query.category_slug;
if (slug) {
const tagName = this.$route.query.tag_name;
if (slug && tagName) {
this.category_slug = slug;
this.getToolsByTag(slug);
this.tagName = tagName;
}
},
}
@ -64,13 +67,13 @@ export default {
<style scoped lang="scss">
.content {
padding-top: 60px;
padding-top: 50px;
padding-bottom: 100px;
.tag-item {
display: inline-block;
padding: 10px;
border-radius: 12px;
font-family: 'Poppins-SemiBold', sans-serif;
font-family: 'Poppins-SemiBold';
color: #fff;
font-weight: 600;
background: $header-backgroungd;