@juejin-opensource/jusage 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/args.d.ts +8 -0
- package/dist/args.js +28 -4
- package/dist/dashboard/assets/dashboard-BR6dGzRU.js +60 -0
- package/dist/dashboard/assets/download-BUH6YifV.js +6 -0
- package/dist/dashboard/assets/{downloads-BGBukFcp.js → downloads-DtzcmlGG.js} +1 -1
- package/dist/dashboard/assets/index-B_TGKfQG.css +1 -0
- package/dist/dashboard/assets/index-BishKKQ3.js +151 -0
- package/dist/dashboard/assets/{index-sxwOKh3b.js → index-tHASxOXL.js} +1 -1
- package/dist/dashboard/assets/{model-provider-z76eVBRd.js → model-provider-DFqk09Xz.js} +1 -1
- package/dist/dashboard/assets/{pricing-Bix3wcTu.js → pricing-Vc67jZDX.js} +1 -1
- package/dist/dashboard/assets/qwenwork-CW5htBDs.ico +0 -0
- package/dist/dashboard/assets/rank-DBiAEOR5.js +16 -0
- package/dist/dashboard/assets/{settings-BItuk443.js → settings-BvNehDGa.js} +1 -1
- package/dist/dashboard/assets/{useLocalStorage-CqfyLuzE.js → useLocalStorage-CmdvKOoP.js} +1 -1
- package/dist/dashboard/brand-logos/command-code.svg +4 -0
- package/dist/dashboard/brand-logos/qwenwork.ico +0 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/index.js +12 -3
- package/dist/service-linux.js +5 -3
- package/dist/service-windows.js +5 -1
- package/dist/service.js +21 -2
- package/package.json +3 -3
- package/dist/dashboard/assets/dashboard-BuoaCKAO.js +0 -55
- package/dist/dashboard/assets/download-Dxb9oVNa.js +0 -6
- package/dist/dashboard/assets/index-D3jJkpMe.css +0 -1
- package/dist/dashboard/assets/index-DLtjtn6U.js +0 -143
- package/dist/dashboard/assets/rank-wigwKGFb.js +0 -16
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{r as n,c as Q,j as e,B as A,a as l,C as O,bd as q,be as Y}from"./index-DLtjtn6U.js";import{r as H,d as D,a as V,g as X,f as ee,D as E,m as se,P as c,C as y,b as te,G as ae,c as ne}from"./downloads-BGBukFcp.js";const re=t=>n.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",viewBox:"0 0 16 16"},t),n.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 2.5H8A1.5 1.5 0 0 0 6.5 4v1H8a3 3 0 0 1 3 3v1.5h1A1.5 1.5 0 0 0 13.5 8V4A1.5 1.5 0 0 0 12 2.5M11 11h1a3 3 0 0 0 3-3V4a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v1H4a3 3 0 0 0-3 3v4a3 3 0 0 0 3 3h4a3 3 0 0 0 3-3zM4 6.5h4A1.5 1.5 0 0 1 9.5 8v4A1.5 1.5 0 0 1 8 13.5H4A1.5 1.5 0 0 1 2.5 12V8A1.5 1.5 0 0 1 4 6.5",clipRule:"evenodd"}));/**
|
|
2
|
-
* @license lucide-react v1.24.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const oe=[["path",{d:"M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z",key:"12oyoe"}],["path",{d:"M21 16v2a4 4 0 0 1-4 4h-5",key:"1x7m43"}]],ie=Q("headset",oe),le="/captain-wechat.jpg";function P(){return window.matchMedia("(hover: hover) and (pointer: fine)").matches}function ce(){return e.jsxs("div",{className:"w-52 rounded-xl bg-overlay p-3 text-overlay-foreground shadow-surface",children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"问题反馈"}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-muted",children:"使用问题,建议反馈,可加微信反馈"}),e.jsx("img",{alt:"微信客服二维码:扫码添加 Captain",className:"mt-2.5 block h-auto w-full rounded-lg bg-white",decoding:"async",draggable:!1,height:640,src:le,width:480})]})}function de({variant:t}){const[o,i]=n.useState(!1),x=n.useRef(null),d=t==="link";return n.useEffect(()=>{if(!o)return;const f=h=>{var m;(m=x.current)!=null&&m.contains(h.target)||i(!1)},v=h=>{h.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",f),document.addEventListener("keydown",v),()=>{document.removeEventListener("pointerdown",f),document.removeEventListener("keydown",v)}},[o]),e.jsxs("div",{ref:x,className:"relative inline-flex",onMouseEnter:()=>{P()&&i(!0)},onMouseLeave:()=>{P()&&i(!1)},children:[e.jsx(A,{"aria-expanded":o,"aria-haspopup":"dialog","aria-label":"问题反馈",className:d?l("h-7 min-h-7 min-w-7 shrink-0 p-0 text-foreground/70 shadow-none","hover:bg-transparent hover:text-foreground","data-[pressed=true]:bg-transparent"):"size-8 min-h-8 min-w-8 shrink-0 p-0",isIconOnly:!0,size:"sm",variant:d?"ghost":"tertiary",onPress:()=>i(f=>!f),children:e.jsx(ie,{"aria-hidden":"true",className:d?"size-4.5":"size-4",strokeWidth:2})}),o?e.jsx("div",{className:l("absolute z-50",d?"bottom-full left-1/2 -translate-x-1/2 pb-2":"top-full right-0 pt-2"),role:"dialog","aria-label":"问题反馈",children:e.jsx(ce,{})}):null]})}const ue={new_user:{badge:"Juejin Usage",headline:["Cursor、Claude、Codex","多工具 Token 与费用","本地面板一张表看完。"],description:"汇总你实际在用的 AI 编码工具用量与趋势,安装后即可查看。"},uninstalled:{badge:"客户端暂未连接",headline:["客户端暂未连接","启动后继续","同步本机用量。"],description:"下载并打开 Juejin Usage,即可把本机 AI 用量同步回这块面板。"}},fe="/e1.png",_=[{id:"install-start",label:"npm",command:"npm i -g @juejin-opensource/jusage && jusage service start"},{id:"npx",label:"npx",command:"npx @juejin-opensource/jusage start"}],U="tud.downloadTarget";function G(){try{const t=sessionStorage.getItem(U);if(t&&E.some(o=>o.id===t))return t}catch{}return null}function me(t){try{sessionStorage.setItem(U,t)}catch{}}function xe({reason:t}){const o=ue[t],[i,x]=n.useState(()=>{const s=G();return s||(typeof navigator>"u"?"macos-arm":H(V(navigator.userAgent,navigator.platform),D(navigator.userAgent)))}),[d,f]=n.useState({}),[v,h]=n.useState(),[m,z]=n.useState(!1),[w,M]=n.useState(!1),[R,W]=n.useState("npx"),[p,N]=n.useState(!1),[I,Z]=n.useState(null),T=n.useRef(G()!==null),g=X(i),$=ne(v),k=_.find(s=>s.id===R)??_[0];n.useEffect(()=>{var u,b;let s=!1;const a=navigator,r=(j,K)=>{var L;s||T.current||x(H(V(a.userAgent,a.platform,K??((L=a.userAgentData)==null?void 0:L.platform)??""),D(a.userAgent,j)))};return r(),(b=(u=a.userAgentData)==null?void 0:u.getHighEntropyValues)==null||b.call(u,["architecture","platform"]).then(j=>{r(j.architecture,j.platform)}).catch(()=>{}),()=>{s=!0}},[]),n.useEffect(()=>{let s=!1;return ee().then(a=>{if(s)return;const r={};for(const u of E){const b=se(a.assets,u.id);b&&(r[u.id]=b)}f(r),h(a.source)}).catch(()=>{}),()=>{s=!0}},[]),n.useEffect(()=>{if(!p)return;const s=window.setTimeout(()=>N(!1),1600);return()=>window.clearTimeout(s)},[p]),n.useEffect(()=>{let s=!1;return fetch("https://api.github.com/repos/juejin-cn/juejin-usage",{headers:{Accept:"application/vnd.github+json"}}).then(a=>a.ok?a.json():null).then(a=>{const r=a==null?void 0:a.stargazers_count;s||typeof r!="number"||!Number.isFinite(r)||Z(he(r))}).catch(()=>{}),()=>{s=!0}},[]);const F=s=>{const a=d[s]??$,r=document.createElement("a");r.href=a,r.rel="noopener noreferrer",r.target="_blank",d[s]&&(r.download=""),document.body.append(r),r.click(),r.remove()},J=async()=>{try{await navigator.clipboard.writeText(k.command),N(!0)}catch{N(!1)}};return e.jsx("section",{className:"flex min-h-[calc(100svh-9rem)] items-start pt-4 pb-10 sm:pt-6 sm:pb-14 lg:pt-8",children:e.jsxs("div",{className:"flex w-full flex-col gap-14 sm:gap-16 lg:gap-20",children:[e.jsxs("div",{className:"grid w-full items-start gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)] lg:gap-16 xl:gap-20",children:[e.jsxs("div",{className:"max-w-2xl motion-safe:animate-[fade-up_420ms_ease-out] lg:max-w-none",children:[e.jsxs("p",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-base text-muted",children:[e.jsx("span",{children:o.badge}),e.jsx("span",{"aria-hidden":"true",className:"text-foreground/25",children:"·"}),g.os==="windows"?e.jsx(S,{className:"size-4 text-foreground/70"}):e.jsx(C,{className:"size-4 text-foreground/70"}),e.jsxs("span",{children:["适用于 ",g.badgePlatform]})]}),e.jsxs("h1",{className:"mt-6 text-[2.15rem] leading-[1.15] font-semibold tracking-tight text-foreground sm:text-5xl sm:leading-[1.12] lg:text-[3.15rem] lg:leading-[1.1]",children:[o.headline[0],e.jsx("br",{}),o.headline[1],e.jsx("br",{}),o.headline[2]]}),e.jsx("p",{className:"mt-5 max-w-xl text-lg leading-8 text-muted",children:o.description}),e.jsxs("div",{className:"mt-9 flex flex-col gap-4",children:[e.jsxs("div",{"aria-label":"下载客户端",className:"inline-flex max-w-full shrink-0 overflow-hidden rounded-full shadow-[0_1px_2px_rgb(0_0_0/0.06)]",role:"group",children:[e.jsxs("button",{className:l(B,"rounded-l-full ps-6 pe-5"),type:"button",onClick:()=>F(i),children:[g.os==="windows"?e.jsx(S,{className:"size-4.5"}):e.jsx(C,{className:"size-4.5"}),g.label]}),e.jsxs(c,{isOpen:m,onOpenChange:z,children:[e.jsx(A,{"aria-expanded":m,"aria-haspopup":"menu","aria-label":"选择其它系统",className:l(B,"h-14! min-h-14! min-w-14 rounded-l-none rounded-r-full border-0 p-0 shadow-none","bg-[#1e80ff]! text-white! hover:bg-[#1171ee]!","relative before:absolute before:inset-y-2.5 before:left-0 before:w-px before:bg-white/30","dark:bg-[#4b9cff]! dark:hover:bg-[#3a8ff0]!"),isIconOnly:!0,variant:"primary",children:e.jsx(O,{"aria-hidden":"true",className:l("size-4.5 transition-transform duration-200 motion-reduce:transition-none",m&&"rotate-180")})}),e.jsx(c.Content,{className:"min-w-56 overflow-hidden rounded-[10px] border-0 bg-overlay p-0 text-overlay-foreground shadow-surface",placement:"bottom start",children:e.jsxs(c.Dialog,{className:"p-0 outline-none",children:[e.jsx(c.Heading,{className:"sr-only",children:"选择下载平台"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:E.map(s=>{const a=s.id===i;return e.jsxs("button",{"aria-current":a?"true":void 0,className:l("flex min-h-11 w-full cursor-pointer items-center gap-2 px-3 text-left text-sm","transition-colors duration-150","hover:bg-surface-secondary","focus-visible:bg-surface-secondary focus-visible:outline-none",a?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{T.current=!0,me(s.id),x(s.id),z(!1)},children:[s.os==="windows"?e.jsx(S,{className:"size-4 text-foreground/70"}):e.jsx(C,{className:"size-4 text-foreground/70"}),e.jsx("span",{className:"min-w-0 flex-1",children:s.menuLabel}),a?e.jsx(y,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):null]},s.id)})})]})})]})]}),e.jsxs("div",{className:"flex min-h-14 min-w-0 max-w-2xl items-center gap-2 rounded-2xl border border-border bg-surface-secondary/80 p-2 ps-3 dark:bg-overlay/60",children:[e.jsxs(c,{isOpen:w,onOpenChange:M,children:[e.jsxs(A,{"aria-expanded":w,"aria-haspopup":"menu","aria-label":"选择 CLI 启动方式",className:"h-10 min-h-10 shrink-0 gap-1 rounded-full bg-background/80 px-3 text-xs font-medium text-foreground shadow-none hover:bg-background dark:bg-black/10 dark:hover:bg-black/20",variant:"secondary",children:[e.jsx("span",{children:k.label}),e.jsx(O,{"aria-hidden":"true",className:l("size-3.5 transition-transform duration-200 motion-reduce:transition-none",w&&"rotate-180")})]}),e.jsx(c.Content,{className:"min-w-60 overflow-hidden rounded-[10px] border-0 bg-overlay p-0 text-overlay-foreground shadow-surface",placement:"bottom start",children:e.jsxs(c.Dialog,{className:"p-0 outline-none",children:[e.jsx(c.Heading,{className:"sr-only",children:"选择 CLI 启动方式"}),e.jsx("div",{className:"flex flex-col py-1",role:"menu",children:_.map(s=>{const a=s.id===R;return e.jsxs("button",{"aria-current":a?"true":void 0,className:l("flex min-h-11 w-full cursor-pointer items-center gap-2 px-3 text-left text-sm","transition-colors duration-150 hover:bg-surface-secondary","focus-visible:bg-surface-secondary focus-visible:outline-none",a?"text-foreground":"text-foreground/80"),role:"menuitem",type:"button",onClick:()=>{W(s.id),M(!1)},children:[e.jsx("span",{className:"min-w-0 flex-1",children:s.label}),a?e.jsx(y,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):null]},s.id)})})]})})]}),e.jsx("div",{className:"min-w-0 flex-1 overflow-hidden rounded-xl bg-background/75 px-3 py-2 dark:bg-black/10",children:e.jsxs("code",{className:"block overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground/85 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:["$ ",k.command]})}),e.jsx("button",{"aria-label":p?"安装命令已复制":"复制 CLI 安装命令",className:l("inline-flex size-11 shrink-0 items-center justify-center rounded-full","text-muted transition-colors duration-150","hover:bg-background hover:text-foreground","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent","touch-manipulation"),type:"button",onClick:()=>{J()},children:p?e.jsx(y,{"aria-hidden":"true",className:"size-4 text-[#1e80ff] dark:text-[#4b9cff]"}):e.jsx(re,{"aria-hidden":"true",className:"size-4"})})]})]}),e.jsx("p",{"aria-live":"polite",className:"sr-only",children:p?"安装命令已复制":""}),e.jsxs("p",{className:"mt-5 flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted",children:[e.jsx("span",{children:g.requirement}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:"CLI 需 Node.js 20+"}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsxs("a",{className:"inline-flex items-center gap-1 text-foreground/70 transition-colors hover:text-foreground",href:te,rel:"noopener noreferrer",target:"_blank",children:[e.jsx(ge,{className:"size-3.5"}),"Gitee"]}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx(de,{variant:"link"})]}),e.jsxs("a",{"aria-label":"在 GitHub 上 Star 本项目",className:"mt-4 flex w-full max-w-xl items-center gap-4 rounded-2xl border border-border bg-surface-secondary/80 px-5 py-4 shadow-[0_1px_2px_rgb(0_0_0/0.06)] outline-offset-2 transition-colors hover:bg-surface-secondary focus-visible:outline-2 focus-visible:outline-accent dark:bg-overlay/60 dark:hover:bg-overlay/80",href:ae,rel:"noopener noreferrer",target:"_blank",children:[e.jsx(pe,{className:"size-8 shrink-0"}),e.jsxs("span",{className:"min-w-0",children:[e.jsxs("span",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-base font-medium text-foreground",children:"⭐️ Star"}),I?e.jsx("span",{className:"text-sm font-medium tabular-nums text-foreground/55",children:I}):null]}),e.jsx("span",{className:"mt-0.5 block text-sm leading-6 text-muted",children:"开源共享,欢迎提 Issue 与贡献代码"})]})]})]}),e.jsx("div",{className:"min-w-0 motion-safe:animate-[fade-up_520ms_ease-out]",children:e.jsx("figure",{className:"overflow-hidden rounded-2xl border border-border/80 bg-surface shadow-[0_24px_48px_-28px_rgb(15_23_42/0.45)] dark:shadow-[0_24px_48px_-24px_rgb(0_0_0/0.65)]",children:e.jsx("img",{alt:"Juejin Usage 用量看板界面预览:费用、Token、热力图与趋势图",className:"h-auto w-full",decoding:"async",fetchPriority:"high",height:1560,src:fe,width:2102})})})]}),e.jsxs("section",{"aria-labelledby":"supported-tools-heading",className:"w-full",children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight text-foreground sm:text-xl",id:"supported-tools-heading",children:"支持的工具"}),e.jsx("div",{className:"mt-4",children:e.jsx(q,{className:"lg:grid-cols-3",collapsible:!0})})]})]})})}const B=l("inline-flex h-14 min-h-14 cursor-pointer items-center justify-center gap-2.5","bg-[#1e80ff] text-base font-medium whitespace-nowrap text-white","transition-colors duration-200 motion-reduce:transition-none","hover:bg-[#1171ee] active:brightness-[0.96]","focus-visible:z-10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#1e80ff]","dark:bg-[#4b9cff] dark:hover:bg-[#3a8ff0] dark:focus-visible:outline-[#4b9cff]","touch-manipulation");function he(t){if(t<1e3)return String(Math.floor(t));const o=t/1e3,i=t>=1e4?0:1;return`${o.toFixed(i).replace(/\.0$/,"")}k`}function pe({className:t}){return e.jsx("svg",{"aria-hidden":"true",className:t,fill:"currentColor",focusable:"false",overflow:"visible",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M10.226 17.284c-2.965-.36-5.054-2.493-5.054-5.256 0-1.123.404-2.336 1.078-3.144-.292-.741-.247-2.314.09-2.965.898-.112 2.111.36 2.83 1.01.853-.269 1.752-.404 2.853-.404 1.1 0 1.999.135 2.807.382.696-.629 1.932-1.1 2.83-.988.315.606.36 2.179.067 2.942.72.854 1.101 2 1.101 3.167 0 2.763-2.089 4.852-5.098 5.234.763.494 1.28 1.572 1.28 2.807v2.336c0 .674.561 1.056 1.235.786 4.066-1.55 7.255-5.615 7.255-10.646C23.5 6.188 18.334 1 11.978 1 5.62 1 .5 6.188.5 12.545c0 4.986 3.167 9.12 7.435 10.669.606.225 1.19-.18 1.19-.786V20.63a2.9 2.9 0 0 1-1.078.224c-1.483 0-2.359-.808-2.987-2.313-.247-.607-.517-.966-1.034-1.033-.27-.023-.359-.135-.359-.27 0-.27.45-.471.898-.471.652 0 1.213.404 1.797 1.235.45.651.921.943 1.483.943.561 0 .92-.202 1.437-.719.382-.381.674-.718.944-.943"})})}function C({className:t}){return e.jsx("svg",{"aria-hidden":"true",className:t,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})})}function ge({className:t}){return e.jsx("svg",{"aria-hidden":"true",className:t,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M11.984 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.016 0zm6.09 5.333c.328 0 .593.266.592.593v1.482a.594.594 0 0 1-.593.592H9.777c-.982 0-1.778.796-1.778 1.778v5.63c0 .327.266.592.593.592h5.63c.982 0 1.778-.796 1.778-1.778v-.296a.593.593 0 0 0-.592-.593h-4.15a.592.592 0 0 1-.592-.592v-1.482a.593.593 0 0 1 .593-.592h6.815c.327 0 .593.265.593.592v3.408a4 4 0 0 1-4 4H5.926a.593.593 0 0 1-.593-.593V9.778a4.444 4.444 0 0 1 4.445-4.444h8.296z"})})}function S({className:t}){return e.jsx("svg",{"aria-hidden":"true",className:t,fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 5.2 11.2 4v7.4H3V5.2Zm8.9-1.4L21 2.6v8.8h-9.1V3.8ZM3 13.4h8.2V21L3 19.7v-6.3Zm8.9 0H21V21.4l-9.1-1.3v-6.7Z"})})}function je(){const t=Y(),o=(t==null?void 0:t.reason)==="uninstalled"?"uninstalled":"new_user";return e.jsx(xe,{reason:o})}export{je as component};
|