1919 <tiny-radio-group v-model =" state.variableType" :options =" VAR_TYPES" ></tiny-radio-group >
2020 </tiny-form-item >
2121 <tiny-collapse v-model =" state.activeName" >
22- <tiny-collapse-item title =" 初始值 " name =" initValue" >
22+ <tiny-collapse-item : title =" INIT " name =" initValue" >
2323 <tiny-form-item >
2424 <monaco-editor
2525 ref =" variableEditor"
2929 :options =" state.editorOptions"
3030 @editorDidMount =" editorDidMount"
3131 >
32- <template #toolbarStart >
33- <div class =" label-left-wrap" >
34- <tiny-popover
35- placement =" bottom-start"
36- effect =" dark"
37- trigger =" hover"
38- popper-class =" state-data-example-tips"
39- >
40- <div class =" tips-content" >
41- <div class =" create-content-head" >
42- <div class =" create-content-tip" >数据写法和JS写法一致</div >
43- </div >
44- <div class =" create-content-demo" >
45- <ul >
46- <li >字符串: "string"</li >
47- <li >数字: 123</li >
48- <li >布尔值: true/false</li >
49- <li >对象: {"name": "xxx"}</li >
50- <li >数组: ["1", "2"]</li >
51- <li >空值: null</li >
52- <li >JS表达式: (需要先选择JS表达式类型)</li >
53- <li class =" ml20" >示例1: t('i18nkey1')</li >
54- <li class =" ml20" >示例2: function fnName() {}</li >
55- <li class =" ml20" >示例3: { getValue: () => {} }</li >
56- </ul >
57- <div class =" create-content-foot" >
58- <div class =" create-content-tip" >
59- 注意:使用JS表达式定义state变量的时候无法调用state其他变量定义,<br />另由于JS函数定义在变量之后,也无法调用JS面板定义的函数
60- </div >
61- </div >
62- </div >
63- </div >
64- </tiny-popover >
65- </div >
66- </template >
6732 <template #buttons >
6833 <editor-i18n-tool ref =" i18nToolRef" @confirm =" insertContent" ></editor-i18n-tool >
6934 </template >
35+ <template #fullscreenHead >
36+ <state-fullscreen-head :title =" INIT" @close =" cancel" ></state-fullscreen-head >
37+ </template >
38+ <template #fullscreenFooter >
39+ <div class =" fullscreen-footer-content" >
40+ <state-tips ></state-tips >
41+ </div >
42+ </template >
7043 </monaco-editor >
71- <div class =" tips" >
72- <div >字符串:"string"</div >
73- <div >数字:123</div >
74- <div >布尔值:true/false</div >
75- <div >对象:{"name":"xxx"}</div >
76- <div >数组:["1","2"]</div >
77- <div >空值:null</div >
78- <div >"color":red</div >
79- <div >"background":"blue"</div >
80- </div >
44+ <state-tips ></state-tips >
8145 </tiny-form-item >
8246 </tiny-collapse-item >
83- <tiny-collapse-item title =" getter " name =" getter " >
47+ <tiny-collapse-item : title =" GETTER " : name =" GETTER " >
8448 <tiny-form-item >
8549 <monaco-editor ref =" getterEditor" class =" variable-editor" :options =" options" :value =" state.getterEditorValue" >
86- <template #toolbarStart >
87- <div class =" label-left-wrap" >
88- <tiny-popover placement =" bottom-start" trigger =" hover" popper-class =" state-data-example-tips" >
89- <div class =" tips-content" >
90- <div class =" create-content-demo" >
91- <pre ><code >{{ getterExample }}</code ></pre >
92- </div >
93- </div >
94- </tiny-popover >
50+ <template #fullscreenHead >
51+ <state-fullscreen-head :title =" GETTER" @close =" cancel" ></state-fullscreen-head >
52+ </template >
53+ <template #fullscreenFooter >
54+ <div class =" fullscreen-footer-content" >
55+ <div class =" tips" >
56+ <pre ><code >{{ getterExample }}</code ></pre >
57+ </div >
9558 </div >
9659 </template >
9760 </monaco-editor >
10063 </div >
10164 </tiny-form-item >
10265 </tiny-collapse-item >
103- <tiny-collapse-item title =" setter " name =" setter " >
66+ <tiny-collapse-item : title =" SETTER " : name =" SETTER " >
10467 <tiny-form-item >
10568 <monaco-editor ref =" setterEditor" class =" variable-editor" :options =" options" :value =" state.setterEditorValue" >
106- <template #toolbarStart >
107- <div class =" label-left-wrap" >
108- <tiny-popover placement =" bottom-start" trigger =" hover" popper-class =" state-data-example-tips" >
109- <div class =" tips-content" >
110- <div class =" create-content-demo" >
111- <pre ><code >{{ setterExample }}</code ></pre >
112- </div >
113- </div >
114- </tiny-popover >
69+ <template #fullscreenHead >
70+ <state-fullscreen-head :title =" SETTER" @close =" cancel" ></state-fullscreen-head >
71+ </template >
72+ <template #fullscreenFooter >
73+ <div class =" fullscreen-footer-content" >
74+ <div class =" tips" >
75+ <pre ><code >{{ setterExample }}</code ></pre >
76+ </div >
11577 </div >
11678 </template >
11779 </monaco-editor >
12789<script >
12890import { reactive , ref , computed , watch , onBeforeUnmount } from ' vue'
12991import {
130- Popover ,
13192 Form ,
13293 FormItem ,
13394 Input ,
@@ -141,14 +102,17 @@ import { initCompletion } from '@opentiny/tiny-engine-common/js/completion'
141102import * as Monaco from ' monaco-editor'
142103import { validateMonacoEditorData } from ' ./js/common'
143104import EditorI18nTool from ' ./EditorI18nTool.vue'
105+ import StateTips from ' ./StateTips.vue'
106+ import StateFullscreenHead from ' ./StateFullscreenHead.vue'
144107
145108export default {
146109 components: {
147110 MonacoEditor,
111+ StateTips,
112+ StateFullscreenHead,
148113 TinyForm: Form,
149114 TinyFormItem: FormItem,
150115 TinyInput: Input,
151- TinyPopover: Popover,
152116 TinyRadioGroup: RadioGroup,
153117 EditorI18nTool,
154118 TinyCollapse,
@@ -168,8 +132,11 @@ export default {
168132 type: String
169133 }
170134 },
171- emits: [' nameInput' ],
172- setup (props ) {
135+ emits: [' nameInput' , ' close' ],
136+ setup (props , { emit }) {
137+ const INIT = ' 初始值'
138+ const GETTER = ' getter'
139+ const SETTER = ' setter'
173140 const variableEditor = ref (null )
174141 const getterEditor = ref (null )
175142 const setterEditor = ref (null )
@@ -390,6 +357,10 @@ export default {
390357 monacoEditor .focus ()
391358 }
392359
360+ const cancel = () => {
361+ emit (' close' )
362+ }
363+
393364 const options = {
394365 lineNumbers: true ,
395366 language: ' javascript' ,
@@ -403,6 +374,9 @@ export default {
403374 " function setter() {\r\n // const [firstName, lastName] = this.state.name.split(' ')\r\n // this.emit('update:firstName', firstName)\r\n // this.emit('update:lastName', lastName)\r\n }" // eslint-disable-line
404375
405376 return {
377+ INIT ,
378+ GETTER ,
379+ SETTER ,
406380 state,
407381 VAR_TYPES ,
408382 variableEditor,
@@ -419,7 +393,8 @@ export default {
419393 editorDidMount,
420394 validate,
421395 getFormData,
422- insertContent
396+ insertContent,
397+ cancel
423398 }
424399 }
425400}
0 commit comments