PageSourceSearch

https://xyc.ai/static/js/async/1917.1bdbfec8fd.js

js xyc.ai collected 2026-10-05 14:38:14 UTC 7,522 bytes, 1 lines download raw bytes

1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[1917],{69756(e,t,s){s.r(t),s.d(t,{component:()=>A});var a=s(72361),i=s(68413),n=s(96962),l=s(53540),r=s(55667),c=s(6702),o=s(20598),d=s(61631),u=s(63742),h=s(46775),x=s(31005),m=s(54023),j=s(61309),p=s(18434),g=s(1951),f=s(32999),w=s(67267),y=s(64577);async function _(){let e=await y.FH.get("/api/autopost/config");if(!e.data?.success)throw Error(e.data?.message??"load failed");return e.data.data}async function v(){let e=await y.FH.get("/api/autopost/x/auth-url");if(!e.data?.success)throw Error(e.data?.message??"failed");return e.data.data.url}async function N(e){let t=await y.FH.put("/api/autopost/config",e);if(!t.data?.success)throw Error(t.data?.message??"save failed")}async function b(e){let t=await y.FH.get(`/api/autopost/logs?p=${e}&page_size=20`);if(!t.data?.success)throw Error(t.data?.message??"load failed");return t.data.data}async function C(e){let t=await y.FH.post("/api/autopost/trigger",{platform:e??""});if(!t.data?.success)throw Error(t.data?.message??"trigger failed");return t.data.data}
1function k(e){let{label:t,value:s,onChange:i,placeholder:n,type:l="text"}=e;return(0,a.jsxs)("div",{className:"grid gap-1.5",children:[(0,a.jsx)(j.J,{className:"text-xs",children:t}),(0,a.jsx)(m.p,{value:s,type:l,placeholder:n,onChange:e=>i(e.target.value),autoComplete:"off"})]})}let A=function(){let{t:e}=(0,c.Bd)(),t=(0,n.jE)(),[s,m]=(0,i.useState)(null),[j,y]=(0,i.useState)(1),[A,S]=(0,i.useState)(""),{data:z,isLoading:P}=(0,l.I)({queryKey:["autopost-config"],queryFn:_}),R=z?.config,E=z?.x_oauth2_authorized??!1,{data:H}=(0,l.I)({queryKey:["autopost-logs",j],queryFn:()=>b(j)});(0,i.useEffect)(()=>{R&&m(R)},[R]);let F=(0,r.n)({mutationFn:e=>N(e),onSuccess:()=>{o.oR.success(e("Saved")),t.invalidateQueries({queryKey:["autopost-config"]})},onError:e=>o.oR.error(e.message)}),D=async()=>{if(s)try{await N({x_oauth2_client_id:s.x_oauth2_client_id,x_oauth2_client_secret:s.x_oauth2_client_secret});let t=await v();window.open(t,"_blank","noopener"),o.oR.info(e("Complete authorization in the new tab, then refresh this page"))}catch(e){o.oR.error(e.message)}},$=async s=>{S(s);try{let a=H?.items?.[0]?.id??0;await C(s),o.oR.info(e("Publishing in background, result will appear in history"));let i=Date.now()+48e4,n=async()=>{let s=await b(1),l=s.items?.[0];if(l&&l.id>a){t.invalidateQueries({queryKey:["autopost-logs"]}),"success"===l.status?o.oR.success(e("Published successfully")):o.oR.error(l.detail),S("");return}if(Date.now()>i){o.oR.warning(e("Still running, check history later")),S("");return}setTimeout(()=>void n(),5e3)};setTimeout(()=>void n(),5e3)}catch(e){o.oR.error(e.message),S("")}},q=(e,t)=>m(s=>s?{...s,[e]:t}:s);return P||!s?(0,a.jsxs)(w.Ni,{children:[(0,a.jsx)(w.Ni.Title,{children:e("Auto Posting")}),(0,a.jsx)(w.Ni.Content,{children:(0,a.jsx)(p.E,{className:"h-48 w-full"})})]}):(0,a.jsxs)(w.Ni,{children:[(0,a.jsx)(w.Ni.Title,{children:e("Auto Posting")}),(0,a.jsx)(w.Ni.Description,{children:e("Bind X and WeChat Official Account, auto publish the daily news article every day")}),(0,a.jsx)(w.Ni.Content,{children:(0,a.jsxs)("div",{className:"flex max-w-3xl flex-col gap-5",children:[(0,a.jsxs)(x.Zp,{children:[(0,a.jsx)(x.aR,{children:(0,a.jsxs)(x.ZB,{className:"flex items-center justify-between text-base",children:[e("Auto Posting Master Switch"),(0,a.jsx)(g.d,{checked:s.enabled,onCheckedChange:e=>q("enabled",e)})]})}),(0,a.jsxs)(x.Wu,{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,a.jsx)(k,{label:e("Daily post time (HH:MM)"),value:s.post_time,onChange:e=>q("post_time",e),placeholder:"10:00"}),(0,a.jsx)(k,{label:e("articles.json path on server"),value:s.articles_json_path,onChange:e=>q("articles_json_path",e)})]}),(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:e("Content source is the daily news article generated by news-site; the task picks the article whose date matches today")})]})]}),(0,a.jsxs)(x.Zp,{children:[(0,a.jsx)(x.aR,{children:(0,a.jsxs)(x.ZB,{className:"flex items-center justify-between text-base",children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(d.Vnp,{className:"size-4"})," X (Twitter)"]}),(0,a.jsx)(g.d,{checked:s.x_enabled,onCheckedChange:e=>q("x_enabled",e)})]})}),(0,a.jsxs)(x.Wu,{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[(0,a.jsx)(k,{label:"OAuth 2.0 Client ID",value:s.x_oauth2_client_id,onChange:e=>q("x_oauth2_client_id",e)}),(0,a.jsx)(k,{label:"OAuth 2.0 Client Secret",value:s.x_oauth2_client_secret,onChange:e=>q("x_oauth2_client_secret",e),type:"password"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(u.E,{variant:E?"default":"secondary",children:E?e("Authorized"):e("Not authorized")}),(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:e("Save Client ID/Secret first, then authorize with the posting X account")})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(h.$,{variant:"outline",size:"sm",onClick:()=>void D(),children:E?e("Re-authorize"):e("Authorize X account")}
1),(0,a.jsx)(h.$,{variant:"outline",size:"sm",disabled:""!==A,onClick:()=>void $("x"),children:"x"===A?e("Publishing..."):e("Post article tweet")}),(0,a.jsx)(h.$,{variant:"outline",size:"sm",disabled:""!==A,onClick:()=>void $("x_post"),children:"x_post"===A?e("Publishing..."):e("Post image tweet")})]})]})]})]}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(h.$,{onClick:()=>F.mutate(s),disabled:F.isPending,children:F.isPending?e("Saving..."):e("Save Settings")})}),(0,a.jsxs)(x.Zp,{children:[(0,a.jsx)(x.aR,{children:(0,a.jsx)(x.ZB,{className:"text-base",children:e("Post History")})}),(0,a.jsxs)(x.Wu,{children:[(0,a.jsxs)(f.XI,{children:[(0,a.jsx)(f.A0,{children:(0,a.jsxs)(f.Hj,{children:[(0,a.jsx)(f.nd,{children:e("Platform")}),(0,a.jsx)(f.nd,{children:e("Article Date")}),(0,a.jsx)(f.nd,{children:e("Title")}),(0,a.jsx)(f.nd,{children:e("Status")}),(0,a.jsx)(f.nd,{children:e("Detail")})]})}),(0,a.jsxs)(f.BF,{children:[(H?.items??[]).map(t=>(0,a.jsxs)(f.Hj,{children:[(0,a.jsx)(f.nA,{className:"font-medium",children:"x"===t.platform?"X":t.platform}),(0,a.jsx)(f.nA,{children:t.date}),(0,a.jsx)(f.nA,{className:"max-w-[220px] truncate",children:t.title}),(0,a.jsx)(f.nA,{children:(0,a.jsx)(u.E,{variant:"success"===t.status?"default":"destructive",children:"success"===t.status?e("Success"):e("Failed")})}),(0,a.jsx)(f.nA,{className:"text-muted-foreground max-w-[260px] truncate text-xs",children:t.detail.startsWith("http")?(0,a.jsx)("a",{href:t.detail,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline",children:t.detail}):t.detail})]},t.id)),0===(H?.items??[]).length&&(0,a.jsx)(f.Hj,{children:(0,a.jsx)(f.nA,{colSpan:5,className:"text-muted-foreground py-8 text-center text-sm",children:e("No posts yet")})})]})]}),(H?.total??0)>20&&(0,a.jsxs)("div",{className:"mt-3 flex items-center justify-end gap-2",children:[(0,a.jsx)(h.$,{variant:"outline",size:"sm",disabled:j<=1,onClick:()=>y(e=>e-1),children:e("Previous")}),(0,a.jsxs)("span",{className:"text-muted-foreground text-xs",children:[j," / ",Math.ceil((H?.total??0)/20)]}),(0,a.jsx)(h.$,{variant:"outline",size:"sm",disabled:j>=Math.ceil((H?.total??0)/20),onClick:()=>y(e=>e+1),children:e("Next")})]})]})]})]})})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.