@@ -32,15 +32,24 @@ export const getLocalMaterials = (
3232 viewPrompt ?: string ;
3333 } ;
3434 } ;
35+ commandPrompt ?: string ; // 优先级比 preview.chatGPT 高
36+ viewPrompt ?: string ; // 优先级比 preview.chatGPT 高
3537 template : string ;
3638 } [ ] = [ ] ;
3739 try {
3840 materials = fs . readdirSync ( materialsFullPath ) . map ( ( s ) => {
3941 const fullPath = path . join ( materialsFullPath , s ) ;
4042 let model = { } as any ;
4143 let schema = { } as any ;
42- let preview = { img : '' , category : [ ] , schema : 'form-render' } ;
44+ let preview = {
45+ img : '' ,
46+ category : [ ] ,
47+ schema : 'form-render' ,
48+ chatGPT : { commandPrompt : '' , viewPrompt : '' } ,
49+ } ;
4350 let template = '' ;
51+ let commandPrompt = '' ;
52+ let viewPrompt = '' ;
4453 try {
4554 model = JSON . parse (
4655 getFileContent ( path . join ( fullPath , 'config' , 'model.json' ) , true ) ,
@@ -56,13 +65,32 @@ export const getLocalMaterials = (
5665 getFileContent ( path . join ( fullPath , 'config' , 'preview.json' ) , true ) ,
5766 ) ;
5867 } catch { }
68+ try {
69+ commandPrompt = getFileContent (
70+ path . join ( fullPath , 'config' , 'commandPrompt.ejs' ) ,
71+ true ,
72+ ) ;
73+ } catch { }
74+ try {
75+ viewPrompt = getFileContent (
76+ path . join ( fullPath , 'config' , 'viewPrompt.ejs' ) ,
77+ true ,
78+ ) ;
79+ } catch { }
5980 if ( ! preview . img ) {
6081 preview . img =
6182 'https://gitee.com/img-host/img-host/raw/master/2020/11/05/1604587962875.jpg' ;
6283 }
6384 if ( ! preview . schema ) {
6485 preview . schema = 'form-render' ;
6586 }
87+ if ( ! commandPrompt ) {
88+ commandPrompt = preview . chatGPT ?. commandPrompt ;
89+ }
90+ if ( ! viewPrompt ) {
91+ viewPrompt = preview . chatGPT ?. viewPrompt ;
92+ }
93+
6694 if ( type === 'snippets' ) {
6795 try {
6896 template = getFileContent (
@@ -100,6 +128,8 @@ export const getLocalMaterials = (
100128 schema,
101129 preview,
102130 template,
131+ commandPrompt,
132+ viewPrompt,
103133 } ;
104134 } ) ;
105135 } catch { }
@@ -127,7 +157,7 @@ export const getCodeTemplateListFromFiles = () => {
127157} ;
128158
129159/**
130- * 获取 codeTemplate 目录下ejs文件作为代码模板并且合并代码片段
160+ * 获取 codeTemplate 目录下ejs文件作为代码模板并且合并代码片段 (兼容以前旧代码)
131161 *
132162 * @export
133163 * @returns
@@ -152,6 +182,8 @@ export function getSnippets() {
152182 viewPrompt ?: string ;
153183 } ;
154184 } ;
185+ commandPrompt ?: string ; // 优先级比 preview.chatGPT 高
186+ viewPrompt ?: string ; // 优先级比 preview.chatGPT 高
155187 template : string ;
156188 } [ ] = getCodeTemplateListFromFiles ( ) . map ( ( s ) => ( {
157189 path : s . name ,
0 commit comments