更细粒度控制发送图片的触发时间,兼容py3.8

pull/23/head
zanllp 2023-04-13 02:18:03 +08:00
parent e6cae24f12
commit 3bcdc4e539
19 changed files with 27 additions and 24 deletions

View File

@ -8,7 +8,7 @@
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-8e57fc54.js"></script>
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-93bb8bfa.js"></script>
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-85d7437d.css">
</head>

View File

@ -239,7 +239,7 @@ def baidu_netdisk_api(_: Any, app: FastAPI):
return res
class DeleteFilesReq(BaseModel):
file_paths: list[str]
file_paths: List[str]
@app.post(pre+"/delete_files/{target}")
async def delete_files(req: DeleteFilesReq, target: Literal["local", "netdisk"]):
@ -255,7 +255,7 @@ def baidu_netdisk_api(_: Any, app: FastAPI):
exec_ops(["rm", *req.file_paths]) #没检查是否失败,暂时先这样
class MoveFilesReq(BaseModel):
file_paths: list[str]
file_paths: List[str]
dest: str
@app.post(pre+"/move_files/{target}")
@ -417,7 +417,7 @@ def baidu_netdisk_api(_: Any, app: FastAPI):
@app.get(pre+"/gen_info_completed")
async def api_set_send_img_path():
for _ in range(600): # 等待60s
if send_img_path["value"] == '':
if send_img_path["value"] == '': # 等待setup里面生成完成
return True
await asyncio.sleep(0.1)
return send_img_path["value"] == ''

View File

@ -20,24 +20,28 @@ def on_ui_tabs():
gr.HTML(
"如果你看到这个那说明此项那说明出现了问题", elem_id="baidu_netdisk_container_wrapper"
)
# 以下是使用2个组件模拟粘贴过程
img = gr.Image(
type="pil",
elem_id="bd_hidden_img",
)
def on_img_change():
send_img_path["value"] = '' # 真正收到图片改变才允许放行
img.change(on_img_change)
img_update_trigger = gr.Button("button", elem_id="bd_hidden_img_update_trigger")
# 修改文本和图像,等待修改完成后前端触发粘贴按钮
def img_update_func():
path = send_img_path.get("value")
geninfo,_ = extras.images.read_info_from_image(Image.open(path))
send_img_path["value"] = ''
return path, geninfo
img_file_info = gr.Textbox(elem_id="bd_hidden_img_file_info")
img_update_trigger.click(img_update_func, outputs=[img, img_file_info])
for tab in ["txt2img", "img2img", "inpaint", "extras"]:
btn = gr.Button(f"Send to {tab}", elem_id=f"bd_hidden_tab_{tab}")
# 注册粘贴
send.register_paste_params_button(
send.ParamBinding(
paste_button=btn,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
import{b as s}from"./index-63054365.js";import{bJ as n,aU as t}from"./index-8e57fc54.js";function i(e,o){return e&&e.length?n(e,s(o)):[]}const r=(e,o)=>(t.success({content:o??`已复制内容 "${e}" 到粘贴板`}),navigator.clipboard.writeText(e));export{r as c,i as u};
import{b as s}from"./index-84633439.js";import{bJ as n,aU as t}from"./index-93bb8bfa.js";function i(e,o){return e&&e.length?n(e,s(o)):[]}const r=(e,o)=>(t.success({content:o??`已复制内容 "${e}" 到粘贴板`}),navigator.clipboard.writeText(e));export{r as c,i as u};

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
import{u as p}from"./useTaskListStore-82b161eb.js";import{d as u,r as d,G as g,aj as f,ak as m,K as t,L as s,V as l,W as k,X as L,U as y,M as D,a2 as v}from"./index-8e57fc54.js";const x={class:"container"},h=u({__name:"logDetail",props:{logDetailId:null},setup(r){const n=r,c=p(),a=d(),o=g(()=>c.taskLogMap.get(n.logDetailId));return f(o,async()=>{await m();const e=a.value;e&&(e.scrollTop=e.scrollHeight)},{deep:!0}),(e,B)=>(t(),s("div",x,[l("ul",{class:"list",ref_key:"logListEl",ref:a},[(t(!0),s(k,null,L(D(o),(i,_)=>(t(),s("li",{key:_},[l("pre",null,y(i.log),1)]))),128))],512)]))}});const T=v(h,[["__scopeId","data-v-59148842"]]);export{T as default};
import{u as p}from"./useTaskListStore-ec084589.js";import{d as u,r as d,G as g,aj as f,ak as m,K as t,L as s,V as l,W as k,X as L,U as y,M as D,a2 as v}from"./index-93bb8bfa.js";const x={class:"container"},h=u({__name:"logDetail",props:{logDetailId:null},setup(r){const n=r,c=p(),a=d(),o=g(()=>c.taskLogMap.get(n.logDetailId));return f(o,async()=>{await m();const e=a.value;e&&(e.scrollTop=e.scrollHeight)},{deep:!0}),(e,B)=>(t(),s("div",x,[l("ul",{class:"list",ref_key:"logListEl",ref:a},[(t(!0),s(k,null,L(D(o),(i,_)=>(t(),s("li",{key:_},[l("pre",null,y(i.log),1)]))),128))],512)]))}});const T=v(h,[["__scopeId","data-v-59148842"]]);export{T as default};

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import{i as Te,I as P,t as Ee,f as Oe,C as Ne,a as je,r as ie,E as ke}from"./index-cf732d49.js";import{d as Q,u as te,G as q,_ as S,a as _,h as g,x as fe,P as $e,r as O,a4 as Re,bE as Ve,b as _e,c as ne,B as ae,A as De,al as U,ad as Ge,aj as Me,ak as J,y as He,f as Le,bF as Ue,bG as Ze,ao as Be,ah as Ye,H as qe,ag as ee,a8 as ge,D as Qe,i as We,bH as oe,bI as Xe}from"./index-8e57fc54.js";import{i as Ke}from"./index-10b7ef51.js";import{B as Je}from"./button-e07125db.js";const et=Q({compatConfig:{MODE:3},name:"AInputGroup",props:{prefixCls:String,size:{type:String},compact:{type:Boolean,default:void 0},onMouseenter:{type:Function},onMouseleave:{type:Function},onFocus:{type:Function},onBlur:{type:Function}},setup:function(e,t){var a=t.slots,c=te("input-group",e),p=c.prefixCls,f=c.direction,r=q(function(){var o,u=p.value;return o={},S(o,"".concat(u),!0),S(o,"".concat(u,"-lg"),e.size==="large"),S(o,"".concat(u,"-sm"),e.size==="small"),S(o,"".concat(u,"-compact"),e.compact),S(o,"".concat(u,"-rtl"),f.value==="rtl"),o});return function(){var o;return _("span",{class:r.value,onMouseenter:e.onMouseenter,onMouseleave:e.onMouseleave,onFocus:e.onFocus,onBlur:e.onBlur},[(o=a.default)===null||o===void 0?void 0:o.call(a)])}}});var le=/iPhone/i,me=/iPod/i,pe=/iPad/i,ue=/\bAndroid(?:.+)Mobile\b/i,he=/Android/i,Z=/\bAndroid(?:.+)SD4930UR\b/i,K=/\bAndroid(?:.+)(?:KF[A-Z]{2,4})\b/i,V=/Windows Phone/i,be=/\bWindows(?:.+)ARM\b/i,xe=/BlackBerry/i,ye=/BB10/i,Ce=/Opera Mini/i,ze=/\b(CriOS|Chrome)(?:.+)Mobile/i,Se=/Mobile(?:.+)Firefox\b/i;function i(l,e){return l.test(e)}function we(l){var e=l||(typeof navigator<"u"?navigator.userAgent:""),t=e.split("[FBAN");if(typeof t[1]<"u"){var a=t,c=fe(a,1);e=c[0]}if(t=e.split("Twitter"),typeof t[1]<"u"){var p=t,f=fe(p,1);e=f[0]}var r={apple:{phone:i(le,e)&&!i(V,e),ipod:i(me,e),tablet:!i(le,e)&&i(pe,e)&&!i(V,e),device:(i(le,e)||i(me,e)||i(pe,e))&&!i(V,e)},amazon:{phone:i(Z,e),tablet:!i(Z,e)&&i(K,e),device:i(Z,e)||i(K,e)},android:{phone:!i(V,e)&&i(Z,e)||!i(V,e)&&i(ue,e),tablet:!i(V,e)&&!i(Z,e)&&!i(ue,e)&&(i(K,e)||i(he,e)),device:!i(V,e)&&(i(Z,e)||i(K,e)||i(ue,e)||i(he,e))||i(/\bokhttp\b/i,e)},windows:{phone:i(V,e),tablet:i(be,e),device:i(V,e)||i(be,e)},other:{blackberry:i(xe,e),blackberry10:i(ye,e),opera:i(Ce,e),firefox:i(Se,e),chrome:i(ze,e),device:i(xe,e)||i(ye,e)||i(Ce,e)||i(Se,e)||i(ze,e)},any:null,phone:null,tablet:null};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}var tt=g(g({},we()),{},{isMobile:we});const nt=tt;var at=["disabled","loading","addonAfter","suffix"];const rt=Q({compatConfig:{MODE:3},name:"AInputSearch",inheritAttrs:!1,props:g(g({},Te()),{},{inputPrefixCls:String,enterButton:$e.any,onSearch:{type:Function}}),setup:function(e,t){var a=t.slots,c=t.attrs,p=t.expose,f=t.emit,r=O(),o=function(){var s;(s=r.value)===null||s===void 0||s.focus()},u=function(){var s;(s=r.value)===null||s===void 0||s.blur()};p({focus:o,blur:u});var y=function(s){f("update:value",s.target.value),s&&s.target&&s.type==="click"&&f("search",s.target.value,s),f("change",s)},h=function(s){var C;document.activeElement===((C=r.value)===null||C===void 0?void 0:C.input)&&s.preventDefault()},A=function(s){var C;f("search",(C=r.value)===null||C===void 0?void 0:C.stateValue,s),nt.tablet||r.value.focus()},I=te("input-search",e),T=I.prefixCls,k=I.getPrefixCls,N=I.direction,w=I.size,v=q(function(){return k("input",e.inputPrefixCls)});return function(){var m,s,C,M,R,B=e.disabled,j=e.loading,H=e.addonAfter,$=H===void 0?(m=a.addonAfter)===null||m===void 0?void 0:m.call(a):H,W=e.suffix,X=W===void 0?(s=a.suffix)===null||s===void 0?void 0:s.call(a):W,re=Re(e,at),b=e.enterButton,n=b===void 0?(C=(M=a.enterButton)===null||M===void 0?void 0:M.call(a))!==null&&C!==void 0?C:!1:b;n=n||n==="";var d=typeof n=="boolean"?_(Ve,null,null):null,x="".concat(T.value,"-button"),z=Array.isArray(n)?n[0]:n,E,L=z.type&&Ke(z.type)&&z.type.__ANT_BUTTON;if(L||z.tagName==="button")E=_e(z,g({onMousedown:h,onClick:A,key:"enterButton"},L?{class:x,size:w.value}:{}),!1);else{var D=d&&!n;E=_(Je,{class:x,type:n?"primary":void 0,size:w.value,disabled:B,key:"enterButton",onMousedown:h,onClick:A,loading:j,icon:D?d:null},{default:function(){return[D?null:d||n]}})}$&&(E=[E,$]);var G=ne(T.value,(R={},S(R,"".concat(T.value,"-rtl"),N.value==="rtl"),S(R,"".concat(T.value,"-").concat(w.value),!!w.value),S(R,"".concat(T.value,"-with-button"),!!n),R),c.class);return _(P,g(g(g({ref:r},ae(re,["onUpdate:value","onSearch","enterButton"])),c),{},{onPressEnter:A,size:w.value,prefixCls:v.value,addonAfter:E,suffix:X,onChange:y,class:G,disabled:B}),a)}}});var it=`
import{i as Te,I as P,t as Ee,f as Oe,C as Ne,a as je,r as ie,E as ke}from"./index-ed16943b.js";import{d as Q,u as te,G as q,_ as S,a as _,h as g,x as fe,P as $e,r as O,a4 as Re,bE as Ve,b as _e,c as ne,B as ae,A as De,al as U,ad as Ge,aj as Me,ak as J,y as He,f as Le,bF as Ue,bG as Ze,ao as Be,ah as Ye,H as qe,ag as ee,a8 as ge,D as Qe,i as We,bH as oe,bI as Xe}from"./index-93bb8bfa.js";import{i as Ke}from"./index-1fe59d75.js";import{B as Je}from"./button-81155cd9.js";const et=Q({compatConfig:{MODE:3},name:"AInputGroup",props:{prefixCls:String,size:{type:String},compact:{type:Boolean,default:void 0},onMouseenter:{type:Function},onMouseleave:{type:Function},onFocus:{type:Function},onBlur:{type:Function}},setup:function(e,t){var a=t.slots,c=te("input-group",e),p=c.prefixCls,f=c.direction,r=q(function(){var o,u=p.value;return o={},S(o,"".concat(u),!0),S(o,"".concat(u,"-lg"),e.size==="large"),S(o,"".concat(u,"-sm"),e.size==="small"),S(o,"".concat(u,"-compact"),e.compact),S(o,"".concat(u,"-rtl"),f.value==="rtl"),o});return function(){var o;return _("span",{class:r.value,onMouseenter:e.onMouseenter,onMouseleave:e.onMouseleave,onFocus:e.onFocus,onBlur:e.onBlur},[(o=a.default)===null||o===void 0?void 0:o.call(a)])}}});var le=/iPhone/i,me=/iPod/i,pe=/iPad/i,ue=/\bAndroid(?:.+)Mobile\b/i,he=/Android/i,Z=/\bAndroid(?:.+)SD4930UR\b/i,K=/\bAndroid(?:.+)(?:KF[A-Z]{2,4})\b/i,V=/Windows Phone/i,be=/\bWindows(?:.+)ARM\b/i,xe=/BlackBerry/i,ye=/BB10/i,Ce=/Opera Mini/i,ze=/\b(CriOS|Chrome)(?:.+)Mobile/i,Se=/Mobile(?:.+)Firefox\b/i;function i(l,e){return l.test(e)}function we(l){var e=l||(typeof navigator<"u"?navigator.userAgent:""),t=e.split("[FBAN");if(typeof t[1]<"u"){var a=t,c=fe(a,1);e=c[0]}if(t=e.split("Twitter"),typeof t[1]<"u"){var p=t,f=fe(p,1);e=f[0]}var r={apple:{phone:i(le,e)&&!i(V,e),ipod:i(me,e),tablet:!i(le,e)&&i(pe,e)&&!i(V,e),device:(i(le,e)||i(me,e)||i(pe,e))&&!i(V,e)},amazon:{phone:i(Z,e),tablet:!i(Z,e)&&i(K,e),device:i(Z,e)||i(K,e)},android:{phone:!i(V,e)&&i(Z,e)||!i(V,e)&&i(ue,e),tablet:!i(V,e)&&!i(Z,e)&&!i(ue,e)&&(i(K,e)||i(he,e)),device:!i(V,e)&&(i(Z,e)||i(K,e)||i(ue,e)||i(he,e))||i(/\bokhttp\b/i,e)},windows:{phone:i(V,e),tablet:i(be,e),device:i(V,e)||i(be,e)},other:{blackberry:i(xe,e),blackberry10:i(ye,e),opera:i(Ce,e),firefox:i(Se,e),chrome:i(ze,e),device:i(xe,e)||i(ye,e)||i(Ce,e)||i(Se,e)||i(ze,e)},any:null,phone:null,tablet:null};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}var tt=g(g({},we()),{},{isMobile:we});const nt=tt;var at=["disabled","loading","addonAfter","suffix"];const rt=Q({compatConfig:{MODE:3},name:"AInputSearch",inheritAttrs:!1,props:g(g({},Te()),{},{inputPrefixCls:String,enterButton:$e.any,onSearch:{type:Function}}),setup:function(e,t){var a=t.slots,c=t.attrs,p=t.expose,f=t.emit,r=O(),o=function(){var s;(s=r.value)===null||s===void 0||s.focus()},u=function(){var s;(s=r.value)===null||s===void 0||s.blur()};p({focus:o,blur:u});var y=function(s){f("update:value",s.target.value),s&&s.target&&s.type==="click"&&f("search",s.target.value,s),f("change",s)},h=function(s){var C;document.activeElement===((C=r.value)===null||C===void 0?void 0:C.input)&&s.preventDefault()},A=function(s){var C;f("search",(C=r.value)===null||C===void 0?void 0:C.stateValue,s),nt.tablet||r.value.focus()},I=te("input-search",e),T=I.prefixCls,k=I.getPrefixCls,N=I.direction,w=I.size,v=q(function(){return k("input",e.inputPrefixCls)});return function(){var m,s,C,M,R,B=e.disabled,j=e.loading,H=e.addonAfter,$=H===void 0?(m=a.addonAfter)===null||m===void 0?void 0:m.call(a):H,W=e.suffix,X=W===void 0?(s=a.suffix)===null||s===void 0?void 0:s.call(a):W,re=Re(e,at),b=e.enterButton,n=b===void 0?(C=(M=a.enterButton)===null||M===void 0?void 0:M.call(a))!==null&&C!==void 0?C:!1:b;n=n||n==="";var d=typeof n=="boolean"?_(Ve,null,null):null,x="".concat(T.value,"-button"),z=Array.isArray(n)?n[0]:n,E,L=z.type&&Ke(z.type)&&z.type.__ANT_BUTTON;if(L||z.tagName==="button")E=_e(z,g({onMousedown:h,onClick:A,key:"enterButton"},L?{class:x,size:w.value}:{}),!1);else{var D=d&&!n;E=_(Je,{class:x,type:n?"primary":void 0,size:w.value,disabled:B,key:"enterButton",onMousedown:h,onClick:A,loading:j,icon:D?d:null},{default:function(){return[D?null:d||n]}})}$&&(E=[E,$]);var G=ne(T.value,(R={},S(R,"".concat(T.value,"-rtl"),N.value==="rtl"),S(R,"".concat(T.value,"-").concat(w.value),!!w.value),S(R,"".concat(T.value,"-with-button"),!!n),R),c.class);return _(P,g(g(g({ref:r},ae(re,["onUpdate:value","onSearch","enterButton"])),c),{},{onPressEnter:A,size:w.value,prefixCls:v.value,addonAfter:E,suffix:X,onChange:y,class:G,disabled:B}),a)}}});var it=`
min-height:0 !important;
max-height:none !important;
height:0 !important;

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
import{cJ as r,r as e,J as t,aW as i,cK as d}from"./index-8e57fc54.js";const v=r("useTaskListStore",()=>{const a=e(new Map),n=t(new i),u=e(3),o=e([]),c=t([]),l=e(-1),s=e(null);return{checkBaiduyunInstalled:async()=>(s.value===null&&(s.value=d()),s.value),baiduyunInstalled:s,pollInterval:u,taskLogMap:a,queue:n,tasks:o,showDirAutoCompletedIdx:l,pendingBaiduyunTaskQueue:c}},{persist:{paths:["pollInterval","tasks"],key:"useTaskListStore-v0.0.1"}});export{v as u};
import{cJ as r,r as e,J as t,aW as i,cK as d}from"./index-93bb8bfa.js";const v=r("useTaskListStore",()=>{const a=e(new Map),n=t(new i),u=e(3),o=e([]),c=t([]),l=e(-1),s=e(null);return{checkBaiduyunInstalled:async()=>(s.value===null&&(s.value=d()),s.value),baiduyunInstalled:s,pollInterval:u,taskLogMap:a,queue:n,tasks:o,showDirAutoCompletedIdx:l,pendingBaiduyunTaskQueue:c}},{persist:{paths:["pollInterval","tasks"],key:"useTaskListStore-v0.0.1"}});export{v as u};

2
vue/dist/index.html vendored
View File

@ -7,7 +7,7 @@
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-8e57fc54.js"></script>
<script type="module" crossorigin src="/baidu_netdisk/fe-static/assets/index-93bb8bfa.js"></script>
<link rel="stylesheet" href="/baidu_netdisk/fe-static/assets/index-85d7437d.css">
</head>

View File

@ -663,7 +663,6 @@ export function useFileItemActions (props: Props, { openNext }: { openNext: (fil
const btn = gradioApp().querySelector('#bd_hidden_img_update_trigger')! as HTMLButtonElement
btn.click() // 触发图像组件更新
ok(await genInfoCompleted(), '图像信息生成超时') // 等待消息生成完成
await delay(300)
const tabBtn = gradioApp().querySelector(`#bd_hidden_tab_${tab}`) as HTMLButtonElement
tabBtn.click() // 触发粘贴
} catch (error) {