Files

2 lines
10 KiB
JavaScript

import{k as j,l as E,o as S,b as c,d,w as l,c as s,g as e,f as a,h as r,t as x,j as u,e as y}from"./index.js";const T={style:{"margin-bottom":"8px"}},B={style:{"margin-bottom":"8px"}},H={style:{"margin-left":"8px"}},I={style:{"margin-bottom":"8px"}},N={style:{"margin-left":"8px"}},V={style:{"margin-bottom":"8px"}},D={style:{"font-size":"11px",color:"#8c8c8c","margin-top":"6px"}},G={key:0},K={key:1},L={key:2},M={style:{"margin-top":"16px"}},O={style:{"margin-bottom":"16px"}},W={style:{"margin-left":"8px"}},X={key:0,style:{"margin-bottom":"16px"}},q={style:{"margin-bottom":"16px"}},J={style:{"margin-bottom":"16px"}},Q={key:2,style:{"margin-bottom":"16px"}},R={style:{"margin-left":"8px"}},Y={style:{"margin-bottom":"16px"}},Z={style:{"margin-bottom":"16px"}},$={style:{"margin-bottom":"16px",padding:"12px",background:"#fafafa","border-radius":"6px"}},tt={style:{display:"flex","align-items":"center","justify-content":"space-between"}},ot={style:{"margin-bottom":"16px",padding:"12px",background:"#fafafa","border-radius":"6px"}},et={style:{display:"flex","align-items":"center","justify-content":"space-between"}},st={style:{padding:"12px",background:"#fff2f0","border-radius":"6px",border:"1px solid #ffccc7"}},nt={style:{display:"flex","align-items":"center","justify-content":"space-between"}},lt={style:{display:"flex","justify-content":"flex-end","margin-top":"24px"}},rt={__name:"browser",setup(it){const f=j(),o=E({path:"",headless:!1,fission:!0,humanizeCursor:!1,cssAnimation:!1,cssFilter:!1,cssFont:!1,proxyEnable:!1,proxyType:"http",proxyHost:"127.0.0.1",proxyPort:7890,proxyAuth:!1,proxyUser:"",proxyPasswd:""});S(async()=>{await f.fetchBrowserConfig();const i=f.browserConfig||{};o.path=i.path||"",o.headless=i.headless||!1,o.fission=i.fission!==!1,o.humanizeCursor=i.humanizeCursor??!1,i.cssInject&&(o.cssAnimation=i.cssInject.animation||!1,o.cssFilter=i.cssInject.filter||!1,o.cssFont=i.cssInject.font||!1),i.proxy&&(o.proxyEnable=i.proxy.enable||!1,o.proxyType=i.proxy.type||"http",o.proxyHost=i.proxy.host||"",o.proxyPort=i.proxy.port||7890,o.proxyAuth=i.proxy.auth||!1,o.proxyUser=i.proxy.username||"",o.proxyPasswd=i.proxy.password||"")});const k=async()=>{const i={path:o.path,headless:o.headless,cssInject:{animation:o.cssAnimation,filter:o.cssFilter,font:o.cssFont},fission:o.fission,humanizeCursor:o.humanizeCursor,proxy:{enable:o.proxyEnable,type:o.proxyType,host:o.proxyHost,port:o.proxyPort,auth:o.proxyAuth,username:o.proxyUser,password:o.proxyPasswd}};await f.saveBrowserConfig(i)};return(i,t)=>{const g=a("a-input"),p=a("a-col"),m=a("a-switch"),w=a("a-segmented"),b=a("a-row"),h=a("a-input-number"),C=a("a-input-password"),_=a("a-collapse-panel"),U=a("a-alert"),v=a("a-tag"),z=a("a-collapse"),P=a("a-button"),A=a("a-card"),F=a("a-layout");return d(),c(F,{style:{background:"transparent"}},{default:l(()=>[s(A,{title:"浏览器设置",bordered:!1,style:{width:"100%"}},{default:l(()=>[s(b,{gutter:[16,16]},{default:l(()=>[s(p,{xs:24,md:24},{default:l(()=>[e("div",T,[t[14]||(t[14]=e("div",{style:{"font-weight":"600","margin-bottom":"4px"}},"浏览器可执行文件路径",-1)),t[15]||(t[15]=e("div",{style:{"font-size":"12px",color:"#8c8c8c","margin-bottom":"8px"}},[r(" 留空则使用 Camoufox 默认下载路径"),e("br"),r(" Windows示例: C:\\camoufox\\camoufox.exe"),e("br"),r(" Linux示例: /opt/camoufox/camoufox ")],-1)),s(g,{value:o.path,"onUpdate:value":t[0]||(t[0]=n=>o.path=n),placeholder:"留空使用默认路径"},null,8,["value"])])]),_:1}),s(p,{xs:24,md:12},{default:l(()=>[e("div",B,[t[16]||(t[16]=e("div",{style:{"font-weight":"600","margin-bottom":"4px"}},"无头模式",-1)),t[17]||(t[17]=e("div",{style:{"font-size":"12px",color:"#8c8c8c","margin-bottom":"8px"}},[r(" 启用后浏览器无界面化运行"),e("br"),r(" 登录模式和 Xvfb 模式会无视该设置强行禁用无头模式 ")],-1)),s(m,{checked:o.headless,"onUpdate:checked":t[1]||(t[1]=n=>o.headless=n)},null,8,["checked"]),e("span",H,x(o.headless?"已启用":"未启用"),1)])]),_:1}),s(p,{xs:24,md:12},{default:l(()=>[e("div",I,[t[18]||(t[18]=e("div",{style:{"font-weight":"600","margin-bottom":"4px"}},"站点隔离 (fission.autostart)",-1)),t[19]||(t[19]=e("div",{style:{"font-size":"12px",color:"#8c8c8c","margin-bottom":"8px"}},[r(" 关闭可低内存占用,适合低配服务器"),e("br"),r(" 正常 FireFox 用户是默认开启的,请酌情关闭"),e("br"),e("span",{style:{color:"#faad14"}},"⚠️ 反爬检测可能通过检测单进程或者跨进程延迟来识别自动化特征")],-1)),s(m,{checked:o.fission,"onUpdate:checked":t[2]||(t[2]=n=>o.fission=n)},null,8,["checked"]),e("span",N,x(o.fission?"已启用":"已关闭 (省内存)"),1)])]),_:1}),s(p,{xs:24,md:24},{default:l(()=>[e("div",V,[t[20]||(t[20]=e("div",{style:{"font-weight":"600","margin-bottom":"4px"}},"拟人鼠标轨迹模式",-1)),t[21]||(t[21]=e("div",{style:{"font-size":"12px",color:"#8c8c8c","margin-bottom":"8px"}}," 控制鼠标点击的拟人化程度,影响性能和反爬检测风险 ",-1)),s(w,{value:o.humanizeCursor,"onUpdate:value":t[3]||(t[3]=n=>o.humanizeCursor=n),block:"",options:[{label:"禁用 (性能最佳)",value:!1},{label:"Ghost-Cursor (更拟人)",value:!0},{label:"Camoufox内置 (平衡)",value:"camou"}]},null,8,["value"]),e("div",D,[o.humanizeCursor===!1?(d(),u("span",G,"使用 Playwright 原生点击,性能最好,但可能被检测为自动化")):o.humanizeCursor===!0?(d(),u("span",K,"使用项目优化的 ghost-cursor 模拟人类鼠标轨迹(如不会点击正中心),性能稍差")):(d(),u("span",L,"使用 Camoufox 内置的 humanize 功能,性能与拟人化的平衡选择"))])])]),_:1})]),_:1}),e("div",M,[s(z,null,{default:l(()=>[s(_,{key:"proxy",header:"全局代理设置"},{default:l(()=>[t[28]||(t[28]=e("div",{style:{"font-size":"12px",color:"#8c8c8c","margin-bottom":"16px"}}," 如果实例没有独立配置代理,将使用此全局代理配置 ",-1)),e("div",O,[s(m,{checked:o.proxyEnable,"onUpdate:checked":t[4]||(t[4]=n=>o.proxyEnable=n)},null,8,["checked"]),e("span",W,x(o.proxyEnable?"已启用全局代理":"未启用全局代理"),1)]),o.proxyEnable?(d(),u("div",X,[t[22]||(t[22]=e("div",{style:{"font-weight":"600","margin-bottom":"8px"}},"代理类型",-1)),s(w,{value:o.proxyType,"onUpdate:value":t[5]||(t[5]=n=>o.proxyType=n),block:"",options:[{label:"HTTP",value:"http"},{label:"SOCKS5",value:"socks5"}]},null,8,["value"])])):y("",!0),o.proxyEnable?(d(),c(b,{key:1,gutter:16},{default:l(()=>[s(p,{xs:24,md:12},{default:l(()=>[e("div",q,[t[23]||(t[23]=e("div",{style:{"font-weight":"600","margin-bottom":"8px"}},"代理主机",-1)),s(g,{value:o.proxyHost,"onUpdate:value":t[6]||(t[6]=n=>o.proxyHost=n),placeholder:"例如: 127.0.0.1"},null,8,["value"])])]),_:1}),s(p,{xs:24,md:12},{default:l(()=>[e("div",J,[t[24]||(t[24]=e("div",{style:{"font-weight":"600","margin-bottom":"8px"}},"代理端口",-1)),s(h,{value:o.proxyPort,"onUpdate:value":t[7]||(t[7]=n=>o.proxyPort=n),min:1,max:65535,style:{width:"100%"},placeholder:"例如: 7890"},null,8,["value"])])]),_:1})]),_:1})):y("",!0),o.proxyEnable?(d(),u("div",Q,[t[25]||(t[25]=e("div",{style:{"font-weight":"600","margin-bottom":"8px"}},"代理认证",-1)),s(m,{checked:o.proxyAuth,"onUpdate:checked":t[8]||(t[8]=n=>o.proxyAuth=n)},null,8,["checked"]),e("span",R,x(o.proxyAuth?"需要认证":"无需认证"),1)])):y("",!0),o.proxyEnable&&o.proxyAuth?(d(),c(b,{key:3,gutter:16},{default:l(()=>[s(p,{xs:24,md:12},{default:l(()=>[e("div",Y,[t[26]||(t[26]=e("div",{style:{"font-weight":"600","margin-bottom":"8px"}},"用户名",-1)),s(g,{value:o.proxyUser,"onUpdate:value":t[9]||(t[9]=n=>o.proxyUser=n),placeholder:"请输入用户名"},null,8,["value"])])]),_:1}),s(p,{xs:24,md:12},{default:l(()=>[e("div",Z,[t[27]||(t[27]=e("div",{style:{"font-weight":"600","margin-bottom":"8px"}},"密码",-1)),s(C,{value:o.proxyPasswd,"onUpdate:value":t[10]||(t[10]=n=>o.proxyPasswd=n),placeholder:"请输入密码"},null,8,["value"])])]),_:1})]),_:1})):y("",!0)]),_:1}),s(_,{key:"cssInject",header:"CSS 性能优化注入"},{default:l(()=>[s(U,{message:"⚡ 适用于无 GPU 的服务器环境,通过禁用网页特效来降低 CPU 压力",type:"info","show-icon":"",style:{"margin-bottom":"16px"}}),e("div",$,[e("div",tt,[e("div",null,[t[30]||(t[30]=e("div",{style:{"font-weight":"600","margin-bottom":"4px"}},"禁用网页动画",-1)),t[31]||(t[31]=e("div",{style:{"font-size":"12px",color:"#8c8c8c"}}," 移除 transition 和 animation,显著降低 CPU 持续占用 ",-1)),s(v,{color:"green",style:{"margin-top":"6px"}},{default:l(()=>[...t[29]||(t[29]=[r("风险:低",-1)])]),_:1}),t[32]||(t[32]=e("span",{style:{"font-size":"11px",color:"#389e0d","margin-left":"8px"}}," 几乎不影响浏览器指纹,但可能导致部分网页布局异常 ",-1))]),s(m,{checked:o.cssAnimation,"onUpdate:checked":t[11]||(t[11]=n=>o.cssAnimation=n)},null,8,["checked"])])]),e("div",ot,[e("div",et,[e("div",null,[t[34]||(t[34]=e("div",{style:{"font-weight":"600","margin-bottom":"4px"}},"禁用滤镜和阴影",-1)),t[35]||(t[35]=e("div",{style:{"font-size":"12px",color:"#8c8c8c"}}," 移除 blur(模糊)、box-shadow(阴影) 等复杂渲染 ",-1)),s(v,{color:"orange",style:{"margin-top":"6px"}},{default:l(()=>[...t[33]||(t[33]=[r("风险:中",-1)])]),_:1}),t[36]||(t[36]=e("span",{style:{"font-size":"11px",color:"#faad14","margin-left":"8px"}}," 界面会变丑,少数反爬可能检测样式计算结果 ",-1))]),s(m,{checked:o.cssFilter,"onUpdate:checked":t[12]||(t[12]=n=>o.cssFilter=n)},null,8,["checked"])])]),e("div",st,[e("div",nt,[e("div",null,[t[38]||(t[38]=e("div",{style:{"font-weight":"600","margin-bottom":"4px"}},"降低字体渲染质量",-1)),t[39]||(t[39]=e("div",{style:{"font-size":"12px",color:"#8c8c8c"}}," 强制使用极速渲染模式,微量减少 CPU 绘图压力 ",-1)),s(v,{color:"red",style:{"margin-top":"6px"}},{default:l(()=>[...t[37]||(t[37]=[r("⚠️ 风险:高",-1)])]),_:1}),t[40]||(t[40]=e("div",{style:{"font-size":"11px",color:"#cf1322","margin-top":"4px"}}," 会导致文字边缘有锯齿,且可能导致字体指纹与标准浏览器不符,易被高级反爬识别 ",-1))]),s(m,{checked:o.cssFont,"onUpdate:checked":t[13]||(t[13]=n=>o.cssFont=n)},null,8,["checked"])])])]),_:1})]),_:1})]),e("div",lt,[s(P,{type:"primary",onClick:k},{default:l(()=>[...t[41]||(t[41]=[r(" 保存设置 ",-1)])]),_:1})])]),_:1})]),_:1})}}};export{rt as default};