2121</template >
2222
2323<script setup lang="ts">
24- import { onMounted , ref } from ' vue' ;
24+ import { onMounted , ref , nextTick } from ' vue' ;
2525import type { ElTable } from ' element-plus' ;
2626import { imgUrl } from ' ../assets/img' ;
2727import { sendCommand } from ' ../api/vscode' ;
@@ -44,9 +44,11 @@ const reloadBSPProjects = () => {
4444
4545const saveBSPProjects = () => {
4646 let args: string [] = [];
47- const selectedRows = tableRef .value ?.getSelectionRows ();
48- if (selectedRows && selectedRows .length > 0 ) {
49- args = selectedRows .map ((row : any ) => row .path );
47+ if (tableRef .value ) {
48+ const selectedRows = (tableRef .value as any ).getSelectionRows ();
49+ if (selectedRows .length > 0 ) {
50+ args = selectedRows .map (row => row .path );
51+ }
5052 }
5153
5254 sendCommand (' saveBSPProjects' , [args ]);
@@ -63,12 +65,17 @@ onMounted(() => {
6365 case ' updateProjects' :
6466 tableData .value = message .data .dirs ;
6567 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- }
68+
69+ nextTick (() => {
70+ tableData .value .forEach ((item : any , index : number ) => {
71+ if (stars .includes (item .path )) {
72+ if (tableRef .value ) {
73+ (tableRef .value as any ).toggleRowSelection (item , true );
74+ }
75+ }
76+ });
7077 });
71-
78+
7279 loading .value = false ; // 停止加载动画
7380 break ;
7481
0 commit comments