Skip to content

Commit 093c008

Browse files
authored
Merge pull request #15 from BernardXiong/dev
refactor: enhance saveBSPProjects and updateProjects logic for better…
2 parents c1e097a + 76827e0 commit 093c008

File tree

1 file changed

+58
-10
lines changed

1 file changed

+58
-10
lines changed

src/vue/projects/App.vue

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
<template>
22
<div class="container">
3-
<img class="logo_img" :src="imgUrl['head-logo']" alt="" /> | workspace工程列表
3+
<div class="header_logo">
4+
<img class="logo_img" :src="imgUrl['head-logo']" alt="" />
5+
<div class="logo_text">
6+
<p>扩展工具 - workspace工程列表</p>
7+
<span>v{{ extensionInfo.version }}</span>
8+
</div>
9+
</div>
410
<br><br>
511
可以在感兴趣的BSP/工程项上✔,然后保存配置,将会在侧边栏中显示对应列表。<br>
612
<hr>
@@ -21,10 +27,11 @@
2127
</template>
2228

2329
<script setup lang="ts">
24-
import { onMounted, ref } from 'vue';
30+
import { onMounted, ref, nextTick } from 'vue';
2531
import type { ElTable } from 'element-plus';
2632
import { imgUrl } from '../assets/img';
2733
import { sendCommand } from '../api/vscode';
34+
import { extensionInfo } from '../home/data';
2835
2936
const loading = ref(false); // 是否加载中
3037
@@ -44,9 +51,11 @@ const reloadBSPProjects = () => {
4451
4552
const saveBSPProjects = () => {
4653
let args: string[] = [];
47-
const selectedRows = tableRef.value?.getSelectionRows();
48-
if (selectedRows && selectedRows.length > 0) {
49-
args = selectedRows.map((row: any) => row.path);
54+
if (tableRef.value) {
55+
const selectedRows = (tableRef.value as any).getSelectionRows();
56+
if (selectedRows.length > 0) {
57+
args = selectedRows.map(row => row.path);
58+
}
5059
}
5160
5261
sendCommand('saveBSPProjects', [args]);
@@ -63,12 +72,17 @@ onMounted(() => {
6372
case 'updateProjects':
6473
tableData.value = message.data.dirs;
6574
let stars: string[] = message.data.stars;
66-
tableData.value.forEach((item: any, index: number) => {
67-
if (stars.includes(item.path)) {
68-
tableRef.value?.toggleRowSelection(item, true);
69-
}
75+
76+
nextTick(() => {
77+
tableData.value.forEach((item: any, index: number) => {
78+
if (stars.includes(item.path)) {
79+
if (tableRef.value) {
80+
(tableRef.value as any).toggleRowSelection(item, true);
81+
}
82+
}
83+
});
7084
});
71-
85+
7286
loading.value = false; // 停止加载动画
7387
break;
7488
@@ -83,4 +97,38 @@ onMounted(() => {
8397
.container {
8498
padding: 20px;
8599
}
100+
101+
.header_logo {
102+
display: flex;
103+
align-items: center;
104+
column-gap: 12px;
105+
font-size: 18px;
106+
color: #333;
107+
margin-bottom: 20px;
108+
109+
.logo_img {
110+
width: 228px;
111+
height: 68px;
112+
}
113+
114+
.logo_text {
115+
color: #333;
116+
padding-top: 15px;
117+
118+
p {
119+
font-size: 18px;
120+
margin: 0;
121+
}
122+
123+
span {
124+
font-size: 12px;
125+
}
126+
}
127+
}
128+
129+
.page_title {
130+
font-size: 16px;
131+
color: #666;
132+
margin-top: 10px;
133+
}
86134
</style>

0 commit comments

Comments
 (0)