@@ -14,10 +14,12 @@ const selectedLanguage = ref('javascript');
1414const projectFiles = ref <FileNode []>([]);
1515const selectedFile = ref <FileNode | null >(null );
1616const showConfigModal = ref (false );
17+ const showSidebar = ref (true ); // 控制侧边栏显示状态
1718
1819// 计算属性
1920const canConvert = computed (() => sourceCode .value .trim ().length > 0 );
2021const selectedFilePath = computed (() => selectedFile .value ?.path || ' ' );
22+ const hasSidebar = computed (() => projectFiles .value .length > 0 && showSidebar .value );
2123
2224// 配置
2325const config = reactive ({
@@ -73,6 +75,9 @@ const handleFileUpload = (files: File[]) => {
7375 // 添加到文件树
7476 projectFiles .value = [fileToNode (file )];
7577 selectedFile .value = projectFiles .value [0 ];
78+
79+ // 确保侧边栏显示
80+ showSidebar .value = true ;
7681 }
7782 };
7883 reader .readAsText (file );
@@ -85,6 +90,9 @@ const handleFileUpload = (files: File[]) => {
8590 if (firstFile ) {
8691 selectedFile .value = firstFile ;
8792 loadFileContent (firstFile , files );
93+
94+ // 确保侧边栏显示
95+ showSidebar .value = true ;
8896 }
8997 }
9098};
@@ -177,13 +185,18 @@ const setLanguageFromExtension = (extension: string) => {
177185 }
178186};
179187
180- // const handleLanguageChange = (language: string) => {
181- // selectedLanguage.value = language;
182- // };
188+ // 切换侧边栏显示状态
189+ const toggleSidebar = () => {
190+ showSidebar .value = ! showSidebar .value ;
191+ };
192+
193+ const handleLanguageChange = (language : string ) => {
194+ selectedLanguage .value = language ;
195+ };
183196
184- // const handleConfigChange = (newConfig: any) => {
185- // config.shitty_code_settings = newConfig.shitty_code_settings;
186- // };
197+ const handleConfigChange = (newConfig : any ) => {
198+ config .shitty_code_settings = newConfig .shitty_code_settings ;
199+ };
187200
188201const closeConfigModal = () => {
189202 showConfigModal .value = false ;
@@ -201,16 +214,32 @@ const closeConfigModal = () => {
201214 <!-- 主内容区域 -->
202215 <div class =" main-content" >
203216 <!-- 侧边栏 -->
204- <div class =" sidebar" v-if =" projectFiles.length > 0" >
217+ <div class =" sidebar" v-if =" hasSidebar" >
218+ <div class =" sidebar-header" >
219+ <h3 >项目文件</h3 >
220+ <button class =" sidebar-toggle" @click =" toggleSidebar" title =" 隐藏侧边栏" >
221+ <span >◀</span >
222+ </button >
223+ </div >
205224 <FileTree
206225 :files =" projectFiles"
207226 @file-select =" handleFileSelect"
208227 :selected-path =" selectedFilePath"
209228 />
210229 </div >
211230
231+ <!-- 侧边栏切换按钮 -->
232+ <button
233+ v-if =" projectFiles.length > 0 && !showSidebar"
234+ class =" sidebar-show-button"
235+ @click =" toggleSidebar"
236+ title =" 显示侧边栏"
237+ >
238+ <span >▶</span >
239+ </button >
240+
212241 <!-- 编辑器区域 -->
213- <div class =" editors" >
242+ <div class =" editors" :class = " { 'with-sidebar': hasSidebar } " >
214243 <div class =" editor-container" >
215244 <CodeEditor
216245 v-model =" sourceCode"
@@ -282,15 +311,80 @@ html, body {
282311 overflow : hidden ;
283312 width : 100% ;
284313 height : calc (100vh - 60px );
314+ position : relative ;
285315}
286316
287317.sidebar {
288318 width : 250px ;
289319 min-width : 200px ;
290- overflow : auto ;
320+ overflow : hidden ;
291321 border-right : 1px solid #333 ;
292322 background-color : #1e1e1e ;
293323 height : 100% ;
324+ display : flex ;
325+ flex-direction : column ;
326+ transition : width 0.3s ease ;
327+ }
328+
329+ .sidebar-header {
330+ display : flex ;
331+ justify-content : space-between ;
332+ align-items : center ;
333+ padding : 10px 16px ;
334+ background-color : #2a2a2a ;
335+ border-bottom : 1px solid #333 ;
336+ }
337+
338+ .sidebar-header h3 {
339+ margin : 0 ;
340+ font-size : 16px ;
341+ font-weight : 500 ;
342+ }
343+
344+ .sidebar-toggle {
345+ background : none ;
346+ border : none ;
347+ color : #888 ;
348+ cursor : pointer ;
349+ font-size : 14px ;
350+ padding : 4px ;
351+ display : flex ;
352+ align-items : center ;
353+ justify-content : center ;
354+ border-radius : 4px ;
355+ transition : all 0.2s ease ;
356+ }
357+
358+ .sidebar-toggle :hover {
359+ color : #e0e0e0 ;
360+ background-color : #3a3a3a ;
361+ }
362+
363+ .sidebar-show-button {
364+ position : absolute ;
365+ left : 0 ;
366+ top : 50% ;
367+ transform : translateY (-50% );
368+ background-color : #2a2a2a ;
369+ border : none ;
370+ border-right : 1px solid #333 ;
371+ color : #888 ;
372+ cursor : pointer ;
373+ font-size : 14px ;
374+ padding : 8px 4px ;
375+ display : flex ;
376+ align-items : center ;
377+ justify-content : center ;
378+ border-top-right-radius : 4px ;
379+ border-bottom-right-radius : 4px ;
380+ z-index : 5 ;
381+ transition : all 0.2s ease ;
382+ box-shadow : 2px 0 5px rgba (0 , 0 , 0 , 0.2 );
383+ }
384+
385+ .sidebar-show-button :hover {
386+ color : #e0e0e0 ;
387+ background-color : #3a3a3a ;
294388}
295389
296390.editor-container {
@@ -310,6 +404,12 @@ html, body {
310404 overflow : hidden ;
311405 height : 100% ;
312406 width : 100% ;
407+ transition : width 0.3s ease , margin-left 0.3s ease ;
408+ padding-left : 0 ;
409+ }
410+
411+ .editors.with-sidebar {
412+ width : calc (100% - 250px );
313413}
314414
315415.editor-panel {
@@ -451,10 +551,24 @@ html, body {
451551 border-bottom : 1px solid #333 ;
452552 }
453553
554+ .editors.with-sidebar {
555+ width : 100% ;
556+ height : calc (100% - 200px );
557+ }
558+
454559 .editor-container {
455560 width : 100% ;
456561 height : calc (100% - 200px );
457562 padding : 8px ;
458563 }
564+
565+ .sidebar-show-button {
566+ top : 200px ;
567+ left : 50% ;
568+ transform : translateX (-50% ) rotate (90deg );
569+ border-radius : 0 0 4px 4px ;
570+ border-right : none ;
571+ border-top : 1px solid #333 ;
572+ }
459573}
460574 </style >
0 commit comments