99 @close =" $emit('cancel')"
1010 @open =" initdialogBox"
1111 >
12- <div class =" mcp-switch-container" >
13- <span class =" mcp-switch-label" >启用 MCP 集成:</span >
14- <tiny-switch v-model =" mcpEnabled" @change =" handleMcpChange" ></tiny-switch >
15- <span class =" mcp-switch-tip" >(开启后将生成 MCP 相关配置和工具代码)</span >
16- </div >
1712 <div class =" dialog-grid" >
1813 <div class =" tree-wrap" >
1914 <tiny-tree
4035 </div >
4136 </div >
4237 <template #footer >
43- <tiny-button type =" primary" @click =" confirm" >确定</tiny-button >
44- <tiny-button @click =" $emit('cancel')" >取消</tiny-button >
38+ <div class =" dialog-footer" >
39+ <div class =" mcp-switch-container" >
40+ <span class =" mcp-switch-label" >启用 MCP 集成:</span >
41+ <tiny-switch v-model =" mcpEnabled" @change =" handleMcpChange" ></tiny-switch >
42+ <span class =" mcp-switch-tip" >(开启后将生成 MCP 相关配置和工具代码)</span >
43+ </div >
44+ <div class =" dialog-footer-actions" >
45+ <tiny-button @click =" $emit('cancel')" >取消</tiny-button >
46+ <tiny-button type =" primary" @click =" confirm" >确定</tiny-button >
47+ </div >
48+ </div >
4549 </template >
4650 </tiny-dialog-box >
4751</template >
@@ -117,6 +121,18 @@ export default {
117121 }
118122 const mcpEnabled = ref (props .enableMcp )
119123
124+ // 更新树的展开和选中状态
125+ const updateTreeState = (checkedKeys : string []) => {
126+ if (! fileTreeRef .value ) return
127+
128+ nextTick (() => {
129+ // 设置选中的节点
130+ fileTreeRef .value .setCheckedKeys (checkedKeys )
131+ // 展开所有节点
132+ fileTreeRef .value .expandAllNodes (true )
133+ })
134+ }
135+
120136 // 监听 props.enableMcp 的变化,同步到本地状态
121137 watch (
122138 () => props .enableMcp ,
@@ -129,12 +145,22 @@ export default {
129145 watch (
130146 () => props .data ,
131147 () => {
132- nextTick (() => {
133- if (gridRef .value ) {
134- gridRef .value .setAllTreeExpansion (true )
135- gridRef .value .setAllSelection (true )
136- }
137- })
148+ if (fileTreeRef .value && props .treeData ?.checkedTreeData ) {
149+ const allKeys = [' all' , ... props .treeData .checkedTreeData ]
150+ updateTreeState (allKeys )
151+ }
152+ },
153+ { deep: true }
154+ )
155+
156+ // 监听 props.treeData 的变化,更新树的选中状态
157+ watch (
158+ () => props .treeData ,
159+ (newTreeData ) => {
160+ if (newTreeData ?.checkedTreeData && fileTreeRef .value ) {
161+ const allKeys = [' all' , ... newTreeData .checkedTreeData ]
162+ updateTreeState (allKeys )
163+ }
138164 },
139165 { deep: true }
140166 )
@@ -166,14 +192,14 @@ export default {
166192 if (currentPage ) {
167193 const initCurrentNode: any = props .data .find ((item : any ) => item .fileName === ` ${currentPage .name }.vue ` )
168194 // 同步 props 到本地状态
169- mcpEnabled .value = props .enableMcp
195+ mcpEnabled .value = props .enableMcp
170196
171- nextTick (() => {
172- if (gridRef .value ) {
197+ nextTick (() => {
198+ if (fileTreeRef .value && initCurrentNode ) {
173199 fileContent .value = initCurrentNode .fileContent
174200 fileTreeRef .value .setCurrentKey (initCurrentNode .fileName )
175201 }
176- })
202+ })
177203 }
178204 }
179205
@@ -197,23 +223,46 @@ export default {
197223 </script >
198224
199225<style lang="less" scoped>
226+ .dialog-footer {
227+ width : 100% ;
228+ display : flex ;
229+ align-items : center ;
230+ justify-content : space-between ;
231+ gap : 16px ;
232+ }
233+
234+ .dialog-footer-actions {
235+ display : flex ;
236+ align-items : center ;
237+ gap : 8px ;
238+ flex-shrink : 0 ;
239+
240+ @media (max-width : 768px ) {
241+ width : 100% ;
242+ justify-content : flex-end ;
243+ }
244+ }
245+
200246.mcp-switch-container {
201247 display : flex ;
202248 align-items : center ;
203- padding : 12px 0 ;
204- margin-bottom : 12px ;
205- border-bottom : 1px solid var (--te-toolbars-generate-code-border-color , #ddd );
249+ gap : 8px ;
250+ flex-wrap : wrap ;
206251
207252 .mcp-switch-label {
208253 font-size : 14px ;
209254 color : var (--te-toolbars-generate-code-text-color );
210- margin-right : 8 px ;
255+ white-space : nowrap ;
211256 }
212257
213258 .mcp-switch-tip {
214259 font-size : 12px ;
215260 color : var (--te-toolbars-generate-code-text-color-secondary , #999 );
216- margin-left : 8px ;
261+ line-height : 1.5 ;
262+
263+ @media (max-width : 768px ) {
264+ flex-basis : 100% ;
265+ }
217266 }
218267}
219268
@@ -241,6 +290,9 @@ export default {
241290 }
242291
243292 .tiny-dialog-box__footer {
293+ display : flex ;
294+ justify-content : space-around ;
295+
244296 .tiny-button--primary {
245297 background-color : var (--te-toolbars-generate-code-bg-color-primary );
246298 border : none ;
0 commit comments