@@ -6,11 +6,13 @@ import FileTree from './components/FileTree.vue';
66import ConfigPanel from ' ./components/ConfigPanel.vue' ;
77import Toolbar from ' ./components/Toolbar.vue' ;
88import { generatePrompt , copyToClipboard , filesToTree , fileToNode , type FileNode } from ' ./utils/promptGenerator' ;
9+ import { generateCursorRules } from ' ./utils/cursorRulesGenerator' ;
910
1011// 状态
1112const sourceCode = ref (' ' );
1213const generatedPrompt = ref (' ' );
13- const selectedLanguage = ref (' javascript' );
14+ const generatedCursorRules = ref (' ' );
15+ const selectedLanguage = ref (' python' );
1416const projectFiles = ref <FileNode []>([]);
1517const selectedFile = ref <FileNode | null >(null );
1618const showConfigModal = ref (false );
@@ -34,6 +36,7 @@ const config = reactive({
3436 ' readability'
3537 ],
3638 language_specific_techniques: true ,
39+ framework: ' ' ,
3740 preserve_functionality: true ,
3841 add_easter_eggs: true ,
3942 add_comments: true ,
@@ -47,7 +50,7 @@ const config = reactive({
4750 }
4851});
4952
50- // 自动更新生成的 prompt
53+ // 自动更新生成的 prompt 和 cursorrules
5154const updatePrompt = () => {
5255 if (sourceCode .value .trim ().length > 0 ) {
5356 const prompt = generatePrompt (
@@ -57,6 +60,13 @@ const updatePrompt = () => {
5760 projectFiles .value .length > 0 ? projectFiles .value : undefined
5861 );
5962 generatedPrompt .value = prompt ;
63+
64+ // 生成 .cursorrules 文件内容
65+ const cursorRules = generateCursorRules (
66+ selectedLanguage .value ,
67+ config
68+ );
69+ generatedCursorRules .value = cursorRules ;
6070 }
6171};
6272
@@ -224,10 +234,9 @@ const closeConfigModal = () => {
224234 @open-config =" showConfigModal = true"
225235 />
226236
227- <!-- 主内容区域 -->
228237 <div class =" main-content" >
229238 <!-- 侧边栏 -->
230- <div class = " sidebar " v-if =" hasSidebar" >
239+ <div v-if =" hasSidebar" class = " sidebar " >
231240 <div class =" sidebar-header" >
232241 <h3 >项目文件</h3 >
233242 <button class =" sidebar-toggle" @click =" toggleSidebar" title =" 隐藏侧边栏" >
@@ -251,21 +260,54 @@ const closeConfigModal = () => {
251260 <span >▶</span >
252261 </button >
253262
254- <!-- 编辑器区域 -->
255- <div class =" editors" :class =" { 'with-sidebar': hasSidebar }" >
256- <div class =" editor-container" >
263+ <!-- 内容区域 -->
264+ <div class =" content-area" :class =" { 'with-sidebar': hasSidebar }" >
265+ <!-- 编辑器部分 -->
266+ <div class =" editor-section" >
267+ <div class =" section-header" >
268+ <h3 >源代码</h3 >
269+ <div class =" language-selector" >
270+ <label for =" language-select" >语言:</label >
271+ <select
272+ id =" language-select"
273+ v-model =" selectedLanguage"
274+ @change =" updatePrompt"
275+ >
276+ <option value =" javascript" >JavaScript</option >
277+ <option value =" typescript" >TypeScript</option >
278+ <option value =" python" >Python</option >
279+ <option value =" java" >Java</option >
280+ <option value =" csharp" >C#</option >
281+ <option value =" cpp" >C++</option >
282+ <option value =" go" >Go</option >
283+ <option value =" rust" >Rust</option >
284+ <option value =" php" >PHP</option >
285+ <option value =" ruby" >Ruby</option >
286+ <option value =" swift" >Swift</option >
287+ <option value =" kotlin" >Kotlin</option >
288+ <option value =" scala" >Scala</option >
289+ <option value =" html" >HTML</option >
290+ <option value =" css" >CSS</option >
291+ <option value =" sql" >SQL</option >
292+ </select >
293+ </div >
294+ </div >
257295 <CodeEditor
258296 v-model =" sourceCode"
259- :language =" selectedLanguage"
260- :showUpload =" true"
261- title =" 源代码"
297+ :language =" selectedLanguage"
298+ :show-upload =" true"
262299 @file-upload =" handleFileUpload"
263300 />
264301 </div >
265- <div class =" editor-container" >
302+
303+ <!-- 预览部分 -->
304+ <div class =" preview-section" >
305+ <div class =" section-header" >
306+ <h3 >生成的提示</h3 >
307+ </div >
266308 <MarkdownPreview
267309 v-model =" generatedPrompt"
268- title = " 生成的提示 "
310+ :cursor-rules = " generatedCursorRules "
269311 />
270312 </div >
271313 </div >
@@ -303,7 +345,9 @@ html, body {
303345 width : 100% ;
304346 overflow : hidden ;
305347}
348+ </style >
306349
350+ <style scoped>
307351.app {
308352 display : flex ;
309353 flex-direction : column ;
@@ -322,42 +366,36 @@ html, body {
322366 display : flex ;
323367 flex : 1 ;
324368 overflow : hidden ;
325- width : 100% ;
326- height : calc (100vh - 60px );
327- position : relative ;
328369}
329370
330371.sidebar {
331372 width : 250px ;
332- min-width : 200px ;
333- overflow : hidden ;
373+ background-color : #252526 ;
334374 border-right : 1px solid #333 ;
335375 background-color : #1e1e1e ;
336376 height : 100% ;
337377 display : flex ;
338378 flex-direction : column ;
339- transition : width 0.3 s ease ;
379+ overflow : hidden ;
340380}
341381
342382.sidebar-header {
343383 display : flex ;
344384 justify-content : space-between ;
345385 align-items : center ;
346- padding : 10px 16px ;
347- background-color : #2a2a2a ;
386+ padding : 10px ;
348387 border-bottom : 1px solid #333 ;
349388}
350389
351390.sidebar-header h3 {
352391 margin : 0 ;
353392 font-size : 16px ;
354- font-weight : 500 ;
355393}
356394
357395.sidebar-toggle {
358396 background : none ;
359397 border : none ;
360- color : #888 ;
398+ color : #e0e0e0 ;
361399 cursor : pointer ;
362400 font-size : 14px ;
363401 padding : 4px ;
@@ -378,60 +416,66 @@ html, body {
378416 left : 0 ;
379417 top : 50% ;
380418 transform : translateY (-50% );
381- background-color : #2a2a2a ;
382- border : none ;
383- border-right : 1px solid #333 ;
384- color : #888 ;
419+ background-color : #252526 ;
420+ border : 1px solid #333 ;
421+ border-left : none ;
422+ color : #e0e0e0 ;
423+ padding : 10px 5px ;
385424 cursor : pointer ;
386- font-size : 14px ;
387- padding : 8px 4px ;
425+ z-index : 10 ;
426+ }
427+
428+ .content-area {
429+ flex : 1 ;
388430 display : flex ;
389- align-items : center ;
390- justify-content : center ;
391- border-top-right-radius : 4px ;
392- border-bottom-right-radius : 4px ;
393- z-index : 5 ;
394- transition : all 0.2s ease ;
395- box-shadow : 2px 0 5px rgba (0 , 0 , 0 , 0.2 );
431+ flex-direction : column ;
432+ overflow : hidden ;
396433}
397434
398- .sidebar-show-button :hover {
399- color : #e0e0e0 ;
400- background-color : #3a3a3a ;
435+ @media (min-width : 768px ) {
436+ .content-area {
437+ flex-direction : row ;
438+ }
439+ }
440+
441+ .content-area.with-sidebar {
442+ margin-left : 0 ;
401443}
402444
403- .editor-container {
445+ .editor-section , .preview-section {
404446 flex : 1 ;
405447 display : flex ;
406448 flex-direction : column ;
407449 overflow : hidden ;
408- padding : 16px ;
409- height : 100% ;
410- box-sizing : border-box ;
450+ padding : 10px ;
451+ border-bottom : 1px solid #333 ;
452+ }
453+
454+ @media (min-width : 768px ) {
455+ .editor-section , .preview-section {
456+ border-bottom : none ;
457+ }
458+
459+ .editor-section {
460+ border-right : 1px solid #333 ;
461+ }
411462}
412463
413- .editors {
464+ .section-header {
414465 display : flex ;
415- flex : 1 ;
416- gap : 16px ;
417- overflow : hidden ;
418- height : 100% ;
419- width : 100% ;
420- transition : width 0.3s ease , margin-left 0.3s ease ;
421- padding-left : 0 ;
466+ justify-content : space-between ;
467+ align-items : center ;
468+ margin-bottom : 10px ;
422469}
423470
424- .editors.with-sidebar {
425- width : calc (100% - 250px );
471+ .section-header h3 {
472+ margin : 0 ;
473+ font-size : 16px ;
426474}
427475
428- .editor-panel {
429- flex : 1 ;
476+ .language-selector {
430477 display : flex ;
431- flex-direction : column ;
432- overflow : hidden ;
433- min-width : 400px ;
434- height : 100% ;
478+ align-items : center ;
435479}
436480
437481/* 弹窗样式 */
@@ -491,7 +535,7 @@ html, body {
491535.close-button {
492536 background : none ;
493537 border : none ;
494- color : #888 ;
538+ color : #e0e0e0 ;
495539 font-size : 24px ;
496540 cursor : pointer ;
497541 padding : 0 ;
0 commit comments