Spaces:
Paused
Paused
fix: rotate 只在最后统一同步 CPA 和打印状态表
Browse files- sync_to_cpa 移到 finally 里,中途不同步避免 CPA 不可用
- 去掉提前 return 路径的重复 _print_status_table
- 前端任务轮询改为 30s(减少 API 日志刷屏)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Files changed (4)
984 unmodified lines98598698798898999099199269 unmodified lines106210631064106510661067106810697 unmodified lines1077107810791080108110821083108410851086984 unmodified linesif vacancies <= 0:logger.info("[4/5] Team 已满 (%d/%d)", current_count, TARGET)sync_to_cpa()_print_status_table(load_accounts())returnlogger.info("[4/5] 填补 %d 个空缺 (当前 %d/%d)...", vacancies, current_count, TARGET)69 unmodified linesremaining = vacancies - filledif remaining <= 0:logger.info("[4/5] 已用旧账号填满空缺")sync_to_cpa()_print_status_table(load_accounts())return# 必须创建新号7 unmodified linesfinally:if chatgpt and chatgpt.browser:chatgpt.stop()logger.info("[轮转] 轮转完成")sync_to_cpa()_print_status_table(load_accounts())def cmd_add():984 unmodified lines98598698798898999069 unmodified lines1060106110621063106410657 unmodified lines1073107410751076107710781079108010811082984 unmodified linesif vacancies <= 0:logger.info("[4/5] Team 已满 (%d/%d)", current_count, TARGET)returnlogger.info("[4/5] 填补 %d 个空缺 (当前 %d/%d)...", vacancies, current_count, TARGET)69 unmodified linesremaining = vacancies - filledif remaining <= 0:logger.info("[4/5] 已用旧账号填满空缺")return# 必须创建新号7 unmodified linesfinally:if chatgpt and chatgpt.browser:chatgpt.stop()# 所有操作完成后统一同步 CPA,避免中途同步导致 CPA 不可用logger.info("[轮转] 轮转完成,同步 CPA...")sync_to_cpa()_print_status_table(load_accounts())def cmd_add():
13 unmodified lines1415161713 unmodified lines* @vue/runtime-dom v3.5.32* (c) 2018-present Yuxi (Evan) You and Vue contributors* @license MIT**/let Hs;const Mn=typeof window<"u"&&window.trustedTypes;if(Mn)try{Hs=Mn.createPolicy("vue",{createHTML:e=>e})}catch{}const zr=Hs?e=>Hs.createHTML(e):e=>e,Zo="http://www.w3.org/2000/svg",Qo="http://www.w3.org/1998/Math/MathML",je=typeof document<"u"?document:null,Rn=je&&je.createElement("template"),el={insert:(e,t,s)=>{t.insertBefore(e,s||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,s,n)=>{const r=t==="svg"?je.createElementNS(Zo,e):t==="mathml"?je.createElementNS(Qo,e):s?je.createElement(e,{is:s}):je.createElement(e);return e==="select"&&n&&n.multiple!=null&&r.setAttribute("multiple",n.multiple),r},createText:e=>je.createTextNode(e),createComment:e=>je.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>je.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,s,n,r,i){const o=s?s.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),s),!(r===i||!(r=r.nextSibling)););else{Rn.innerHTML=zr(n==="svg"?`<svg>${e}</svg>`:n==="mathml"?`<math>${e}</math>`:e);const l=Rn.content;if(n==="svg"||n==="mathml"){const c=l.firstChild;for(;c.firstChild;)l.appendChild(c.firstChild);l.removeChild(c)}t.insertBefore(l,s)}return[o?o.nextSibling:t.firstChild,s?s.previousSibling:t.lastChild]}},tl=Symbol("_vtc");function sl(e,t,s){const n=e[tl];n&&(t=(t?[t,...n]:[...n]).join(" ")),t==null?e.removeAttribute("class"):s?e.setAttribute("class",t):e.className=t}const In=Symbol("_vod"),nl=Symbol("_vsh"),rl=Symbol(""),il=/(?:^|;)\s*display\s*:/;function ol(e,t,s){const n=e.style,r=Z(s);let i=!1;if(s&&!r){if(t)if(Z(t))for(const o of t.split(";")){const l=o.slice(0,o.indexOf(":")).trim();s[l]==null&&Yt(n,l,"")}else for(const o in t)s[o]==null&&Yt(n,o,"");for(const o in s)o==="display"&&(i=!0),Yt(n,o,s[o])}else if(r){if(t!==s){const o=n[rl];o&&(s+=";"+o),n.cssText=s,i=il.test(s)}}else t&&e.removeAttribute("style");In in e&&(e[In]=i?n.display:"",e[nl]&&(n.display="none"))}const Fn=/\s*!important$/;function Yt(e,t,s){if(R(s))s.forEach(n=>Yt(e,t,n));else if(s==null&&(s=""),t.startsWith("--"))e.setProperty(t,s);else{const n=ll(e,t);Fn.test(s)?e.setProperty(st(n),s.replace(Fn,""),"important"):e[n]=s}}const Dn=["Webkit","Moz","ms"],Cs={};function ll(e,t){const s=Cs[t];if(s)return s;let n=_e(t);if(n!=="filter"&&n in e)return Cs[t]=n;n=Xn(n);for(let r=0;r<Dn.length;r++){const i=Dn[r]+n;if(i in e)return Cs[t]=i}return t}const jn="http://www.w3.org/1999/xlink";function Nn(e,t,s,n,r,i=ci(t)){n&&t.startsWith("xlink:")?s==null?e.removeAttributeNS(jn,t.slice(6,t.length)):e.setAttributeNS(jn,t,s):s==null||i&&!Qn(s)?e.removeAttribute(t):e.setAttribute(t,i?"":Ie(s)?String(s):s)}function Hn(e,t,s,n,r){if(t==="innerHTML"||t==="textContent"){s!=null&&(e[t]=t==="innerHTML"?zr(s):s);return}const i=e.tagName;if(t==="value"&&i!=="PROGRESS"&&!i.includes("-")){const l=i==="OPTION"?e.getAttribute("value")||"":e.value,c=s==null?e.type==="checkbox"?"on":"":String(s);(l!==c||!("_value"in e))&&(e.value=c),s==null&&e.removeAttribute(t),e._value=s;return}let o=!1;if(s===""||s==null){const l=typeof e[t];l==="boolean"?s=Qn(s):s==null&&l==="string"?(s="",o=!0):l==="number"&&(s=0,o=!0)}try{e[t]=s}catch{}o&&e.removeAttribute(r||t)}function it(e,t,s,n){e.addEventListener(t,s,n)}function cl(e,t,s,n){e.removeEventListener(t,s,n)}const Ln=Symbol("_vei");function fl(e,t,s,n,r=null){const i=e[Ln]||(e[Ln]={}),o=i[t];if(n&&o)o.value=n;else{const[l,c]=ul(t);if(n){const d=i[t]=hl(n,r);it(e,l,d,c)}else o&&(cl(e,l,o,c),i[t]=void 0)}}const kn=/(?:Once|Passive|Capture)$/;function ul(e){let t;if(kn.test(e)){t={};let n;for(;n=e.match(kn);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):st(e.slice(2)),t]}let Es=0;const al=Promise.resolve(),dl=()=>Es||(al.then(()=>Es=0),Es=Date.now());function hl(e,t){const s=n=>{if(!n._vts)n._vts=Date.now();else if(n._vts<=s.attached)return;Fe(pl(n,s.value),t,5,[n])};return s.value=e,s.attached=dl(),s}function pl(e,t){if(R(t)){const s=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{s.call(e),e._stopped=!0},t.map(n=>r=>!r._stopped&&n&&n(r))}else return t}const Vn=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,gl=(e,t,s,n,r,i)=>{const o=r==="svg";t==="class"?sl(e,n,o):t==="style"?ol(e,s,n):ns(t)?rs(t)||fl(e,t,s,n,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):ml(e,t,n,o))?(Hn(e,t,n),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Nn(e,t,n,o,i,t!=="value")):e._isVueCE&&(bl(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!Z(n)))?Hn(e,_e(t),n,i,t):(t==="true-value"?e._trueValue=n:t==="false-value"&&(e._falseValue=n),Nn(e,t,n,o))};function ml(e,t,s,n){if(n)return!!(t==="innerHTML"||t==="textContent"||t in e&&Vn(t)&&I(s));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return Vn(t)&&Z(s)?!1:t in e}function bl(e,t){const s=e._def.props;if(!s)return!1;const n=_e(t);return Array.isArray(s)?s.some(r=>_e(r)===n):Object.keys(s).some(r=>_e(r)===n)}const Un=e=>{const t=e.props["onUpdate:modelValue"]||!1;return R(t)?s=>Wt(t,s):t};function yl(e){e.target.composing=!0}function Kn(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const As=Symbol("_assign");function Bn(e,t,s){return t&&(e=e.trim()),s&&(e=Us(e)),e}const zt={created(e,{modifiers:{lazy:t,trim:s,number:n}},r){e[As]=Un(r);const i=n||r.props&&r.props.type==="number";it(e,t?"change":"input",o=>{o.target.composing||e[As](Bn(e.value,s,i))}),(s||i)&&it(e,"change",()=>{e.value=Bn(e.value,s,i)}),t||(it(e,"compositionstart",yl),it(e,"compositionend",Kn),it(e,"change",Kn))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:s,modifiers:{lazy:n,trim:r,number:i}},o){if(e[As]=Un(o),e.composing)return;const l=(i||e.type==="number")&&!/^0\d/.test(e.value)?Us(e.value):e.value,c=t??"";if(l===c)return;const d=e.getRootNode();(d instanceof Document||d instanceof ShadowRoot)&&d.activeElement===e&&e.type!=="range"&&(n&&t===s||r&&e.value.trim()===c)||(e.value=c)}},_l=ne({patchProp:gl},el);let Wn;function xl(){return Wn||(Wn=Ro(_l))}const vl=((...e)=>{const t=xl().createApp(...e),{mount:s}=t;return t.mount=n=>{const r=Sl(n);if(!r)return;const i=t._component;!I(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=s(r,!1,wl(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},t});function wl(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function Sl(e){return Z(e)?document.querySelector(e):e}const Tl="/api";async function ie(e,t,s=null){var o;const n={method:e,headers:{"Content-Type":"application/json"}};s&&(n.body=JSON.stringify(s));const r=await fetch(`${Tl}${t}`,n),i=await r.json();if(!r.ok){const l=((o=i==null?void 0:i.detail)==null?void 0:o.message)||(i==null?void 0:i.detail)||`HTTP ${r.status}`;throw new Error(l)}return i}const dt={getStatus:()=>ie("GET","/status"),getAccounts:()=>ie("GET","/accounts"),getActiveAccounts:()=>ie("GET","/accounts/active"),getStandbyAccounts:()=>ie("GET","/accounts/standby"),getCpaFiles:()=>ie("GET","/cpa/files"),postSync:()=>ie("POST","/sync"),startRotate:(e=5)=>ie("POST","/tasks/rotate",{target:e}),startCheck:()=>ie("POST","/tasks/check"),startAdd:()=>ie("POST","/tasks/add"),startFill:(e=5)=>ie("POST","/tasks/fill",{target:e}),startCleanup:(e=null)=>ie("POST","/tasks/cleanup",{max_seats:e}),getTasks:()=>ie("GET","/tasks"),getTask:e=>ie("GET",`/tasks/${e}`),getAutoCheckConfig:()=>ie("GET","/config/auto-check"),setAutoCheckConfig:e=>ie("PUT","/config/auto-check",e)},Cl={key:0},El={class:"grid grid-cols-2 sm:grid-cols-4 gap-4 mb-6"},Al={class:"text-sm text-gray-400"},Ol={class:"bg-gray-900 border border-gray-800 rounded-xl overflow-hidden"},Pl={class:"overflow-x-auto"},$l={class:"w-full text-sm"},Ml={class:"px-4 py-3 text-gray-500"},Rl={class:"px-4 py-3 font-mono text-xs"},Il={class:"px-4 py-3"},Fl={class:"px-4 py-3 text-gray-400 text-xs"},Dl={class:"px-4 py-3 text-gray-400 text-xs"},jl={key:1,class:"space-y-4"},Nl={class:"grid grid-cols-2 sm:grid-cols-4 gap-4"},Hl={__name:"Dashboard",props:{status:Object,loading:Boolean},setup(e){const t=e,s=Yr(()=>{if(!t.status)return[];const u=t.status.summary;return[{label:"活跃",value:u.active,color:"text-green-400"},{label:"待命",value:u.standby,color:"text-yellow-400"},{label:"额度用完",value:u.exhausted,color:"text-red-400"},{label:"总计",value:u.total,color:"text-white"}]});function n(u){return{active:"bg-green-500/10 text-green-400",exhausted:"bg-red-500/10 text-red-400",standby:"bg-yellow-500/10 text-yellow-400",pending:"bg-gray-500/10 text-gray-400"}[u]||"bg-gray-500/10 text-gray-400"}function r(u){return{active:"bg-green-400",exhausted:"bg-red-400",standby:"bg-yellow-400",pending:"bg-gray-400"}[u]||"bg-gray-400"}function i(u){return{active:"Active",exhausted:"Used up",standby:"Standby",pending:"Pending"}[u]||u}function o(u,h){var $,E;const m=((E=($=t.status)==null?void 0:$.quota_cache)==null?void 0:E[u.email])||u.last_quota;return m?100-((h==="primary"?m.primary_pct:m.weekly_pct)||0):null}function l(u,h){const m=o(u,h);return m!==null?`${m}%`:"-"}function c(u,h){var E,q;const m=((q=(E=t.status)==null?void 0:E.quota_cache)==null?void 0:q[u.email])||u.last_quota;if(!m)return"-";const T=h==="primary"?m.primary_resets_at:m.weekly_resets_at;if(!T)return"-";const $=new Date(T*1e3);return`${String($.getMonth()+1).padStart(2,"0")}-${String($.getDate()).padStart(2,"0")} ${String($.getHours()).padStart(2,"0")}:${String($.getMinutes()).padStart(2,"0")}`}function d(u){return u===null?"text-gray-500":u>30?"text-green-400":u>0?"text-yellow-400":"text-red-400"}return(u,h)=>e.status?(Y(),z("div",Cl,[x("div",El,[(Y(!0),z(ae,null,Ct(s.value,m=>(Y(),z("div",{key:m.label,class:"bg-gray-900 border border-gray-800 rounded-xl p-4"},[x("div",Al,B(m.label),1),x("div",{class:pe(["text-3xl font-bold mt-1",m.color])},B(m.value),3)]))),128))]),x("div",Ol,[h[1]||(h[1]=x("div",{class:"px-4 py-3 border-b border-gray-800"},[x("h2",{class:"text-lg font-semibold text-white"},"账号列表")],-1)),x("div",Pl,[x("table",$l,[h[0]||(h[0]=x("thead",null,[x("tr",{class:"text-gray-400 text-left border-b border-gray-800"},[x("th",{class:"px-4 py-3 font-medium"},"#"),x("th",{class:"px-4 py-3 font-medium"},"邮箱"),x("th",{class:"px-4 py-3 font-medium"},"状态"),x("th",{class:"px-4 py-3 font-medium text-right"},"5h 剩余"),x("th",{class:"px-4 py-3 font-medium text-right"},"周 剩余"),x("th",{class:"px-4 py-3 font-medium"},"5h 重置"),x("th",{class:"px-4 py-3 font-medium"},"周 重置")])],-1)),x("tbody",null,[(Y(!0),z(ae,null,Ct(e.status.accounts,(m,T)=>(Y(),z("tr",{key:m.email,class:"border-b border-gray-800/50 hover:bg-gray-800/30 transition"},[x("td",Ml,B(T+1),1),x("td",Rl,B(m.email),1),x("td",Il,[x("span",{class:pe(["inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium",n(m.status)])},[x("span",{class:pe(["w-1.5 h-1.5 rounded-full",r(m.status)])},null,2),ds(" "+B(i(m.status)),1)],2)]),x("td",{class:pe(["px-4 py-3 text-right font-mono",d(o(m,"primary"))])},B(l(m,"primary")),3),x("td",{class:pe(["px-4 py-3 text-right font-mono",d(o(m,"weekly"))])},B(l(m,"weekly")),3),x("td",Fl,B(c(m,"primary")),1),x("td",Dl,B(c(m,"weekly")),1)]))),128))])])])])])):e.loading?(Y(),z("div",jl,[x("div",Nl,[(Y(),z(ae,null,Ct(4,m=>x("div",{key:m,class:"bg-gray-900 border border-gray-800 rounded-xl p-4 h-20 animate-pulse"})),64))]),h[2]||(h[2]=x("div",{class:"bg-gray-900 border border-gray-800 rounded-xl h-64 animate-pulse"},null,-1))])):Rt("",!0)}},Ll={class:"mt-6 bg-gray-900 border border-gray-800 rounded-xl p-4"},kl={class:"flex flex-wrap gap-3"},Vl=["onClick","disabled"],Ul={key:0,class:"mt-4 flex items-center gap-3"},Kl={class:"text-sm text-gray-400"},Bl={__name:"TaskPanel",props:{runningTask:Object},emits:["task-started","refresh"],setup(e,{emit:t}){const s=t,n=[{key:"rotate",label:"智能轮转",method:"startRotate",needParam:!0,paramName:"target",style:"bg-blue-600 text-white border-blue-500"},{key:"check",label:"检查额度",method:"startCheck",needParam:!1,style:"bg-emerald-600 text-white border-emerald-500"},{key:"fill",label:"补满成员",method:"startFill",needParam:!0,paramName:"target",style:"bg-violet-600 text-white border-violet-500"},{key:"add",label:"添加账号",method:"startAdd",needParam:!1,style:"bg-amber-600 text-white border-amber-500"},{key:"cleanup",label:"清理成员",method:"startCleanup",needParam:!1,style:"bg-rose-600 text-white border-rose-500"},{key:"sync",label:"同步 CPA",method:"postSync",needParam:!1,sync:!0,style:"bg-gray-700 text-white border-gray-600"}],r=he(!1),i=he(""),o=he(5),l=he(null),c=he(""),d=he("");async function u(T){if(c.value="",T.needParam){l.value=T,i.value=T.paramName==="target"?"目标成员数":"最大席位",o.value=5,r.value=!0;return}await m(T)}async function h(){r.value=!1,l.value&&(await m(l.value,o.value),l.value=null)}async function m(T,$){try{if(T.sync){const E=await dt[T.method]();c.value=E.message||"操作完成",d.value="bg-green-500/10 text-green-400 border border-green-500/20",s("refresh")}else{const E=await dt[T.method]($);c.value=`任务已提交: ${E.task_id}`,d.value="bg-blue-500/10 text-blue-400 border border-blue-500/20",s("task-started")}}catch(E){c.value=E.message,d.value="bg-red-500/10 text-red-400 border border-red-500/20"}setTimeout(()=>{c.value=""},8e3)}return(T,$)=>(Y(),z("div",Ll,[$[2]||($[2]=x("h2",{class:"text-lg font-semibold text-white mb-4"},"操作",-1)),x("div",kl,[(Y(),z(ae,null,Ct(n,E=>x("button",{key:E.key,onClick:q=>u(E),disabled:!!e.runningTask,class:pe(["px-4 py-2 rounded-lg text-sm font-medium transition border",e.runningTask?"bg-gray-800 text-gray-500 border-gray-700 cursor-not-allowed":`${E.style} hover:opacity-80`])},B(E.label),11,Vl)),64))]),r.value?(Y(),z("div",Ul,[x("label",Kl,B(i.value)+":",1),qt(x("input",{"onUpdate:modelValue":$[0]||($[0]=E=>o.value=E),type:"number",min:"1",max:"20",class:"w-20 px-3 py-1.5 bg-gray-800 border border-gray-700 rounded-lg text-sm text-white focus:outline-none focus:border-blue-500"},null,512),[[zt,o.value,void 0,{number:!0}]]),x("button",{onClick:h,class:"px-4 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded-lg transition"}," 确认执行 "),x("button",{onClick:$[1]||($[1]=E=>r.value=!1),class:"px-3 py-1.5 text-gray-400 hover:text-white text-sm transition"}," 取消 ")])):Rt("",!0),c.value?(Y(),z("div",{key:1,class:pe(["mt-4 px-4 py-3 rounded-lg text-sm",d.value])},B(c.value),3)):Rt("",!0)]))}},Wl={class:"mt-6 bg-gray-900 border border-gray-800 rounded-xl overflow-hidden"},ql={key:0,class:"px-4 py-8 text-center text-gray-500 text-sm"},Gl={key:1,class:"overflow-x-auto"},Jl={class:"w-full text-sm"},Yl={class:"px-4 py-3 font-mono text-xs text-gray-400"},zl={class:"px-4 py-3"},Xl={class:"px-2 py-0.5 bg-gray-800 rounded text-xs font-medium text-gray-300"},Zl={class:"px-4 py-3 text-xs text-gray-400"},Ql={class:"px-4 py-3"},ec={key:0,class:"animate-spin inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full"},tc={class:"px-4 py-3 text-xs text-gray-400"},sc={class:"px-4 py-3 text-xs text-gray-400"},nc={__name:"TaskHistory",props:{tasks:{type:Array,default:()=>[]}},setup(e){function t(c){return{pending:"text-gray-400",running:"text-yellow-400",completed:"text-green-400",failed:"text-red-400"}[c]||"text-gray-400"}function s(c){return{pending:"bg-gray-400",completed:"bg-green-400",failed:"bg-red-400"}[c]||"bg-gray-400"}function n(c){return{pending:"等待中",running:"执行中",completed:"已完成",failed:"失败"}[c]||c}function r(c){if(!c)return"-";const d=new Date(c*1e3);return`${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")} ${String(d.getHours()).padStart(2,"0")}:${String(d.getMinutes()).padStart(2,"0")}:${String(d.getSeconds()).padStart(2,"0")}`}function i(c){const d=c.started_at||c.created_at,u=c.finished_at||(c.status==="running"?Date.now()/1e3:null);if(!d||!u)return"-";const h=Math.round(u-d);return h<60?`${h}s`:`${Math.floor(h/60)}m ${h%60}s`}function o(c){return!c||Object.keys(c).length===0?"-":Object.entries(c).map(([d,u])=>`${d}=${u}`).join(", ")}function l(c){return c==null?"-":typeof c=="string"?c:JSON.stringify(c)}return(c,d)=>(Y(),z("div",Wl,[d[1]||(d[1]=x("div",{class:"px-4 py-3 border-b border-gray-800"},[x("h2",{class:"text-lg font-semibold text-white"},"任务历史")],-1)),e.tasks.length===0?(Y(),z("div",ql," 暂无任务记录 ")):(Y(),z("div",Gl,[x("table",Jl,[d[0]||(d[0]=x("thead",null,[x("tr",{class:"text-gray-400 text-left border-b border-gray-800"},[x("th",{class:"px-4 py-3 font-medium"},"任务 ID"),x("th",{class:"px-4 py-3 font-medium"},"命令"),x("th",{class:"px-4 py-3 font-medium"},"参数"),x("th",{class:"px-4 py-3 font-medium"},"状态"),x("th",{class:"px-4 py-3 font-medium"},"创建时间"),x("th",{class:"px-4 py-3 font-medium"},"耗时"),x("th",{class:"px-4 py-3 font-medium"},"结果")])],-1)),x("tbody",null,[(Y(!0),z(ae,null,Ct(e.tasks,u=>(Y(),z("tr",{key:u.task_id,class:"border-b border-gray-800/50 hover:bg-gray-800/30 transition"},[x("td",Yl,B(u.task_id),1),x("td",zl,[x("span",Xl,B(u.command),1)]),x("td",Zl,B(o(u.params)),1),x("td",Ql,[x("span",{class:pe(["inline-flex items-center gap-1.5 text-xs font-medium",t(u.status)])},[u.status==="running"?(Y(),z("span",ec)):(Y(),z("span",{key:1,class:pe(["w-1.5 h-1.5 rounded-full",s(u.status)])},null,2)),ds(" "+B(n(u.status)),1)],2)]),x("td",tc,B(r(u.created_at)),1),x("td",sc,B(i(u)),1),x("td",{class:pe(["px-4 py-3 text-xs max-w-xs truncate",u.error?"text-red-400":"text-gray-400"])},B(u.error||l(u.result)),3)]))),128))])])]))]))}},rc={class:"mt-6 bg-gray-900 border border-gray-800 rounded-xl p-4"},ic={class:"flex items-center justify-between mb-4"},oc={key:0,class:"text-xs text-green-400 transition"},lc={class:"grid grid-cols-1 sm:grid-cols-3 gap-4"},cc={class:"flex items-center gap-2"},fc={class:"flex items-center gap-2"},uc={class:"flex items-center gap-2"},ac={class:"mt-3 flex items-center justify-between"},dc={class:"text-xs text-gray-500"},hc=["disabled"],pc={__name:"Settings",setup(e){const t=he({interval:5,threshold:10,min_low:2}),s=he(!1),n=he(!1);tn(async()=>{try{const i=await dt.getAutoCheckConfig();t.value={interval:Math.round(i.interval/60),threshold:i.threshold,min_low:i.min_low}}catch(i){console.error("加载巡检配置失败:",i)}});async function r(){s.value=!0,n.value=!1;try{const i=await dt.setAutoCheckConfig({interval:t.value.interval*60,threshold:t.value.threshold,min_low:t.value.min_low});t.value={interval:Math.round(i.interval/60),threshold:i.threshold,min_low:i.min_low},n.value=!0,setTimeout(()=>{n.value=!1},3e3)}catch(i){console.error("保存失败:",i)}finally{s.value=!1}}return(i,o)=>(Y(),z("div",rc,[x("div",ic,[o[3]||(o[3]=x("h2",{class:"text-lg font-semibold text-white"},"巡检设置",-1)),n.value?(Y(),z("span",oc,"已保存")):Rt("",!0)]),x("div",lc,[x("div",null,[o[5]||(o[5]=x("label",{class:"block text-sm text-gray-400 mb-1"},"巡检间隔",-1)),x("div",cc,[qt(x("input",{"onUpdate:modelValue":o[0]||(o[0]=l=>t.value.interval=l),type:"number",min:"1",class:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-white focus:outline-none focus:border-blue-500"},null,512),[[zt,t.value.interval,void 0,{number:!0}]]),o[4]||(o[4]=x("span",{class:"text-sm text-gray-500 shrink-0"},"分钟",-1))])]),x("div",null,[o[7]||(o[7]=x("label",{class:"block text-sm text-gray-400 mb-1"},"额度阈值",-1)),x("div",fc,[qt(x("input",{"onUpdate:modelValue":o[1]||(o[1]=l=>t.value.threshold=l),type:"number",min:"1",max:"100",class:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-white focus:outline-none focus:border-blue-500"},null,512),[[zt,t.value.threshold,void 0,{number:!0}]]),o[6]||(o[6]=x("span",{class:"text-sm text-gray-500 shrink-0"},"%",-1))])]),x("div",null,[o[9]||(o[9]=x("label",{class:"block text-sm text-gray-400 mb-1"},"触发账号数",-1)),x("div",uc,[qt(x("input",{"onUpdate:modelValue":o[2]||(o[2]=l=>t.value.min_low=l),type:"number",min:"1",class:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-white focus:outline-none focus:border-blue-500"},null,512),[[zt,t.value.min_low,void 0,{number:!0}]]),o[8]||(o[8]=x("span",{class:"text-sm text-gray-500 shrink-0"},"个",-1))])])]),x("div",ac,[x("p",dc," 每 "+B(t.value.interval)+" 分钟检查一次,"+B(t.value.min_low)+" 个以上账号剩余低于 "+B(t.value.threshold)+"% 时自动轮转 ",1),x("button",{onClick:r,disabled:s.value,class:"px-4 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded-lg transition disabled:opacity-50"},B(s.value?"保存中...":"保存"),9,hc)])]))}},gc={class:"max-w-7xl mx-auto px-4 py-6"},mc={class:"flex items-center justify-between mb-8"},bc={class:"flex items-center gap-3"},yc={key:0,class:"flex items-center gap-2 text-sm text-yellow-400"},_c=["disabled"],xc={__name:"App",setup(e){const t=he(null),s=he([]),n=he(!1),r=he(null);let i=null;async function o(){n.value=!0;try{const[u,h]=await Promise.all([dt.getStatus(),dt.getTasks()]);t.value=u,s.value=h,r.value=h.find(m=>m.status==="running"||m.status==="pending")||null}catch(u){console.error("刷新失败:",u)}finally{n.value=!1}}function l(){c(3e3),o()}function c(u=6e5){d(),i=setInterval(async()=>{await o(),!r.value&&u<6e5&&c(6e5)},u)}function d(){i&&(clearInterval(i),i=null)}return tn(()=>{o(),c(6e5)}),sn(()=>{d()}),(u,h)=>(Y(),z("div",gc,[x("header",mc,[h[1]||(h[1]=x("div",null,[x("h1",{class:"text-2xl font-bold text-white"},"AutoTeam"),x("p",{class:"text-sm text-gray-400 mt-1"},"ChatGPT Team 账号自动轮转管理")],-1)),x("div",bc,[r.value?(Y(),z("span",yc,[h[0]||(h[0]=x("span",{class:"animate-spin inline-block w-4 h-4 border-2 border-yellow-400 border-t-transparent rounded-full"},null,-1)),ds(" "+B(r.value.command)+" 执行中... ",1)])):Rt("",!0),x("button",{onClick:o,disabled:n.value,class:"px-3 py-1.5 bg-gray-800 hover:bg-gray-700 text-sm rounded-lg border border-gray-700 transition disabled:opacity-50"},B(n.value?"刷新中...":"刷新"),9,_c)])]),me(Hl,{status:t.value,loading:n.value},null,8,["status","loading"]),me(Bl,{"running-task":r.value,onTaskStarted:l,onRefresh:o},null,8,["running-task"]),me(nc,{tasks:s.value},null,8,["tasks"]),me(pc)]))}};vl(xc).mount("#app");13 unmodified lines1415161713 unmodified lines* @vue/runtime-dom v3.5.32* (c) 2018-present Yuxi (Evan) You and Vue contributors* @license MIT**/let Hs;const Mn=typeof window<"u"&&window.trustedTypes;if(Mn)try{Hs=Mn.createPolicy("vue",{createHTML:e=>e})}catch{}const zr=Hs?e=>Hs.createHTML(e):e=>e,Zo="http://www.w3.org/2000/svg",Qo="http://www.w3.org/1998/Math/MathML",je=typeof document<"u"?document:null,Rn=je&&je.createElement("template"),el={insert:(e,t,s)=>{t.insertBefore(e,s||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,s,n)=>{const r=t==="svg"?je.createElementNS(Zo,e):t==="mathml"?je.createElementNS(Qo,e):s?je.createElement(e,{is:s}):je.createElement(e);return e==="select"&&n&&n.multiple!=null&&r.setAttribute("multiple",n.multiple),r},createText:e=>je.createTextNode(e),createComment:e=>je.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>je.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,s,n,r,i){const o=s?s.previousSibling:t.lastChild;if(r&&(r===i||r.nextSibling))for(;t.insertBefore(r.cloneNode(!0),s),!(r===i||!(r=r.nextSibling)););else{Rn.innerHTML=zr(n==="svg"?`<svg>${e}</svg>`:n==="mathml"?`<math>${e}</math>`:e);const l=Rn.content;if(n==="svg"||n==="mathml"){const c=l.firstChild;for(;c.firstChild;)l.appendChild(c.firstChild);l.removeChild(c)}t.insertBefore(l,s)}return[o?o.nextSibling:t.firstChild,s?s.previousSibling:t.lastChild]}},tl=Symbol("_vtc");function sl(e,t,s){const n=e[tl];n&&(t=(t?[t,...n]:[...n]).join(" ")),t==null?e.removeAttribute("class"):s?e.setAttribute("class",t):e.className=t}const In=Symbol("_vod"),nl=Symbol("_vsh"),rl=Symbol(""),il=/(?:^|;)\s*display\s*:/;function ol(e,t,s){const n=e.style,r=Z(s);let i=!1;if(s&&!r){if(t)if(Z(t))for(const o of t.split(";")){const l=o.slice(0,o.indexOf(":")).trim();s[l]==null&&Yt(n,l,"")}else for(const o in t)s[o]==null&&Yt(n,o,"");for(const o in s)o==="display"&&(i=!0),Yt(n,o,s[o])}else if(r){if(t!==s){const o=n[rl];o&&(s+=";"+o),n.cssText=s,i=il.test(s)}}else t&&e.removeAttribute("style");In in e&&(e[In]=i?n.display:"",e[nl]&&(n.display="none"))}const Fn=/\s*!important$/;function Yt(e,t,s){if(R(s))s.forEach(n=>Yt(e,t,n));else if(s==null&&(s=""),t.startsWith("--"))e.setProperty(t,s);else{const n=ll(e,t);Fn.test(s)?e.setProperty(st(n),s.replace(Fn,""),"important"):e[n]=s}}const Dn=["Webkit","Moz","ms"],Cs={};function ll(e,t){const s=Cs[t];if(s)return s;let n=_e(t);if(n!=="filter"&&n in e)return Cs[t]=n;n=Xn(n);for(let r=0;r<Dn.length;r++){const i=Dn[r]+n;if(i in e)return Cs[t]=i}return t}const jn="http://www.w3.org/1999/xlink";function Nn(e,t,s,n,r,i=ci(t)){n&&t.startsWith("xlink:")?s==null?e.removeAttributeNS(jn,t.slice(6,t.length)):e.setAttributeNS(jn,t,s):s==null||i&&!Qn(s)?e.removeAttribute(t):e.setAttribute(t,i?"":Ie(s)?String(s):s)}function Hn(e,t,s,n,r){if(t==="innerHTML"||t==="textContent"){s!=null&&(e[t]=t==="innerHTML"?zr(s):s);return}const i=e.tagName;if(t==="value"&&i!=="PROGRESS"&&!i.includes("-")){const l=i==="OPTION"?e.getAttribute("value")||"":e.value,c=s==null?e.type==="checkbox"?"on":"":String(s);(l!==c||!("_value"in e))&&(e.value=c),s==null&&e.removeAttribute(t),e._value=s;return}let o=!1;if(s===""||s==null){const l=typeof e[t];l==="boolean"?s=Qn(s):s==null&&l==="string"?(s="",o=!0):l==="number"&&(s=0,o=!0)}try{e[t]=s}catch{}o&&e.removeAttribute(r||t)}function it(e,t,s,n){e.addEventListener(t,s,n)}function cl(e,t,s,n){e.removeEventListener(t,s,n)}const Ln=Symbol("_vei");function fl(e,t,s,n,r=null){const i=e[Ln]||(e[Ln]={}),o=i[t];if(n&&o)o.value=n;else{const[l,c]=ul(t);if(n){const d=i[t]=hl(n,r);it(e,l,d,c)}else o&&(cl(e,l,o,c),i[t]=void 0)}}const kn=/(?:Once|Passive|Capture)$/;function ul(e){let t;if(kn.test(e)){t={};let n;for(;n=e.match(kn);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):st(e.slice(2)),t]}let Es=0;const al=Promise.resolve(),dl=()=>Es||(al.then(()=>Es=0),Es=Date.now());function hl(e,t){const s=n=>{if(!n._vts)n._vts=Date.now();else if(n._vts<=s.attached)return;Fe(pl(n,s.value),t,5,[n])};return s.value=e,s.attached=dl(),s}function pl(e,t){if(R(t)){const s=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{s.call(e),e._stopped=!0},t.map(n=>r=>!r._stopped&&n&&n(r))}else return t}const Vn=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,gl=(e,t,s,n,r,i)=>{const o=r==="svg";t==="class"?sl(e,n,o):t==="style"?ol(e,s,n):ns(t)?rs(t)||fl(e,t,s,n,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):ml(e,t,n,o))?(Hn(e,t,n),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&Nn(e,t,n,o,i,t!=="value")):e._isVueCE&&(bl(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!Z(n)))?Hn(e,_e(t),n,i,t):(t==="true-value"?e._trueValue=n:t==="false-value"&&(e._falseValue=n),Nn(e,t,n,o))};function ml(e,t,s,n){if(n)return!!(t==="innerHTML"||t==="textContent"||t in e&&Vn(t)&&I(s));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const r=e.tagName;if(r==="IMG"||r==="VIDEO"||r==="CANVAS"||r==="SOURCE")return!1}return Vn(t)&&Z(s)?!1:t in e}function bl(e,t){const s=e._def.props;if(!s)return!1;const n=_e(t);return Array.isArray(s)?s.some(r=>_e(r)===n):Object.keys(s).some(r=>_e(r)===n)}const Un=e=>{const t=e.props["onUpdate:modelValue"]||!1;return R(t)?s=>Wt(t,s):t};function yl(e){e.target.composing=!0}function Kn(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}const As=Symbol("_assign");function Bn(e,t,s){return t&&(e=e.trim()),s&&(e=Us(e)),e}const zt={created(e,{modifiers:{lazy:t,trim:s,number:n}},r){e[As]=Un(r);const i=n||r.props&&r.props.type==="number";it(e,t?"change":"input",o=>{o.target.composing||e[As](Bn(e.value,s,i))}),(s||i)&&it(e,"change",()=>{e.value=Bn(e.value,s,i)}),t||(it(e,"compositionstart",yl),it(e,"compositionend",Kn),it(e,"change",Kn))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:s,modifiers:{lazy:n,trim:r,number:i}},o){if(e[As]=Un(o),e.composing)return;const l=(i||e.type==="number")&&!/^0\d/.test(e.value)?Us(e.value):e.value,c=t??"";if(l===c)return;const d=e.getRootNode();(d instanceof Document||d instanceof ShadowRoot)&&d.activeElement===e&&e.type!=="range"&&(n&&t===s||r&&e.value.trim()===c)||(e.value=c)}},_l=ne({patchProp:gl},el);let Wn;function xl(){return Wn||(Wn=Ro(_l))}const vl=((...e)=>{const t=xl().createApp(...e),{mount:s}=t;return t.mount=n=>{const r=Sl(n);if(!r)return;const i=t._component;!I(i)&&!i.render&&!i.template&&(i.template=r.innerHTML),r.nodeType===1&&(r.textContent="");const o=s(r,!1,wl(r));return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},t});function wl(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function Sl(e){return Z(e)?document.querySelector(e):e}const Tl="/api";async function ie(e,t,s=null){var o;const n={method:e,headers:{"Content-Type":"application/json"}};s&&(n.body=JSON.stringify(s));const r=await fetch(`${Tl}${t}`,n),i=await r.json();if(!r.ok){const l=((o=i==null?void 0:i.detail)==null?void 0:o.message)||(i==null?void 0:i.detail)||`HTTP ${r.status}`;throw new Error(l)}return i}const dt={getStatus:()=>ie("GET","/status"),getAccounts:()=>ie("GET","/accounts"),getActiveAccounts:()=>ie("GET","/accounts/active"),getStandbyAccounts:()=>ie("GET","/accounts/standby"),getCpaFiles:()=>ie("GET","/cpa/files"),postSync:()=>ie("POST","/sync"),startRotate:(e=5)=>ie("POST","/tasks/rotate",{target:e}),startCheck:()=>ie("POST","/tasks/check"),startAdd:()=>ie("POST","/tasks/add"),startFill:(e=5)=>ie("POST","/tasks/fill",{target:e}),startCleanup:(e=null)=>ie("POST","/tasks/cleanup",{max_seats:e}),getTasks:()=>ie("GET","/tasks"),getTask:e=>ie("GET",`/tasks/${e}`),getAutoCheckConfig:()=>ie("GET","/config/auto-check"),setAutoCheckConfig:e=>ie("PUT","/config/auto-check",e)},Cl={key:0},El={class:"grid grid-cols-2 sm:grid-cols-4 gap-4 mb-6"},Al={class:"text-sm text-gray-400"},Ol={class:"bg-gray-900 border border-gray-800 rounded-xl overflow-hidden"},Pl={class:"overflow-x-auto"},$l={class:"w-full text-sm"},Ml={class:"px-4 py-3 text-gray-500"},Rl={class:"px-4 py-3 font-mono text-xs"},Il={class:"px-4 py-3"},Fl={class:"px-4 py-3 text-gray-400 text-xs"},Dl={class:"px-4 py-3 text-gray-400 text-xs"},jl={key:1,class:"space-y-4"},Nl={class:"grid grid-cols-2 sm:grid-cols-4 gap-4"},Hl={__name:"Dashboard",props:{status:Object,loading:Boolean},setup(e){const t=e,s=Yr(()=>{if(!t.status)return[];const u=t.status.summary;return[{label:"活跃",value:u.active,color:"text-green-400"},{label:"待命",value:u.standby,color:"text-yellow-400"},{label:"额度用完",value:u.exhausted,color:"text-red-400"},{label:"总计",value:u.total,color:"text-white"}]});function n(u){return{active:"bg-green-500/10 text-green-400",exhausted:"bg-red-500/10 text-red-400",standby:"bg-yellow-500/10 text-yellow-400",pending:"bg-gray-500/10 text-gray-400"}[u]||"bg-gray-500/10 text-gray-400"}function r(u){return{active:"bg-green-400",exhausted:"bg-red-400",standby:"bg-yellow-400",pending:"bg-gray-400"}[u]||"bg-gray-400"}function i(u){return{active:"Active",exhausted:"Used up",standby:"Standby",pending:"Pending"}[u]||u}function o(u,h){var $,E;const m=((E=($=t.status)==null?void 0:$.quota_cache)==null?void 0:E[u.email])||u.last_quota;return m?100-((h==="primary"?m.primary_pct:m.weekly_pct)||0):null}function l(u,h){const m=o(u,h);return m!==null?`${m}%`:"-"}function c(u,h){var E,q;const m=((q=(E=t.status)==null?void 0:E.quota_cache)==null?void 0:q[u.email])||u.last_quota;if(!m)return"-";const T=h==="primary"?m.primary_resets_at:m.weekly_resets_at;if(!T)return"-";const $=new Date(T*1e3);return`${String($.getMonth()+1).padStart(2,"0")}-${String($.getDate()).padStart(2,"0")} ${String($.getHours()).padStart(2,"0")}:${String($.getMinutes()).padStart(2,"0")}`}function d(u){return u===null?"text-gray-500":u>30?"text-green-400":u>0?"text-yellow-400":"text-red-400"}return(u,h)=>e.status?(Y(),z("div",Cl,[x("div",El,[(Y(!0),z(ae,null,Ct(s.value,m=>(Y(),z("div",{key:m.label,class:"bg-gray-900 border border-gray-800 rounded-xl p-4"},[x("div",Al,B(m.label),1),x("div",{class:pe(["text-3xl font-bold mt-1",m.color])},B(m.value),3)]))),128))]),x("div",Ol,[h[1]||(h[1]=x("div",{class:"px-4 py-3 border-b border-gray-800"},[x("h2",{class:"text-lg font-semibold text-white"},"账号列表")],-1)),x("div",Pl,[x("table",$l,[h[0]||(h[0]=x("thead",null,[x("tr",{class:"text-gray-400 text-left border-b border-gray-800"},[x("th",{class:"px-4 py-3 font-medium"},"#"),x("th",{class:"px-4 py-3 font-medium"},"邮箱"),x("th",{class:"px-4 py-3 font-medium"},"状态"),x("th",{class:"px-4 py-3 font-medium text-right"},"5h 剩余"),x("th",{class:"px-4 py-3 font-medium text-right"},"周 剩余"),x("th",{class:"px-4 py-3 font-medium"},"5h 重置"),x("th",{class:"px-4 py-3 font-medium"},"周 重置")])],-1)),x("tbody",null,[(Y(!0),z(ae,null,Ct(e.status.accounts,(m,T)=>(Y(),z("tr",{key:m.email,class:"border-b border-gray-800/50 hover:bg-gray-800/30 transition"},[x("td",Ml,B(T+1),1),x("td",Rl,B(m.email),1),x("td",Il,[x("span",{class:pe(["inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium",n(m.status)])},[x("span",{class:pe(["w-1.5 h-1.5 rounded-full",r(m.status)])},null,2),ds(" "+B(i(m.status)),1)],2)]),x("td",{class:pe(["px-4 py-3 text-right font-mono",d(o(m,"primary"))])},B(l(m,"primary")),3),x("td",{class:pe(["px-4 py-3 text-right font-mono",d(o(m,"weekly"))])},B(l(m,"weekly")),3),x("td",Fl,B(c(m,"primary")),1),x("td",Dl,B(c(m,"weekly")),1)]))),128))])])])])])):e.loading?(Y(),z("div",jl,[x("div",Nl,[(Y(),z(ae,null,Ct(4,m=>x("div",{key:m,class:"bg-gray-900 border border-gray-800 rounded-xl p-4 h-20 animate-pulse"})),64))]),h[2]||(h[2]=x("div",{class:"bg-gray-900 border border-gray-800 rounded-xl h-64 animate-pulse"},null,-1))])):Rt("",!0)}},Ll={class:"mt-6 bg-gray-900 border border-gray-800 rounded-xl p-4"},kl={class:"flex flex-wrap gap-3"},Vl=["onClick","disabled"],Ul={key:0,class:"mt-4 flex items-center gap-3"},Kl={class:"text-sm text-gray-400"},Bl={__name:"TaskPanel",props:{runningTask:Object},emits:["task-started","refresh"],setup(e,{emit:t}){const s=t,n=[{key:"rotate",label:"智能轮转",method:"startRotate",needParam:!0,paramName:"target",style:"bg-blue-600 text-white border-blue-500"},{key:"check",label:"检查额度",method:"startCheck",needParam:!1,style:"bg-emerald-600 text-white border-emerald-500"},{key:"fill",label:"补满成员",method:"startFill",needParam:!0,paramName:"target",style:"bg-violet-600 text-white border-violet-500"},{key:"add",label:"添加账号",method:"startAdd",needParam:!1,style:"bg-amber-600 text-white border-amber-500"},{key:"cleanup",label:"清理成员",method:"startCleanup",needParam:!1,style:"bg-rose-600 text-white border-rose-500"},{key:"sync",label:"同步 CPA",method:"postSync",needParam:!1,sync:!0,style:"bg-gray-700 text-white border-gray-600"}],r=he(!1),i=he(""),o=he(5),l=he(null),c=he(""),d=he("");async function u(T){if(c.value="",T.needParam){l.value=T,i.value=T.paramName==="target"?"目标成员数":"最大席位",o.value=5,r.value=!0;return}await m(T)}async function h(){r.value=!1,l.value&&(await m(l.value,o.value),l.value=null)}async function m(T,$){try{if(T.sync){const E=await dt[T.method]();c.value=E.message||"操作完成",d.value="bg-green-500/10 text-green-400 border border-green-500/20",s("refresh")}else{const E=await dt[T.method]($);c.value=`任务已提交: ${E.task_id}`,d.value="bg-blue-500/10 text-blue-400 border border-blue-500/20",s("task-started")}}catch(E){c.value=E.message,d.value="bg-red-500/10 text-red-400 border border-red-500/20"}setTimeout(()=>{c.value=""},8e3)}return(T,$)=>(Y(),z("div",Ll,[$[2]||($[2]=x("h2",{class:"text-lg font-semibold text-white mb-4"},"操作",-1)),x("div",kl,[(Y(),z(ae,null,Ct(n,E=>x("button",{key:E.key,onClick:q=>u(E),disabled:!!e.runningTask,class:pe(["px-4 py-2 rounded-lg text-sm font-medium transition border",e.runningTask?"bg-gray-800 text-gray-500 border-gray-700 cursor-not-allowed":`${E.style} hover:opacity-80`])},B(E.label),11,Vl)),64))]),r.value?(Y(),z("div",Ul,[x("label",Kl,B(i.value)+":",1),qt(x("input",{"onUpdate:modelValue":$[0]||($[0]=E=>o.value=E),type:"number",min:"1",max:"20",class:"w-20 px-3 py-1.5 bg-gray-800 border border-gray-700 rounded-lg text-sm text-white focus:outline-none focus:border-blue-500"},null,512),[[zt,o.value,void 0,{number:!0}]]),x("button",{onClick:h,class:"px-4 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded-lg transition"}," 确认执行 "),x("button",{onClick:$[1]||($[1]=E=>r.value=!1),class:"px-3 py-1.5 text-gray-400 hover:text-white text-sm transition"}," 取消 ")])):Rt("",!0),c.value?(Y(),z("div",{key:1,class:pe(["mt-4 px-4 py-3 rounded-lg text-sm",d.value])},B(c.value),3)):Rt("",!0)]))}},Wl={class:"mt-6 bg-gray-900 border border-gray-800 rounded-xl overflow-hidden"},ql={key:0,class:"px-4 py-8 text-center text-gray-500 text-sm"},Gl={key:1,class:"overflow-x-auto"},Jl={class:"w-full text-sm"},Yl={class:"px-4 py-3 font-mono text-xs text-gray-400"},zl={class:"px-4 py-3"},Xl={class:"px-2 py-0.5 bg-gray-800 rounded text-xs font-medium text-gray-300"},Zl={class:"px-4 py-3 text-xs text-gray-400"},Ql={class:"px-4 py-3"},ec={key:0,class:"animate-spin inline-block w-3 h-3 border-2 border-current border-t-transparent rounded-full"},tc={class:"px-4 py-3 text-xs text-gray-400"},sc={class:"px-4 py-3 text-xs text-gray-400"},nc={__name:"TaskHistory",props:{tasks:{type:Array,default:()=>[]}},setup(e){function t(c){return{pending:"text-gray-400",running:"text-yellow-400",completed:"text-green-400",failed:"text-red-400"}[c]||"text-gray-400"}function s(c){return{pending:"bg-gray-400",completed:"bg-green-400",failed:"bg-red-400"}[c]||"bg-gray-400"}function n(c){return{pending:"等待中",running:"执行中",completed:"已完成",failed:"失败"}[c]||c}function r(c){if(!c)return"-";const d=new Date(c*1e3);return`${String(d.getMonth()+1).padStart(2,"0")}-${String(d.getDate()).padStart(2,"0")} ${String(d.getHours()).padStart(2,"0")}:${String(d.getMinutes()).padStart(2,"0")}:${String(d.getSeconds()).padStart(2,"0")}`}function i(c){const d=c.started_at||c.created_at,u=c.finished_at||(c.status==="running"?Date.now()/1e3:null);if(!d||!u)return"-";const h=Math.round(u-d);return h<60?`${h}s`:`${Math.floor(h/60)}m ${h%60}s`}function o(c){return!c||Object.keys(c).length===0?"-":Object.entries(c).map(([d,u])=>`${d}=${u}`).join(", ")}function l(c){return c==null?"-":typeof c=="string"?c:JSON.stringify(c)}return(c,d)=>(Y(),z("div",Wl,[d[1]||(d[1]=x("div",{class:"px-4 py-3 border-b border-gray-800"},[x("h2",{class:"text-lg font-semibold text-white"},"任务历史")],-1)),e.tasks.length===0?(Y(),z("div",ql," 暂无任务记录 ")):(Y(),z("div",Gl,[x("table",Jl,[d[0]||(d[0]=x("thead",null,[x("tr",{class:"text-gray-400 text-left border-b border-gray-800"},[x("th",{class:"px-4 py-3 font-medium"},"任务 ID"),x("th",{class:"px-4 py-3 font-medium"},"命令"),x("th",{class:"px-4 py-3 font-medium"},"参数"),x("th",{class:"px-4 py-3 font-medium"},"状态"),x("th",{class:"px-4 py-3 font-medium"},"创建时间"),x("th",{class:"px-4 py-3 font-medium"},"耗时"),x("th",{class:"px-4 py-3 font-medium"},"结果")])],-1)),x("tbody",null,[(Y(!0),z(ae,null,Ct(e.tasks,u=>(Y(),z("tr",{key:u.task_id,class:"border-b border-gray-800/50 hover:bg-gray-800/30 transition"},[x("td",Yl,B(u.task_id),1),x("td",zl,[x("span",Xl,B(u.command),1)]),x("td",Zl,B(o(u.params)),1),x("td",Ql,[x("span",{class:pe(["inline-flex items-center gap-1.5 text-xs font-medium",t(u.status)])},[u.status==="running"?(Y(),z("span",ec)):(Y(),z("span",{key:1,class:pe(["w-1.5 h-1.5 rounded-full",s(u.status)])},null,2)),ds(" "+B(n(u.status)),1)],2)]),x("td",tc,B(r(u.created_at)),1),x("td",sc,B(i(u)),1),x("td",{class:pe(["px-4 py-3 text-xs max-w-xs truncate",u.error?"text-red-400":"text-gray-400"])},B(u.error||l(u.result)),3)]))),128))])])]))]))}},rc={class:"mt-6 bg-gray-900 border border-gray-800 rounded-xl p-4"},ic={class:"flex items-center justify-between mb-4"},oc={key:0,class:"text-xs text-green-400 transition"},lc={class:"grid grid-cols-1 sm:grid-cols-3 gap-4"},cc={class:"flex items-center gap-2"},fc={class:"flex items-center gap-2"},uc={class:"flex items-center gap-2"},ac={class:"mt-3 flex items-center justify-between"},dc={class:"text-xs text-gray-500"},hc=["disabled"],pc={__name:"Settings",setup(e){const t=he({interval:5,threshold:10,min_low:2}),s=he(!1),n=he(!1);tn(async()=>{try{const i=await dt.getAutoCheckConfig();t.value={interval:Math.round(i.interval/60),threshold:i.threshold,min_low:i.min_low}}catch(i){console.error("加载巡检配置失败:",i)}});async function r(){s.value=!0,n.value=!1;try{const i=await dt.setAutoCheckConfig({interval:t.value.interval*60,threshold:t.value.threshold,min_low:t.value.min_low});t.value={interval:Math.round(i.interval/60),threshold:i.threshold,min_low:i.min_low},n.value=!0,setTimeout(()=>{n.value=!1},3e3)}catch(i){console.error("保存失败:",i)}finally{s.value=!1}}return(i,o)=>(Y(),z("div",rc,[x("div",ic,[o[3]||(o[3]=x("h2",{class:"text-lg font-semibold text-white"},"巡检设置",-1)),n.value?(Y(),z("span",oc,"已保存")):Rt("",!0)]),x("div",lc,[x("div",null,[o[5]||(o[5]=x("label",{class:"block text-sm text-gray-400 mb-1"},"巡检间隔",-1)),x("div",cc,[qt(x("input",{"onUpdate:modelValue":o[0]||(o[0]=l=>t.value.interval=l),type:"number",min:"1",class:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-white focus:outline-none focus:border-blue-500"},null,512),[[zt,t.value.interval,void 0,{number:!0}]]),o[4]||(o[4]=x("span",{class:"text-sm text-gray-500 shrink-0"},"分钟",-1))])]),x("div",null,[o[7]||(o[7]=x("label",{class:"block text-sm text-gray-400 mb-1"},"额度阈值",-1)),x("div",fc,[qt(x("input",{"onUpdate:modelValue":o[1]||(o[1]=l=>t.value.threshold=l),type:"number",min:"1",max:"100",class:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-white focus:outline-none focus:border-blue-500"},null,512),[[zt,t.value.threshold,void 0,{number:!0}]]),o[6]||(o[6]=x("span",{class:"text-sm text-gray-500 shrink-0"},"%",-1))])]),x("div",null,[o[9]||(o[9]=x("label",{class:"block text-sm text-gray-400 mb-1"},"触发账号数",-1)),x("div",uc,[qt(x("input",{"onUpdate:modelValue":o[2]||(o[2]=l=>t.value.min_low=l),type:"number",min:"1",class:"w-full px-3 py-2 bg-gray-800 border border-gray-700 rounded-lg text-sm text-white focus:outline-none focus:border-blue-500"},null,512),[[zt,t.value.min_low,void 0,{number:!0}]]),o[8]||(o[8]=x("span",{class:"text-sm text-gray-500 shrink-0"},"个",-1))])])]),x("div",ac,[x("p",dc," 每 "+B(t.value.interval)+" 分钟检查一次,"+B(t.value.min_low)+" 个以上账号剩余低于 "+B(t.value.threshold)+"% 时自动轮转 ",1),x("button",{onClick:r,disabled:s.value,class:"px-4 py-1.5 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded-lg transition disabled:opacity-50"},B(s.value?"保存中...":"保存"),9,hc)])]))}},gc={class:"max-w-7xl mx-auto px-4 py-6"},mc={class:"flex items-center justify-between mb-8"},bc={class:"flex items-center gap-3"},yc={key:0,class:"flex items-center gap-2 text-sm text-yellow-400"},_c=["disabled"],xc={__name:"App",setup(e){const t=he(null),s=he([]),n=he(!1),r=he(null);let i=null;async function o(){n.value=!0;try{const[u,h]=await Promise.all([dt.getStatus(),dt.getTasks()]);t.value=u,s.value=h,r.value=h.find(m=>m.status==="running"||m.status==="pending")||null}catch(u){console.error("刷新失败:",u)}finally{n.value=!1}}function l(){c(3e4),o()}function c(u=6e5){d(),i=setInterval(async()=>{await o(),!r.value&&u<6e5&&c(6e5)},u)}function d(){i&&(clearInterval(i),i=null)}return tn(()=>{o(),c(6e5)}),sn(()=>{d()}),(u,h)=>(Y(),z("div",gc,[x("header",mc,[h[1]||(h[1]=x("div",null,[x("h1",{class:"text-2xl font-bold text-white"},"AutoTeam"),x("p",{class:"text-sm text-gray-400 mt-1"},"ChatGPT Team 账号自动轮转管理")],-1)),x("div",bc,[r.value?(Y(),z("span",yc,[h[0]||(h[0]=x("span",{class:"animate-spin inline-block w-4 h-4 border-2 border-yellow-400 border-t-transparent rounded-full"},null,-1)),ds(" "+B(r.value.command)+" 执行中... ",1)])):Rt("",!0),x("button",{onClick:o,disabled:n.value,class:"px-3 py-1.5 bg-gray-800 hover:bg-gray-700 text-sm rounded-lg border border-gray-700 transition disabled:opacity-50"},B(n.value?"刷新中...":"刷新"),9,_c)])]),me(Hl,{status:t.value,loading:n.value},null,8,["status","loading"]),me(Bl,{"running-task":r.value,onTaskStarted:l,onRefresh:o},null,8,["running-task"]),me(nc,{tasks:s.value},null,8,["tasks"]),me(pc)]))}};vl(xc).mount("#app");
3 unmodified lines456789103 unmodified lines<meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>AutoTeam</title><script type="module" crossorigin src="/assets/index-BjQmT9Yf.js"></script><link rel="stylesheet" crossorigin href="/assets/index-CNWPOsK5.css"></head><body class="bg-gray-950 text-gray-100 min-h-screen">3 unmodified lines456789103 unmodified lines<meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>AutoTeam</title><script type="module" crossorigin src="/assets/index-DoMwpA9c.js"></script><link rel="stylesheet" crossorigin href="/assets/index-CNWPOsK5.css"></head><body class="bg-gray-950 text-gray-100 min-h-screen">
61 unmodified lines626364656667686961 unmodified lines}function onTaskStarted() {// 任务启动后开始快速轮询startPolling(3000)refresh()}61 unmodified lines626364656667686961 unmodified lines}function onTaskStarted() {// 任务启动后开始较快轮询startPolling(30000)refresh()}
src/autoteam/manager.py+4-8
src/autoteam/web/dist/assets/index-BjQmT9Yf.js → src/autoteam/web/dist/assets/index-DoMwpA9c.jsRenamed+1-1
src/autoteam/web/dist/index.html+1-1
web/src/App.vue+2-2