Skip to content

Commit

Permalink
feat: 修改项目管理
Browse files Browse the repository at this point in the history
  • Loading branch information
xxss0903 committed Nov 22, 2024
1 parent f007d8c commit 71531b3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 18 deletions.
15 changes: 10 additions & 5 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,18 @@ const routes = [
}
},
{
path: '/project/:id',
path: '/tools/project/:id',
name: 'ProjectDetail',
component: () => import('./tools/projecttools/ProjectDetail.vue'),
props: true,
component: () => import('@/tools/projecttools/ProjectDetail.vue'),
props: (route) => ({
id: route.params.id,
title: route.query.title,
from: route.query.from
}),
meta: {
title: '项目详情',
newTab: true // 标记需要在新标签页打开
title: (route) => `项目:${route.query.title || '详情'}`,
icon: 'Folder',
newTab: true
}
}
]
Expand Down
36 changes: 26 additions & 10 deletions src/tools/projecttools/ProjectDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ import moment from 'moment'
interface Props {
id: string
title?: string
from?: string
}
const props = defineProps<Props>()
const route = useRoute()
const router = useRouter()
interface Project {
Expand Down Expand Up @@ -224,26 +225,41 @@ const openInFinder = async () => {
// 加载项目信息
const loadProjectInfo = async () => {
try {
console.log('load project props.id:', props.id)
const projectData = await window.projectAPI.getProject(props.id)
project.value = projectData.dataValues
console.log(project.value)
// 加载项目统计信息
const projectStats = await window.electronAPI.getProjectStats(project.value.path)
stats.value = projectStats
if (project.value && project.value.path) {
// 加载项目统计信息
const projectStats = await window.electronAPI.getProjectStats(project.value.path)
stats.value = projectStats
// 加载文件树结构
// const treeData = await window.electronAPI.getProjectFileTree(project.value.path)
// fileTreeData.value = treeData
// 加载文件树结构
const treeData = await window.electronAPI.getProjectFileTree(project.value.path)
fileTreeData.value = treeData
}
} catch (error) {
console.error(error)
ElMessage.error('加载项目信息失败')
console.error(error)
}
}
// 监听路由参数变化
watch(
() => props.id,
(newId) => {
if (newId) {
loadProjectInfo()
}
}
)
const goBack = () => {
router.back()
// if (props.from === 'project-manager') {
// router.push('/tools/project-manager')
// } else {
// router.back()
// }
}
onMounted(() => {
Expand Down
8 changes: 5 additions & 3 deletions src/tools/projecttools/ProjectManageTools.vue
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,11 @@ onMounted(() => {
const openProjectDetail = (project: Project) => {
router.push({
name: 'ProjectDetail',
params: { id: project.id },
query: { title: project.name }
path: `/tools/project/${project.id}`,
query: {
title: project.name,
from: 'project-manager'
}
})
}
</script>
Expand Down

0 comments on commit 71531b3

Please sign in to comment.