593593 < v-subheader >
594594 < h2 > 脚本编辑器</ h2 >
595595 < v-spacer > </ v-spacer >
596- < v-btn icon @click ="exeScript " :loading ="isLoading ">
596+ < v-btn icon @click ="runTxtScript " :loading ="isLoading ">
597597 < v-icon color ="primary "> mdi-play-circle</ v-icon >
598598 </ v-btn >
599599 </ v-subheader >
@@ -605,7 +605,7 @@ <h2>脚本编辑器</h2>
605605 < v-subheader >
606606 < h2 :style ="appTitleStyle "> {{curapp.name}}</ h2 >
607607 < v-spacer > </ v-spacer >
608- < v-btn v-if ="curapp.script " icon :loading ="isLoading " @click ="runScript (curapp.script, curapp.script_timeout) ">
608+ < v-btn v-if ="curapp.script " icon :loading ="isLoading " @click ="runRemoteScript (curapp.script, curapp.script_timeout) ">
609609 < v-icon color ="primary "> mdi-play-circle</ v-icon >
610610 </ v-btn >
611611 </ v-subheader >
@@ -631,7 +631,7 @@ <h2 :style="appTitleStyle">{{curapp.name}}</h2>
631631 < v-list-item-title >
632632 {{scriptIdx + 1}}. {{script.name}}
633633 </ v-list-item-title >
634- < v-btn icon :loading ="isLoading " @click.stop ="runScript (script.script, script.script_timeout) ">
634+ < v-btn icon :loading ="isLoading " @click.stop ="runRemoteScript (script.script, script.script_timeout) ">
635635 < v-icon > mdi-play-circle</ v-icon >
636636 </ v-btn >
637637 </ v-list-item >
@@ -1147,25 +1147,25 @@ <h2>{{curbak.name}}</h2>
11471147 < v-btn dark v-if ="!box.usercfgs.isHideRefresh " fab small color ="orange " @click ="reload() ">
11481148 < v-icon > mdi-refresh</ v-icon >
11491149 </ v-btn >
1150- < v-btn dark v-if ="!box.usercfgs.isHideCoding " fab small @click ="path = '/#/ coding' ">
1150+ < v-btn dark v-if ="!box.usercfgs.isHideCoding " fab small @click ="switchView(' coding') ">
11511151 < v-icon > mdi-code-tags</ v-icon >
11521152 </ v-btn >
11531153 < v-btn dark v-if ="!box.usercfgs.isHidedSearch " fab small color ="green " @click ="ui.searchDialog.show = true ">
11541154 < v-icon > mdi-magnify</ v-icon >
11551155 </ v-btn >
11561156 </ v-speed-dial >
11571157 </ v-fab-transition >
1158- < v-bottom-sheet v-model ="ui.versionsheet.show " scrollable >
1158+ < v-bottom-sheet v-model ="ui.versionsheet.show " scrollable fullscreen >
11591159 < v-card v-if ="box.versions ">
1160- < v-subheader >
1160+ < v-subheader v-touch =" { down: () => ui.versionsheet.show = false } " >
11611161 < v-btn icon small @click ="open('https://chavyleung.gitbook.io/boxjs/base/upgrade') ">
11621162 < v-icon > mdi-help-circle</ v-icon >
11631163 </ v-btn >
11641164 < v-spacer > </ v-spacer >
11651165 < v-btn text small v-if ="hasNewVersion "> 新版本</ v-btn >
11661166 < v-spacer > </ v-spacer >
11671167 < v-btn icon small @click ="ui.versionsheet.show = false ">
1168- < v-icon > mdi-close </ v-icon >
1168+ < v-icon > mdi-chevron-double-down </ v-icon >
11691169 </ v-btn >
11701170 </ v-subheader >
11711171 < v-divider > </ v-divider >
@@ -1182,21 +1182,21 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
11821182 </ v-card-text >
11831183 </ v-card >
11841184 </ v-bottom-sheet >
1185- < v-bottom-sheet v-model ="ui.exeScriptSheet.show " scrollable >
1185+ < v-bottom-sheet v-model ="ui.exeScriptSheet.show " scrollable fullscreen >
11861186 < v-card >
1187- < v-card-title >
1187+ < v-card-title v-touch =" { down: () => ui.exeScriptSheet.show = false } " >
11881188 执行结果
11891189 < v-spacer > </ v-spacer >
11901190 < v-btn icon @click ="ui.exeScriptSheet.show = false ">
1191- < v-icon > mdi-close </ v-icon >
1191+ < v-icon > mdi-chevron-double-down </ v-icon >
11921192 </ v-btn >
11931193 </ v-card-title >
11941194 < v-divider > </ v-divider >
11951195 < v-card-text style ="height: 80%; ">
11961196 < div class ="mt-4 " v-if ="ui.exeScriptSheet.resp ">
11971197 < p class ="text-pre-wrap " v-if ="ui.exeScriptSheet.resp.exception " v-text ="ui.exeScriptSheet.resp.exception "> </ p >
11981198 < p class ="text-pre-wrap " v-else-if ="ui.exeScriptSheet.resp.output " v-text ="ui.exeScriptSheet.resp.output "> </ p >
1199- < p v-else v-text ="ui.exeScriptSheet.resp "> </ p >
1199+ < p v-else v-text ="JSON.stringify( ui.exeScriptSheet.resp) "> </ p >
12001200 </ div >
12011201 </ v-card-text >
12021202 </ v-card >
@@ -1645,9 +1645,7 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
16451645 ' * 这段脚本是可以直接运行的!' ,
16461646 ' */ ' ,
16471647 'const host = $.getdata("boxjs_host")' ,
1648- '$.json = {' ,
1649- ' msg: "这段 json 是返回给浏览器的!"' ,
1650- '}' ,
1648+ 'console.log("输出的内容是返回给浏览器的!")' ,
16511649 '$.msg($.name, host)' ,
16521650 '$.done()' ,
16531651 '// $done() 或 $.done() 都可以'
@@ -1675,7 +1673,7 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
16751673 this . ui . editor = monaco . editor . create ( document . getElementById ( 'container' ) , {
16761674 fontSize : 12 ,
16771675 tabSize : 2 ,
1678- value : this . box . usercfgs . httpapi ? surgejs_demo . join ( '\n' ) : envjs_demo . join ( '\n' ) ,
1676+ value : this . env === 'Surge' && this . box . usercfgs . httpapi ? surgejs_demo . join ( '\n' ) : envjs_demo . join ( '\n' ) ,
16791677 language : 'javascript' ,
16801678 minimap : { enabled : false } ,
16811679 theme : this . isDarkMode ? 'vs-dark' : 'vs'
@@ -1988,24 +1986,20 @@ <h2 :class="version === ver.version ? 'primary--text' : undefined">v{{ver.versio
19881986 app . isLoaded = true
19891987 } ,
19901988 // 运行远程脚本
1991- runScript ( url , timeout ) {
1989+ runRemoteScript ( url , timeout ) {
19921990 const opts = { url, timeout, isRemote : true }
1993- axios . post ( '/api/runScript' , opts ) . then ( ( resp ) => {
1994- if ( this . box . usercfgs . httpapi ) {
1995- this . ui . exeScriptSheet . resp = JSON . parse ( resp . data )
1996- this . ui . exeScriptSheet . show = true
1997- }
1998- } )
1991+ this . runScript ( opts )
19991992 } ,
20001993 // 运行文本脚本
2001- exeScript ( ) {
1994+ runTxtScript ( ) {
20021995 const script = this . ui . editor . getValue ( )
20031996 const opts = { script }
1997+ this . runScript ( opts )
1998+ } ,
1999+ runScript ( opts ) {
20042000 axios . post ( '/api/runScript' , opts ) . then ( ( resp ) => {
2005- if ( this . box . usercfgs . httpapi ) {
2006- this . ui . exeScriptSheet . resp = JSON . parse ( resp . data )
2007- this . ui . exeScriptSheet . show = true
2008- }
2001+ this . ui . exeScriptSheet . resp = resp . data
2002+ this . ui . exeScriptSheet . show = true
20092003 } )
20102004 } ,
20112005 // 保存用户偏好
0 commit comments