From 6d7f87914e971b93e2f4c27be7d0bafdf1cb34d1 Mon Sep 17 00:00:00 2001 From: super1207 Date: Wed, 28 Aug 2024 12:02:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E7=BD=91=E9=A1=B5=E6=88=AA=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- res/pkg_edit.html | 103 ++++++++++++++++++++++++++++--------------- src/redlang/exfun.rs | 9 +--- 2 files changed, 70 insertions(+), 42 deletions(-) diff --git a/res/pkg_edit.html b/res/pkg_edit.html index 9e3ef8c..b210cf3 100644 --- a/res/pkg_edit.html +++ b/res/pkg_edit.html @@ -14,11 +14,17 @@ padding: 0; } button,textarea,body,select,input{ - background-color: #c7eddf; + background-color: #e1ebe7; font-family: fusion-pixel-12px-monospaced-zh_hant, serif; } + button:hover { + background-color: aqua; + color: red; + cursor: pointer; + } .name_active { /* 点中名字,变色属性 */ color: red; + font-weight: bold; } @@ -29,23 +35,22 @@ -
- -
-
您有如下脚本
- - -
-
-

红色问答脚本编辑

+
+

编辑:{{pkg_name}}

-
- 当前选择的脚本: - +
+ +
无脚本,请点击[新增脚本]吧,亲~
+
可以拖拽调整显示顺序哦,亲~
-
+
脚本名:
@@ -53,7 +58,7 @@

红色问答脚本编辑

介绍: 
- @@ -67,11 +72,11 @@

红色问答脚本编辑

-
+
关键词:
- @@ -81,7 +86,7 @@

红色问答脚本编辑

-
+
@@ -110,14 +115,14 @@

红色问答脚本编辑

last_code:"", last_change_time:(new Date()).valueOf(), last_index:0, - select_name:"当前没有脚本", select_index:-1, pkg_codes:[], script_name:"", script_description:"", script_cffs:"", script_ppfs:"", - script_keyword:"" + script_keyword:"", + pkg_name:"" } }, mounted () { @@ -176,6 +181,8 @@

红色问答脚本编辑

} }); let pkg_name = getQueryVariable("pkg_name") + document.title = decodeURIComponent(pkg_name) + this.pkg_name = document.title if(pkg_name == encodeURIComponent("默认包")) { pkg_name = "" } @@ -200,27 +207,45 @@

红色问答脚本编辑

}); }, watch:{ - select_index:function(newval,oldval){ - console.log("select_index val change:" + newval) - if(newval == -1) { - this.select_name = "当前没有脚本" - }else { - this.select_name = this.pkg_codes[newval]["name"] - } - }, script_name:function(newval,oldval){ if(this.select_index != -1) { - this.select_name = newval + this.pkg_codes[this.select_index]['name'] = newval + // this.select_name = newval } } }, methods: { + //拖曳相關--str---↓↓-- + allowDrop(e) {//取消默認行為 + console.log("allowDrop" + e ) + e.preventDefault(); + }, + dragStart(e, index) {//拖曳開始 + console.log("dragStart:" + e + "," + index) + e.dataTransfer.setData('Text', index); + }, + drop(e, index) {//放置 + console.log("drop" + e + "," + index) + // this.allowDrop(e); + dragIndex = e.dataTransfer.getData('Text'); + if(dragIndex != index) { + let temp = this.pkg_codes[dragIndex] + this.pkg_codes[dragIndex] = this.pkg_codes[index] + this.pkg_codes[index] = temp; + if(this.select_index == dragIndex) { + this.select_index = index + }else if(this.select_index == index){ + this.select_index = dragIndex + } + } + }, + dragEnd() {//放置結束 + console.log("dragEnd"); + }, + //拖曳相關--end---↑↑-- cron(){ window.open("/crontool.html", "_blank"); }, - select_name_fun(){ - document.getElementById('favDialog').showModal(); - }, save(index){ this.pkg_codes[this.select_index]["content"]["code"] = this.$refs.child.getText() this.pkg_codes[index]["name"] = this.script_name @@ -252,12 +277,20 @@

红色问答脚本编辑

//console.log(this.$refs.child.getText()) }, + randomString(e) { + e = e || 32; + var t = "123456789", + a = t.length, + n = ""; + for (i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a)); + return n + }, add_code() { if(this.select_index != -1) { this.save(this.select_index) } let obj = { - name:"script_name", + name:"script_"+this.randomString(4), description:"code_description", content:{ code:"hello\n", diff --git a/src/redlang/exfun.rs b/src/redlang/exfun.rs index e48fd0d..fb8ef45 100644 --- a/src/redlang/exfun.rs +++ b/src/redlang/exfun.rs @@ -1913,7 +1913,8 @@ pub fn init_ex_fun_map() { let el_html= tab.wait_for_element("html")?; let body_height = el_html.get_box_model()?.height; let body_width = el_html.get_box_model()?.width; - tab.set_bounds(headless_chrome::types::Bounds::Normal { left: Some(0), top: Some(0), width:Some(body_width), height: Some(body_height) })?; + + tab.set_bounds(headless_chrome::types::Bounds::Normal { left: Some(0), top: Some(0), width:Some(body_width), height: Some(body_height + 200f64) })?; let mut el = el_html; if sec != ""{ el = tab.wait_for_element(&sec)?; @@ -1983,9 +1984,6 @@ pub fn init_ex_fun_map() { } tab.navigate_to(&path)?.wait_until_navigated()?; let el_html= tab.wait_for_element("html")?; - let body_height = el_html.get_box_model()?.height; - let body_width = el_html.get_box_model()?.width; - tab.set_bounds(headless_chrome::types::Bounds::Normal { left: Some(0), top: Some(0), width:Some(body_width), height: Some(body_height) })?; let mut el = el_html; if sec != ""{ el = tab.wait_for_element(&sec)?; @@ -2054,9 +2052,6 @@ pub fn init_ex_fun_map() { } tab.navigate_to(&path)?.wait_until_navigated()?; let el_html= tab.wait_for_element("html")?; - let body_height = el_html.get_box_model()?.height; - let body_width = el_html.get_box_model()?.width; - tab.set_bounds(headless_chrome::types::Bounds::Normal { left: Some(0), top: Some(0), width:Some(body_width), height: Some(body_height) })?; let mut el = el_html; if sec != ""{ el = tab.wait_for_element(&sec)?;