Files
crawler-plugin/app/assets/appearance-patent.js
2026-05-06 00:01:49 +08:00

7 lines
16 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{d as De,o as xe,L as Ke,a as u,c as i,b,B as $e,e as t,F as X,r as Y,t as o,w as ce,G as de,f as h,V as Be,W as Le,X as Ge,Y as He,N as Me,n as ze,g as f,h as U,i as D,E as p,Z as qe,$ as je,U as pe,a0 as Ve,a1 as Oe,a2 as Je,a3 as Xe,a4 as Ye,a5 as Qe,_ as We,q as Ze,s as es}from"./pywebview-RBTI4RuH.js";/* empty css */import{e as ss}from"./brand-1lGM3Wzk.js";import{c as ts}from"./categorized-timers-JPA-olTr.js";const as={class:"page-shell module-page"},ls={class:"main-content"},ns={class:"left-panel"},os={class:"upload-zone"},rs={class:"selected-files"},us={key:0},is={class:"prompt-card"},cs={class:"secret-card"},ds={class:"run-row"},ps=["disabled"],fs=["disabled"],vs={key:0,class:"parse-card"},gs={key:1,class:"queue-payload"},ys={class:"right-panel"},hs={class:"task-list-wrap"},_s={class:"clean-result-summary"},ks={class:"summary-card"},ms={class:"summary-card"},ws={class:"summary-card"},Is={class:"summary-card"},Ss={class:"result-list-wrap preview-wrap"},bs={class:"result-list-header"},Cs={key:0,class:"muted"},Ps={key:0,class:"empty-tasks"},Fs={class:"result-list-wrap"},Ts={key:0,class:"empty-tasks"},Es={key:1,class:"task-list clean-result-list"},As={class:"left"},Ns={class:"id"},Rs={class:"files"},Us={class:"files"},Ds={class:"task-right"},xs={class:"status running"},Ks=["onClick"],$s={class:"result-list-wrap"},Bs={key:0,class:"empty-tasks"},Ls={key:1,class:"task-list clean-result-list"},Gs={class:"left"},Hs={class:"id"},Ms={class:"files"},zs={key:0,class:"files"},qs={key:1,class:"files result-hint"},js={key:2,class:"file-progress"},Vs={class:"file-progress-meta"},Os={class:"file-progress-track"},Js={class:"file-progress-count"},Xs={key:3,class:"files"},Ys={class:"task-right"},Qs=["onClick"],Ws=["onClick"],fe=`请帮我排查以下亚马逊商品在英国及欧洲地区是否存在知识产权侵权风险。
请直接给出明确结论(有侵权风险 或 未发现明显侵权风险),并严格按照以下三个维度提供精简的排查理由:
外观维度: 评估产品外形、图案设计是否与欧洲/英国常见外观专利雷同。
专利维度: 评估产品的核心技术或物理结构是否存在侵权可能。
标题维度: 排查标题中是否包含大牌商标、敏感词或版权保护词汇。
结论XX`,Zs=3e3,et=De({__name:"BrandAppearancePatentTab",setup(tt){const x=f([]),C=f([]),k=f(null),_=f([]),P=f(null),H=f(""),M=f(""),K=f(!1),$=f(!1),m=f(""),v=f([]),d=f([]),g=f(null),z=f(!1);let F=null,Q=0,T=!1;const E=ts("appearance-patent"),A=f({pendingTaskCount:0,processedTaskCount:0,successTaskCount:0,failedTaskCount:0}),y=f([]),w=U(()=>_.value.flatMap(e=>e.items||[])),W=U(()=>_.value[0]?.items||[]),I=U(()=>k.value||P.value),Z=U(()=>y.value.filter(e=>e.taskId!=null&&v.value.includes(e.taskId))),ee=U(()=>y.value.filter(e=>{const s=G(e);return s!=="RUNNING"&&s!=="PENDING"}));function se(){return H.value.trim()||fe}function q(){return M.value.trim()}function ve(e){return e?e.length<=10?"***":`${e.slice(0,6)}***${e.slice(-4)}`:""}function ge(e){return{...e,data:e.data?{...e.data,api_key:ve(String(e.data.api_key||""))}:e.data}}function ye(){return typeof window<"u"&&window.localStorage.getItem("uid")||"0"}function j(){return`appearance-patent:tasks:${ye()}`}function he(e){return{taskId:e.taskId,totalRows:e.totalRows,acceptedRows:e.acceptedRows,groupCount:e.groupCount,droppedRows:e.droppedRows}}function S(){if(typeof window>"u")return;const e=Array.from(new Set([...v.value,...d.value]));e.length?window.localStorage.setItem(j(),JSON.stringify(e)):window.localStorage.removeItem(j())}function _e(){if(!(typeof window>"u"))try{const e=window.localStorage.getItem(j()),s=e?JSON.parse(e):[];v.value=Array.isArray(s)?s.filter(l=>typeof l=="number"&&l>0):[]}catch{v.value=[]}}async function te(e){const s=D();if(!s?.upload_file_to_java)throw new Error("当前桌面端未提供文件上传能力");const l=[];for(const r of e){const a=typeof r=="string"?r:r.absolutePath,n=typeof r=="string"?void 0:r.relativePath,c=await s.upload_file_to_java(a,n);if(!c?.success||!c.data)throw new Error(c?.error||c?.message||`上传失败:${a}`);l.push(c.data)}return l}async function ke(){const e=D();if(!e?.select_brand_xlsx_files||!e.upload_file_to_java){p.warning("当前环境不支持文件选择或上传");return}const s=await e.select_brand_xlsx_files();if(!s?.length)return;const l=await te(s);C.value=l,x.value=l.map(r=>r.relativePath||r.originalFilename||r.fileKey),k.value=null,_.value=[],P.value=null,m.value=""}async function me(){const e=D();if(!e?.select_brand_folder){p.warning("当前环境不支持文件夹选择,请在本地客户端中打开");return}try{const s=await e.select_brand_folder();if(!s)return;const l=await ss(s);if(!l.success||!l.items?.length){p.warning(l.error||"该文件夹下没有可用的 xlsx 文件");return}const r=await te(l.items);C.value=r,x.value=l.items.map(a=>a.relativePath||a.absolutePath),k.value=null,_.value=[],P.value=null,m.value="",p.success(`已选择文件夹内 ${l.items.length} 个 Excel 文件`)}catch(s){p.error(s instanceof Error?s.message:"选择失败")}}async function we(){if(!C.value.length){p.warning("请先选择 Excel");return}if(!q()){p.warning("请先填写密钥");return}K.value=!0;try{const e=C.value.map(l=>({fileKey:l.fileKey,originalFilename:l.originalFilename,relativePath:l.relativePath})),s=await qe(e,se(),q());k.value=s,P.value=null,_.value=s.groups?.length?s.groups:s.items?.length?[{sourceFileKey:s.items[0]?.sourceFileKey,sourceFilename:s.items[0]?.sourceFilename,groupKey:s.items[0]?.groupKey,baseId:"",displayId:s.items[0]?.displayId,itemCount:s.items.length,items:s.items}]:[],m.value="",p.success(`解析完成,共 ${s.groupCount||0} 组 / ${s.acceptedRows}`)}catch(e){p.error(e instanceof Error?e.message:"解析失败")}finally{K.value=!1}}async function Ie(){const e=D(),s=k.value,l=s?.taskId;if(!l||!w.value.length){p.warning("请先解析文件");return}if(!e?.enqueue_json){p.error("当前环境未启用 pywebview enqueue_json");return}$.value=!0;try{const r={type:"appearance-patent-run",ts:Date.now(),data:{taskId:l,prompt:s.aiPrompt||se(),api_key:q(),groups:_.value.map(n=>({sourceFileKey:n.sourceFileKey||"",sourceFilename:n.sourceFilename||"",groupKey:n.groupKey||"",baseId:n.baseId||"",displayId:n.displayId||"",items:(n.items||[]).map(c=>({sourceFileKey:c.sourceFileKey||"",sourceFilename:c.sourceFilename||"",rowToken:c.rowToken||"",groupKey:c.groupKey||"",id:c.displayId,asin:c.asin,country:c.country,url:c.url||"",title:c.title||""}))})),rows:w.value.map(n=>({sourceFileKey:n.sourceFileKey||"",sourceFilename:n.sourceFilename||"",rowToken:n.rowToken||"",groupKey:n.groupKey||"",id:n.displayId,asin:n.asin,country:n.country,url:n.url||"",title:n.title||""}))}};m.value=JSON.stringify(ge(r),null,2),await je(l);const a=await e.enqueue_json(r);if(!a?.success){p.error(a?.error||"推送失败");return}P.value=he(s),be(l),Se(),await B(),await L({force:!0}),p.success("已推送到 Python 队列")}finally{$.value=!1}}function Se(){k.value=null,_.value=[],m.value=""}function be(e){v.value.includes(e)||(v.value=[...v.value,e],S()),N()}function V(e){v.value=v.value.filter(s=>s!==e),S()}function Ce(e){d.value.includes(e)||(d.value=[...d.value,e],S()),N()}function O(e){d.value=d.value.filter(s=>s!==e),S()}function N(){T||g.value==null&&Pe(!0)}function ae(){g.value!=null&&(E.clearTimer("task-poll",g.value),g.value=null)}function Pe(e=!1){if(T)return;if(g.value!=null){if(!e)return;E.clearTimer("task-poll",g.value),g.value=null}const s=async()=>{g.value=null,!T&&(!v.value.length&&!d.value.length||(await Fe(),!T&&g.value==null&&(v.value.length||d.value.length)&&(g.value=E.setTimeout("task-poll",s,pe()))))};e?s():g.value=E.setTimeout("task-poll",s,pe())}async function Fe(){if(z.value||!v.value.length&&!d.value.length){!v.value.length&&!d.value.length&&ae();return}z.value=!0;try{let e=!1,s=!1;const l=Array.from(new Set([...v.value,...d.value]));if(l.length){const r=await Qe(l,{force:d.value.length>0});for(const a of r.items||[]){const n=a.task;if(!n?.id)continue;const c=a.items?.[0];if(c&&Te(c),(n.status==="SUCCESS"||n.status==="FAILED")&&(V(n.id),e=!0,n.status==="SUCCESS"?Ce(n.id):O(n.id)),c&&n.status==="SUCCESS"&&d.value.includes(n.id)){const ie=(c.fileStatus||"").toUpperCase();(c.fileReady||ie==="SUCCESS"||ie==="FAILED")&&(O(n.id),e=!0,s=!0)}}r.missingTaskIds?.length&&(r.missingTaskIds.forEach(a=>{V(a),O(a)}),s=!0,e=!0)}e&&await B(),s&&await L(),Ee()}finally{z.value=!1}}function Te(e){if(!e.taskId&&!e.resultId)return;const s=y.value.findIndex(l=>e.resultId!=null&&l.resultId===e.resultId||e.taskId!=null&&l.taskId===e.taskId);s>=0?y.value[s]={...y.value[s],...e}:y.value=[e,...y.value]}function Ee(){if(!d.value.length)return;const e=[];for(const s of d.value){const l=y.value.find(n=>n.taskId===s);if(!l){e.push(s);continue}const r=(l.taskStatus||"").toUpperCase(),a=(l.fileStatus||"").toUpperCase();r==="FAILED"||l.fileReady||a==="SUCCESS"||a==="FAILED"||r==="SUCCESS"&&e.push(s)}d.value=e,S(),d.value.length&&N()}function Ae(){const e=y.value.filter(s=>s.taskId!=null&&R(s)).map(s=>s.taskId);d.value=Array.from(new Set(e)),S(),d.value.length&&N()}async function B(){A.value=await Ve()}async function L(e={}){const s=Date.now();if(!(!e.force&&y.value.length&&s-Q<Zs))return F||(F=Oe().then(l=>{y.value=l.items||[],Q=Date.now()}).finally(()=>{F=null}),F)}function le(e){const s=G(e);return s==="RUNNING"?"执行中":s==="PENDING"?"已解析待推送":R(e)?"结果生成中":J(e)?"结果生成失败":s==="SUCCESS"||e.success?"已完成":s==="FAILED"?"失败":"等待中"}function Ne(e){const s=G(e);return s==="RUNNING"||R(e)?"running":J(e)||s==="FAILED"?"failed":s==="SUCCESS"||e.success?"success":"pending"}function R(e){const s=G(e),l=(e.fileStatus||"").toUpperCase();return!(s!=="SUCCESS"||oe(e)||l==="FAILED"||l==="SUCCESS")}function G(e){return(e.taskStatus||"").toUpperCase()}function J(e){return(e.fileStatus||"").toUpperCase()==="FAILED"}function ne(e){if(J(e))return e.fileError||"结果文件生成失败,请稍后重试或检查后端日志";if(!R(e))return"";const s=(e.fileStatus||"").toUpperCase();return s==="RUNNING"?"任务已完成,正在请求 Coze 或组装结果文件,下载按钮稍后出现":s==="PENDING"?"任务已完成,结果文件已入队,正在等待后端生成":"任务已完成,正在生成结果文件,下载按钮稍后出现"}function oe(e){return!!(e.resultId&&(e.fileReady||e.downloadUrl))}function re(e){const s=Number(e.fileProgressPercent||0);return Number.isFinite(s)?Math.max(0,Math.min(100,Math.round(s))):0}function Re(e){return R(e)&&(e.fileProgressTotal||0)>0}async function Ue(e){if(!e.resultId)return;const s=D();if(!s?.save_file_from_url_new){p.error("当前客户端未提供下载能力");return}const l=e.downloadUrl||Je(e.resultId),r=e.resultFilename||`${e.sourceFilename||"appearance-patent"}.xlsx`,a=await s.save_file_from_url_new(l,r);a.success?p.success(`已保存: ${a.path||r}`):a.error&&a.error!=="用户取消"&&p.error(a.error)}async function ue(e){try{e.taskStatus==="RUNNING"&&e.taskId?(await Xe(e.taskId),V(e.taskId)):e.resultId&&await Ye(e.resultId),await B(),await L({force:!0}),p.success("已删除")}catch(s){p.error(s instanceof Error?s.message:"删除失败")}}return xe(async()=>{_e(),await Promise.all([B().catch(()=>{}),L().catch(()=>{})]),Ae(),(v.value.length||d.value.length)&&N()}),Ke(()=>{T=!0,ae(),E.clearScope()}),(e,s)=>{const l=Ge,r=He;return u(),i("div",as,[b($e,{active:"appearance-patent"}),t("div",ls,[t("aside",ns,[s[6]||(s[6]=t("div",{class:"section-title"},"上传文件",-1)),t("div",os,[s[2]||(s[2]=t("div",{class:"hint"},"选择 Excel 后点击解析,后端会提取 id、ASIN、国家并保留整数 id 与子数据的第一条。",-1)),t("div",{class:"btns"},[t("button",{type:"button",class:"opt-btn",onClick:ke},"选择 Excel"),t("button",{type:"button",class:"opt-btn",onClick:me},"选择文件夹")]),t("div",rs,[x.value.length?(u(!0),i(X,{key:1},Y(x.value,a=>(u(),i("span",{key:a},o(a),1))),128)):(u(),i("span",us,"暂未选择文件"))])]),t("div",is,[s[3]||(s[3]=t("div",{class:"section-title"},"AI 提示词",-1)),ce(t("textarea",{"onUpdate:modelValue":s[0]||(s[0]=a=>H.value=a),class:"prompt-input",rows:"8",placeholder:"可选,留空时使用下方默认提示词"},null,512),[[de,H.value]]),s[4]||(s[4]=t("div",{class:"prompt-default-label"},"留空时默认使用以下提示词",-1)),t("div",{class:"prompt-preview"},o(fe))]),t("div",cs,[s[5]||(s[5]=t("div",{class:"section-title"},"密钥",-1)),ce(t("input",{"onUpdate:modelValue":s[1]||(s[1]=a=>M.value=a),class:"secret-input",type:"password",autocomplete:"off",spellcheck:"false"},null,512),[[de,M.value]])]),t("div",ds,[t("button",{type:"button",class:"btn-run",disabled:K.value||!C.value.length,onClick:we},o(K.value?"解析中...":"解析并创建任务"),9,ps),t("button",{type:"button",class:"btn-run btn-queue",disabled:$.value||!w.value.length,onClick:Ie},o($.value?"推送中...":"推送到 Python 队列"),9,fs)]),s[7]||(s[7]=t("p",{class:"loading-msg"},"Python 回传字段按 asin、国家、url、标题提交后端接收分片后按 10 条一批调用 Coze。",-1)),I.value?(u(),i("div",vs,[t("div",null,"任务 ID"+o(I.value.taskId),1),t("div",null,"总行数:"+o(I.value.totalRows)+",有效:"+o(I.value.acceptedRows)+",分组:"+o(I.value.groupCount||0)+",过滤:"+o(I.value.droppedRows),1)])):h("",!0),m.value?(u(),i("pre",gs,o(m.value),1)):h("",!0)]),t("section",ys,[s[16]||(s[16]=t("div",{class:"panel-header"},"外观专利检测",-1)),t("div",hs,[t("div",_s,[t("div",ks,[s[8]||(s[8]=t("span",{class:"summary-label"},"运行中任务",-1)),t("strong",null,o(A.value.pendingTaskCount),1)]),t("div",ms,[s[9]||(s[9]=t("span",{class:"summary-label"},"已结束任务",-1)),t("strong",null,o(A.value.processedTaskCount),1)]),t("div",ws,[s[10]||(s[10]=t("span",{class:"summary-label"},"成功任务",-1)),t("strong",null,o(A.value.successTaskCount),1)]),t("div",Is,[s[11]||(s[11]=t("span",{class:"summary-label"},"失败任务",-1)),t("strong",null,o(A.value.failedTaskCount),1)])]),s[15]||(s[15]=t("div",{class:"subsection-title"},"匹配任务",-1)),t("div",Ss,[t("div",bs,[s[12]||(s[12]=t("span",null,"解析结果",-1)),w.value.length?(u(),i("span",Cs,"显示首组 "+o(W.value.length)+" 条 / 共 "+o(k.value?.groupCount||_.value.length)+" 组,"+o(w.value.length)+" 条",1)):h("",!0)]),w.value.length?(u(),Be(r,{key:1,data:W.value,height:"120",class:"result-table"},{default:Le(()=>[b(l,{prop:"displayId",label:"ID",width:"90"}),b(l,{prop:"asin",label:"ASIN",width:"130"}),b(l,{prop:"country",label:"国家",width:"100"}),b(l,{prop:"title",label:"标题","min-width":"160","show-overflow-tooltip":""}),b(l,{prop:"url",label:"URL","min-width":"160","show-overflow-tooltip":""})]),_:1},8,["data"])):(u(),i("div",Ps,"暂无解析结果"))]),t("div",Fs,[s[13]||(s[13]=t("div",{class:"result-list-header"},[t("span",null,"当前任务")],-1)),Z.value.length?(u(),i("ul",Es,[(u(!0),i(X,null,Y(Z.value,a=>(u(),i("li",{key:`cur-${a.taskId}`,class:"task-item"},[t("div",As,[t("span",Ns,o(a.sourceFilename||"外观专利检测"),1),t("div",Rs,"任务 ID"+o(a.taskId),1),t("div",Us,"行数:"+o(a.rowCount??"-"),1)]),t("div",Ds,[t("span",xs,o(le(a)),1),t("button",{type:"button",class:"btn-delete",onClick:n=>ue(a)},"删除",8,Ks)])]))),128))])):(u(),i("div",Ts,"暂无当前任务"))]),t("div",$s,[s[14]||(s[14]=t("div",{class:"result-list-header"},[t("span",null,"历史记录")],-1)),ee.value.length?(u(),i("ul",Ls,[(u(!0),i(X,null,Y(ee.value,a=>(u(),i("li",{key:`his-${a.resultId}-${a.taskId}`,class:"task-item"},[t("div",Gs,[t("span",Hs,o(a.sourceFilename||"外观专利检测"),1),t("div",Ms,"任务 ID"+o(a.taskId??"-"),1),a.resultFilename?(u(),i("div",zs,o(a.resultFilename||"下载结果"),1)):h("",!0),ne(a)?(u(),i("div",qs,o(ne(a)),1)):h("",!0),Re(a)?(u(),i("div",js,[t("div",Vs,[t("span",null,o(a.fileProgressMessage||"结果生成中"),1),t("span",null,o(re(a))+"%",1)]),t("div",Os,[t("div",{class:"file-progress-bar",style:Me({width:`${re(a)}%`})},null,4)]),t("div",Js,o(a.fileProgressCurrent||0)+"/"+o(a.fileProgressTotal||0),1)])):h("",!0),a.error?(u(),i("div",Xs,"错误:"+o(a.error),1)):h("",!0)]),t("div",Ys,[t("span",{class:ze(["status",Ne(a)])},o(le(a)),3),oe(a)?(u(),i("button",{key:0,type:"button",class:"download",onClick:n=>Ue(a)},"下载",8,Qs)):h("",!0),a.resultId?(u(),i("button",{key:1,type:"button",class:"btn-delete",onClick:n=>ue(a)},"删除",8,Ws)):h("",!0)])]))),128))])):(u(),i("div",Bs,"暂无历史记录"))])])])])])}}}),st=We(et,[["__scopeId","data-v-5682c4d5"]]);Ze(st).use(es).mount("#app");