@acedatacloud/nexior 3.291.10 → 3.291.11
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/assets/{ApiCodeButton-m1-nG6C9.js → ApiCodeButton-CW-kqqzQ.js} +1 -1
- package/dist/assets/{AskUserQuestionCard-Dg3hgRvy.js → AskUserQuestionCard-D_GabaKq.js} +1 -1
- package/dist/assets/{Auth-CO-PN6yf.js → Auth-BEGdfLoE.js} +1 -1
- package/dist/assets/{Bare-BR0RQAzM.js → Bare-BuBXfNIp.js} +1 -1
- package/dist/assets/{BotPlaceholder-CvDNZH-6.js → BotPlaceholder-B-QupzkZ.js} +1 -1
- package/dist/assets/{BottomFooter-BSHy3JmE.js → BottomFooter-DPR3PCMr.js} +1 -1
- package/dist/assets/{Callback-BZ9QTZEH.js → Callback-DJqHSe0N.js} +1 -1
- package/dist/assets/{CodeSnippet-VuGoWzWw.js → CodeSnippet-Dmg9h9SG.js} +1 -1
- package/dist/assets/{Console-B-T02qaO.js → Console-CofC3APf.js} +1 -1
- package/dist/assets/{Consumption-D-wq120u.js → Consumption-bKv-wyaI.js} +1 -1
- package/dist/assets/{Conversation-B18kdZd3.css → Conversation-CYbL_dy0.css} +1 -1
- package/dist/assets/Conversation-U9rh8Dmx.js +3 -0
- package/dist/assets/{CopyToClipboard-CzuAFvmK.js → CopyToClipboard-CfaMivRn.js} +1 -1
- package/dist/assets/{Detail-PULggNsl.js → Detail-BdnLBZ3G.js} +2 -2
- package/dist/assets/{Extra-B3tcZUS6.js → Extra-B5r7uTT5.js} +1 -1
- package/dist/assets/{FilePreview-C6Fyeam3.js → FilePreview-Dn8upPyG.js} +1 -1
- package/dist/assets/{Hailuo-BNm4IK3e.js → Hailuo-mXOkenDP.js} +1 -1
- package/dist/assets/{History-BxZ08TkS.js → History-Cn_iBAWg.js} +1 -1
- package/dist/assets/{ImagePreview-BbSjhE3X.js → ImagePreview-D89mob6D.js} +1 -1
- package/dist/assets/{ImageWrapper-Bsh2vHLQ.js → ImageWrapper-ey-QKSI9.js} +1 -1
- package/dist/assets/{Index-DH_XyIE5.js → Index-3wEUGr2F.js} +1 -1
- package/dist/assets/{Index-C4-tgvBp.js → Index-7qZkX16N.js} +1 -1
- package/dist/assets/{Index-CpPwoMYG.js → Index-9J8_gd4l.js} +1 -1
- package/dist/assets/{Index-018W_aTd.js → Index-B9m7p7lE.js} +1 -1
- package/dist/assets/{Index-8cltukxS.js → Index-BKqidMN2.js} +1 -1
- package/dist/assets/{Index-DdzFomgm.js → Index-BhzrYvyU.js} +1 -1
- package/dist/assets/{Index-BjahUwZN.js → Index-BkFxlR5l.js} +1 -1
- package/dist/assets/{Index--VAV-R-C.js → Index-BlvX_SKq.js} +1 -1
- package/dist/assets/{Index-CXWleIoZ.js → Index-C435pOiW.js} +1 -1
- package/dist/assets/{Index-Cg35KIZ2.js → Index-C6epQMRr.js} +1 -1
- package/dist/assets/{Index-B71up98Q.js → Index-CCvCMb8m.js} +1 -1
- package/dist/assets/{Index-DeBfSNED.js → Index-CDr_mya3.js} +1 -1
- package/dist/assets/{Index-BAg2MszI.js → Index-CMTEcrvv.js} +1 -1
- package/dist/assets/{Index-CdqSJDnn.js → Index-CSwA6_DF.js} +1 -1
- package/dist/assets/Index-Ce6AcFMV.js +1 -0
- package/dist/assets/{Index-BDuJ74Gt.js → Index-CryupUVF.js} +1 -1
- package/dist/assets/{Index-BYC-VrMT.js → Index-CvPy6kop.js} +1 -1
- package/dist/assets/Index-Cw2tmAEC.js +1 -0
- package/dist/assets/{Index-o4Z1NRwO.js → Index-DM6_b1c4.js} +1 -1
- package/dist/assets/{Index-BGyOJ_oR.js → Index-DPNfnTG-.js} +1 -1
- package/dist/assets/Index-DdKLmOt6.js +1 -0
- package/dist/assets/{Index-Wf1iwcSd.js → Index-IeoXUb6-.js} +1 -1
- package/dist/assets/Index-ImQkqrDh.js +1 -0
- package/dist/assets/{Index-Cw2JJpVA.js → Index-MbOA9Evt.js} +1 -1
- package/dist/assets/{Index-Ca6IR8YE.js → Index-fBpyCgxw.js} +1 -1
- package/dist/assets/Index-hBvbkcLh.js +1 -0
- package/dist/assets/{Index-Dt17zXYt.js → Index-swJp5qqV.js} +1 -1
- package/dist/assets/{Index-BBL4gIFo.js → Index-ylb_f17A.js} +1 -1
- package/dist/assets/{Invitees-C3B41hYM.js → Invitees-PcUR5Utg.js} +1 -1
- package/dist/assets/List-4eSzlDYt.js +1 -0
- package/dist/assets/List-DS-Uw-5_.js +1 -0
- package/dist/assets/{List-DFrXVvXm.js → List-y6T5QP_0.js} +1 -1
- package/dist/assets/{Main-BIaUAoDK.js → Main-DWWqWt_9.js} +1 -1
- package/dist/assets/Model-D_CAxgJN.js +1 -0
- package/dist/assets/{Navigator-QatmLuno.js → Navigator-DtlLm4nK.js} +2 -2
- package/dist/assets/{NoTasks-DGOvAWhI.js → NoTasks-CDng3NmE.js} +1 -1
- package/dist/assets/{NotFound-swKjdc-V.js → NotFound-Bw4jfVSZ.js} +1 -1
- package/dist/assets/{Pagination-DEohLcGY.js → Pagination-BDXF90km.js} +1 -1
- package/dist/assets/Pay-CZNUHWoR.js +1 -0
- package/dist/assets/{Player-CC6sxf2q.js → Player-BhUyiaYc.js} +1 -1
- package/dist/assets/{PromptTextarea-zsXcHGSi.js → PromptTextarea-CA5QkASc.js} +1 -1
- package/dist/assets/{RealtimeCall-BR4Rxg_X.js → RealtimeCall-Dp61X_Tf.js} +1 -1
- package/dist/assets/{ScheduledTasks-Cl5PeOLH.js → ScheduledTasks-DvLoYsBZ.js} +2 -2
- package/dist/assets/{Status-6EqywYbR.js → Status-vzlZd2A6.js} +1 -1
- package/dist/assets/{Subscribe-CJSvThmD.js → Subscribe-BdGhBOaA.js} +1 -1
- package/dist/assets/{TabSwitcher-DkGyBniJ.js → TabSwitcher-DUgIYUY0.js} +1 -1
- package/dist/assets/Tts-Dt0rZ_dY.js +1 -0
- package/dist/assets/{VideoPlayer-DT13fzbF.js → VideoPlayer-DOi6kG5-.js} +1 -1
- package/dist/assets/{avatar-BynQEDNq.js → avatar-DHPPWDZI.js} +1 -1
- package/dist/assets/{basic-DciRT-lY.js → basic-YSB16B1s.js} +1 -1
- package/dist/assets/{chat-B_jWZ3bV.js → chat-CfRYLWIY.js} +1 -1
- package/dist/assets/{codingBridge-DV2KkL2G.js → codingBridge-CjPiohmH.js} +2 -2
- package/dist/assets/{codingBridgeNotify-CwPVhdup.js → codingBridgeNotify-BqXuGufB.js} +2 -2
- package/dist/assets/{collapse-D6n4QRob.js → collapse-BQ8N4Try.js} +1 -1
- package/dist/assets/{createTaskActions-D5ucsmU_.js → createTaskActions-Bkw5AnEo.js} +1 -1
- package/dist/assets/{date-picker-BA2lbsxl.js → date-picker-DZJ1K7pP.js} +1 -1
- package/dist/assets/{digitalhuman-DPAqIsbc.js → digitalhuman-B6igrEKk.js} +1 -1
- package/dist/assets/{dropdown-CfSmPJ19.js → dropdown-Uf4EPjG-.js} +1 -1
- package/dist/assets/{esm-CDcPLEoK.js → esm-C5sPhYZ5.js} +2 -2
- package/dist/assets/{esm-CbMmz5QC.js → esm-CZ9remQA.js} +1 -1
- package/dist/assets/{esm-BD6WYid4.js → esm-CakVkZCg.js} +1 -1
- package/dist/assets/{esm-DGqHhF-h.js → esm-D7kzvho2.js} +1 -1
- package/dist/assets/esm-D97ZH1xy.js +1 -0
- package/dist/assets/{esm-B8BpTgL7.js → esm-Du3cxl_4.js} +2 -2
- package/dist/assets/{esm-DKo6gOwt.js → esm-Er6XkU5t.js} +3 -3
- package/dist/assets/{fish-B720GYzF.js → fish-DLYfsTcG.js} +1 -1
- package/dist/assets/{flux-xVEuHMju.js → flux-CJgnBFg8.js} +1 -1
- package/dist/assets/{grokvideo-CqoMzG3i.js → grokvideo-D1SUkMab.js} +1 -1
- package/dist/assets/{pika-OcnOKCin.js → hailuo-Bkm8oFUq.js} +1 -1
- package/dist/assets/{headshots-BV7-KNtj.js → headshots-Ck3avPrB.js} +1 -1
- package/dist/assets/{image-D6Ula-vB.js → image-CJhr3AFE.js} +1 -1
- package/dist/assets/{index-BSyVXYs6.js → index-CZO1Gi94.js} +10 -10
- package/dist/assets/{index.browser.esm-BbWV5Chb.js → index.browser.esm-BNn8hJsX.js} +1 -1
- package/dist/assets/{index.es-1ILd8U96.js → index.es-CLoebfsT.js} +1 -1
- package/dist/assets/{input-number-C4BVgatM.js → input-number-CTpfAAxn.js} +1 -1
- package/dist/assets/{kling-C6zlqM7k.js → kling-CZQVayzV.js} +1 -1
- package/dist/assets/{qrart-xh6NtERL.js → luma-C6_7MdZQ.js} +1 -1
- package/dist/assets/{sora-B4T6Lsz0.js → maestro-CUgeqAil.js} +1 -1
- package/dist/assets/{midjourney-DDNzXVgO.js → midjourney-D6UIYxut.js} +1 -1
- package/dist/assets/{nanobanana-C3HD0lOU.js → nanobanana-BIGI3K7Q.js} +1 -1
- package/dist/assets/{openaiimage-B08O3ZAy.js → openaiimage-CvShnOv4.js} +1 -1
- package/dist/assets/{pagination-CLZh1y4K.js → pagination-BreitTL1.js} +2 -2
- package/dist/assets/{hailuo-DP1asAjo.js → pika-Dh2T1KRD.js} +1 -1
- package/dist/assets/pixverse-D9yePGph.js +1 -0
- package/dist/assets/{popover-BlqNz3Q4.js → popover-DDmZXwG-.js} +1 -1
- package/dist/assets/{producer-DPngeto7.js → producer-C0Mgepui.js} +1 -1
- package/dist/assets/{luma-BjCxBiaM.js → qrart-Dpufh9VB.js} +1 -1
- package/dist/assets/realtime-BOMGlCLD.js +1 -0
- package/dist/assets/{row-BTBWqAH2.js → row-CoiUfzQY.js} +1 -1
- package/dist/assets/{seedance-BHbjdbZz.js → seedance-BgmJDjfA.js} +1 -1
- package/dist/assets/{seedream-B7w6kkqy.js → seedream-DF4LAAKt.js} +1 -1
- package/dist/assets/{select-BRwrjMa2.js → select-BRFOPLGq.js} +1 -1
- package/dist/assets/{serp-CVAHodxm.js → serp-CnqEGi20.js} +1 -1
- package/dist/assets/{slider-C7Lxb4iZ.js → slider-D3ebEeLN.js} +1 -1
- package/dist/assets/{solana-wallets-B9KpMW2x.js → solana-wallets-BkVKjWtn.js} +2 -2
- package/dist/assets/{solana-wallets-vue-SVDZ227v.js → solana-wallets-vue-YYLLA-Aj.js} +1 -1
- package/dist/assets/{maestro-CKyoCK_2.js → sora-D9gIjl0b.js} +1 -1
- package/dist/assets/{suno-D1UT7kGT.js → suno-B0kqY112.js} +1 -1
- package/dist/assets/{switch-Cj731jri.js → switch-EzOTmpa3.js} +1 -1
- package/dist/assets/{tabs-BzAgLM9R.js → tabs-DDSPHTwc.js} +1 -1
- package/dist/assets/{time-picker-BuFfHlPg.js → time-picker-BOH65hcx.js} +1 -1
- package/dist/assets/{upload-DGg583nI.js → upload-CtWAL12L.js} +1 -1
- package/dist/assets/{veo-BYdB2EtE.js → veo-c2SLMseI.js} +1 -1
- package/dist/assets/{wan-DFVU0XbI.js → wan-CYzDeMQA.js} +1 -1
- package/dist/assets/{web-CK833YjN.js → web-B4_nnRTI.js} +1 -1
- package/dist/assets/web-Cz1r5107.js +1 -0
- package/dist/assets/{web-LZX6qX0C.js → web-FLxg-xwR.js} +1 -1
- package/dist/assets/{web-CaK8oCfA.js → web-bmNGi-BA.js} +1 -1
- package/dist/assets/{web-Az-ioOGa.js → web-wvqaMwIQ.js} +1 -1
- package/dist/assets/webextrator-CxaameNy.js +1 -0
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/Conversation-DJdxp2HK.js +0 -3
- package/dist/assets/Index-BUw5yQUe.js +0 -1
- package/dist/assets/Index-CFfOShNi.js +0 -1
- package/dist/assets/Index-Dnnvgwaz.js +0 -1
- package/dist/assets/Index-DxExKnON.js +0 -1
- package/dist/assets/Index-OUkDK8qi.js +0 -1
- package/dist/assets/List-CGD29v9C.js +0 -1
- package/dist/assets/List-suVchB7k.js +0 -1
- package/dist/assets/Model-D4hf7J91.js +0 -1
- package/dist/assets/Pay-BdAyZwsc.js +0 -1
- package/dist/assets/Tts-CYIHLLq8.js +0 -1
- package/dist/assets/esm-BvTi9Mvu.js +0 -1
- package/dist/assets/pixverse-DAURCgBO.js +0 -1
- package/dist/assets/realtime-AFPYStuG.js +0 -1
- package/dist/assets/web-D1-EAbj2.js +0 -1
- package/dist/assets/webextrator-BAYcHku-.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,a as u,c as d,dt as f,i as p,k as m,n as h,nt as g,o as _,r as v,s as y,t as b,tt as x,ut as S,v as ee}from"./vendor-chart-BJCvKk8-.js";import{t as C}from"./button-BydTr5nV.js";import{r as w,t as T}from"./select-BRFOPLGq.js";import{n as E,t as D}from"./table-BJr3w4hQ.js";import{n as O,t as k}from"./tabs-DDSPHTwc.js";import{t as A}from"./card-DjyfNde2.js";import{n as j,r as M}from"./radio-3Hz7h3DR.js";import{t as N}from"./date-picker-DZJ1K7pP.js";import{n as P,t as F}from"./row-CoiUfzQY.js";import{t as I}from"./Pagination-BDXF90km.js";import{n as L,t as R}from"./skeleton-BwNBivMN.js";import{Bn as z,E as B,Fn as V,In as H,Jr as U,Kr as W,Pn as G,Sr as K,kr as q,xr as J}from"./index-CZO1Gi94.js";import{t as Y}from"./index.es-CLoebfsT.js";import{t as X}from"./CopyToClipboard-CfaMivRn.js";p.register(v,u,h,y,d,_);var Z=r({name:`ConsoleUsageList`,components:{Pagination:I,ElTag:U,ElDatePicker:N,ElTable:D,ElSelect:w,ElOption:T,CopyToClipboard:X,ElRow:F,ElCol:P,ElTableColumn:E,ElCard:A,ElRadioButton:j,ElRadioGroup:M,ElSkeleton:R,ElSkeletonItem:L,ElDialog:W,ElTabs:O,ElTabPane:k,ElButton:C,FontAwesomeIcon:Y,BarChart:b},data(){return{applicationIds:this.$route.query.application_id?.toString()?this.$route.query.application_id?.toString().split(`,`):[],apiIds:this.$route.query.api_id?.toString()?this.$route.query.api_id?.toString().split(`,`):[],applications:[],apis:[],apisLoading:!1,credentialType:J,serviceType:K,apiUsages:[],proxyUsages:[],createdAtRange:(()=>{let e=this.$route.query.created_at_to?.toString(),t=this.$route.query.created_at_from?.toString();if(t&&e)return[new Date(t),new Date(e)];let n=new Date,r=new Date;return r.setDate(1),r.setHours(0,0,0,0),[r,n]})(),shortcuts:[{text:this.$t(`usage.shortcuts.thisMonth`),value:()=>{let e=new Date,t=new Date;return t.setDate(1),t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.today`),value:()=>{let e=new Date,t=new Date;return t.setHours(0,0,0,0),[t,e]}},{text:this.$t(`usage.shortcuts.last1Day`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-1),[t,e]}},{text:this.$t(`usage.shortcuts.last3Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-3),[t,e]}},{text:this.$t(`usage.shortcuts.last7Days`),value:()=>{let e=new Date,t=new Date;return t.setDate(t.getDate()-7),[t,e]}},{text:this.$t(`usage.shortcuts.last1Month`),value:()=>{let e=new Date,t=new Date;return t.setMonth(t.getMonth()-1),[t,e]}}],type:this.$route.query.type?.toString()||K.API,loading:!1,total:void 0,limit:15,totalUsed:0,barChartLabels:[],barChartSeries:[],aggLoading:!1,detailDialogVisible:!1,detailRow:null,detailActiveTab:`request`,detailLoading:!1,exporting:!1,statusCodeFilter:this.$route.query.status_code?.toString()||``,statusCodeOptions:[],statusCodeOptionsLoading:!1}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},totalUsedString(){return`${(this.totalUsed||0).toFixed(2)}`},barChartData(){return{labels:this.barChartLabels,datasets:this.barChartSeries.map(e=>({label:e.label,data:e.data,backgroundColor:e.color}))}},barChartOptions(){return{responsive:!0,plugins:{legend:{position:`top`,onClick:(e,t,n)=>{let r=n?.chart;if(!r||t?.datasetIndex===void 0)return;let i=t.datasetIndex,a=r.data?.datasets||[];a.some((e,t)=>t!==i&&r.isDatasetVisible(t))?a.forEach((e,t)=>r.setDatasetVisibility(t,t===i)):a.forEach((e,t)=>r.setDatasetVisibility(t,!0)),r.update()}},title:{display:!0,text:this.$t(`usage.title.usageTrend`)}},scales:{x:{stacked:!0},y:{stacked:!0,beginAtZero:!0}}}}},watch:{page:{handler(){this.onFetchUsages()}},type:{handler(){this.applicationIds=[],this.apiIds=[],this.onApplicationsChange(this.applicationIds),this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()}}},mounted(){this.onFetchApplications(),this.onFetchApis(),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},methods:{async onFetchUsages(){this.type===K.API?this.onFetchApiUsages():this.type===K.Proxy&&this.onFetchProxyUsages()},async onApiChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onApisChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,api_id:e&&e.length?e.join(`,`):``}}),this.onFetchApiUsages(),this.onFetchAggregate()},async onTimeRangeChanged(){console.log(`onTimeRangeChanged`,this.createdAtRange),await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,created_at_from:this.createdAtRange?this.$dayjs.format(this.createdAtRange[0].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``,created_at_to:this.createdAtRange?this.$dayjs.format(this.createdAtRange[1].toString(),`YYYY-MM-DDTHH:mm:ss.SSSSSSZ`):``}}),this.onFetchUsages(),this.onFetchAggregate(),this.onFetchStatusCodeOptions()},async onApplicationChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e}}),this.onFetchUsages(),this.onFetchAggregate()},async onApplicationsChange(e){await this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,application_id:e&&e.length?e.join(`,`):``}}),this.onFetchUsages(),this.onFetchAggregate()},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`},getDeductedAmount(e){if(e?.deducted_amount===void 0||e?.deducted_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.deducted_amount?.toFixed(6)} ${t}`},getOriginalAmount(e){if(e?.original_amount===void 0||e?.original_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.original_amount?.toFixed(6)} ${t}`},onStatusCodeChange(e){let t={...this.$route.query},n=(e||``).trim();n?t.status_code=n:delete t.status_code,delete t.status_code_filter,this.$router.push({name:this.$route.name?.toString(),query:t}),this.onFetchUsages(),this.onFetchAggregate()},async onFetchStatusCodeOptions(){this.statusCodeOptionsLoading=!0;try{let{data:e}=await V.getStatusCodes({user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}});this.statusCodeOptions=(e?.items||[]).slice().sort((e,t)=>e-t)}catch{this.statusCodeOptions=[]}finally{this.statusCodeOptionsLoading=!1}},formatElapsed(e){return e==null||Number.isNaN(e)?`-`:e<1?`${Math.round(e*1e3)} ms`:`${e.toFixed(2)} s`},getSimpleMetadata(e){if(!e)return{};let t={};for(let[n,r]of Object.entries(e))n===`request`||n===`response`||typeof r==`object`&&r||(t[n]=r);return t},onShowDetail(e){this.detailRow={...e,metadata:void 0},this.detailActiveTab=`request`,this.detailDialogVisible=!0,this.detailLoading=!0,e.id&&V.get(e.id).then(e=>{this.detailRow=e.data}).finally(()=>{this.detailLoading=!1})},formatJson(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}},onFetchApplications(){z.getAll({limit:100,offset:0,user_id:this.$store.getters.user.id,ordering:`-created_at`,type:q.USAGE}).then(({data:e})=>{this.applications=e.items.filter(e=>e?.service?.type===this.type)}).catch(()=>{})},onFetchApis(){this.apisLoading=!0,G.getAll({limit:100,offset:0,ordering:`-created_at`}).then(({data:e})=>{this.apis=e.items}).catch(()=>{}).finally(()=>{this.apisLoading=!1})},onFetchApiUsages(){console.log(`onFetchApiUsages`,this.createdAtRange),this.loading=!0,V.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{this.apiUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onFetchProxyUsages(){this.loading=!0,H.getAll({limit:this.limit,offset:(this.page-1)*this.limit,user_id:this.$store.getters.user.id,ordering:`-created_at`,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{}}).then(({data:e})=>{this.proxyUsages=e.items,this.loading=!1,this.total=e.count}).catch(()=>{this.loading=!1})},onExport(){this.exporting=!0,V.exportCsv({user_id:this.$store.getters.user.id,...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{},...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.statusCodeFilter?{status_code:this.statusCodeFilter}:{}}).then(({data:e})=>{let t=window.URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usages.csv`,n.click(),window.URL.revokeObjectURL(t)}).catch(()=>{}).finally(()=>{this.exporting=!1})},async onFetchAggregate(){if(this.aggLoading=!0,this.type!==this.serviceType.API)return;let e={user_id:this.$store.getters.user.id,...this.applicationIds&&this.applicationIds.length?{application_id:this.applicationIds}:{},...this.apiIds&&this.apiIds.length?{api_id:this.apiIds}:{},...this.createdAtRange?.[0]?{created_at_from:this.createdAtRange[0]}:{},...this.createdAtRange?.[1]?{created_at_to:this.createdAtRange[1]}:{}};try{let{data:t}=await V.getAggregate(e);this.totalUsed=t.total||0;let n=Array.from(new Set((t.items||[]).map(e=>e.date))).sort(),r=Array.from(new Set((t.items||[]).map(e=>e.api_id))),i=e=>`hsl(${e*57%360}, 70%, 60%)`,a=r.map((e,r)=>{let a=t.apis?.[e]?.title||e,o={};return(t.items||[]).filter(t=>t.api_id===e).forEach(e=>{o[e.date]=e.amount||0}),{key:e,label:a,data:n.map(e=>o[e]||0),color:i(r)}});this.barChartLabels=n,this.barChartSeries=a}finally{this.aggLoading=!1}}}}),Q={class:`text-[26px] font-bold mb-5 text-[var(--el-text-color-primary)]`},$={class:`inline-block w-9`},te={class:`inline-block`},ne={key:1,class:`summary-card`},re={class:`icon-wrapper`},ie={class:`text-left`},ae={class:`description`},oe={class:`value`},se={class:`chart-wrapper`},ce={key:0},le={key:1},ue={class:`flex flex-wrap gap-2`},de={class:`key`},fe={key:0,class:`cursor-pointer`},pe={class:`created-at`},me={class:`created-at`},he={key:1,class:`detail-json`},ge={key:2,class:`text-gray-400`},_e={key:1,class:`detail-json`},ve={key:2,class:`text-gray-400`},ye={class:`float-right`};function be(r,u,d,p,h,_){let v=x(`el-col`),y=x(`el-row`),b=x(`el-radio-button`),C=x(`el-radio-group`),w=x(`el-option`),T=x(`el-select`),E=x(`el-skeleton-item`),D=x(`el-skeleton`),O=x(`el-date-picker`),k=x(`font-awesome-icon`),A=x(`el-button`),j=x(`el-card`),M=x(`bar-chart`),N=x(`el-table-column`),P=x(`el-tag`),F=x(`copy-to-clipboard`),I=x(`el-table`),L=x(`el-tab-pane`),R=x(`el-tabs`),z=x(`el-dialog`),B=x(`pagination`),V=g(`loading`);return l(),a(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[o(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[n(`h2`,Q,c(r.$t(`common.title.allUsages`)),1)]),_:1})]),_:1}),o(y,null,{default:S(()=>[o(v,{md:4,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[n(`span`,null,c(r.$t(`application.field.type`)),1),o(C,{modelValue:r.type,"onUpdate:modelValue":u[0]||=e=>r.type=e},{default:S(()=>[o(b,{value:r.serviceType.API,label:r.$t(`application.field.api`)},null,8,[`value`,`label`]),o(b,{value:r.serviceType.Proxy,label:r.$t(`application.field.proxy`)},null,8,[`value`,`label`])]),_:1},8,[`modelValue`])]),_:1}),f(o(v,{md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[n(`span`,$,c(r.$t(`usage.field.application`)),1),o(T,{modelValue:r.applicationIds,"onUpdate:modelValue":u[1]||=e=>r.applicationIds=e,placeholder:r.$t(`usage.field.application`),clearable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApplicationsChange},{default:S(()=>[(l(!0),t(s,null,e(r.applications,e=>(l(),a(w,{key:e.id,label:e.service?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`])]),_:1},512),[[ee,!1]]),r.type===r.serviceType.API?(l(),a(v,{key:0,md:6,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[n(`span`,te,c(r.$t(`usage.field.api`)),1),r.apisLoading?(l(),a(D,{key:0,animated:``,class:`w-full`},{template:S(()=>[o(E,{variant:`rect`,style:{height:`32px`,"border-radius":`4px`}})]),_:1})):(l(),a(T,{key:1,modelValue:r.apiIds,"onUpdate:modelValue":u[2]||=e=>r.apiIds=e,placeholder:r.$t(`usage.field.api`),clearable:``,filterable:``,multiple:``,"collapse-tags":``,"collapse-tags-tooltip":``,class:`w-full`,onChange:r.onApisChange},{default:S(()=>[(l(!0),t(s,null,e(r.apis,e=>(l(),a(w,{key:e?.id,label:e?.title,value:e?.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`onChange`]))]),_:1})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:1,md:8,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[o(O,{modelValue:r.createdAtRange,"onUpdate:modelValue":u[3]||=e=>r.createdAtRange=e,type:`datetimerange`,class:`w-full`,shortcuts:r.shortcuts,"range-separator":r.$t(`usage.placeholder.to`),"start-placeholder":r.$t(`usage.placeholder.startDate`),"end-placeholder":r.$t(`usage.placeholder.endDate`),onChange:r.onTimeRangeChanged},null,8,[`modelValue`,`shortcuts`,`range-separator`,`start-placeholder`,`end-placeholder`,`onChange`])]),_:1})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:2,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center`},{default:S(()=>[o(T,{modelValue:r.statusCodeFilter,"onUpdate:modelValue":u[4]||=e=>r.statusCodeFilter=e,placeholder:r.$t(`usage.option.statusCodeAll`),class:`w-full`,clearable:``,filterable:``,"allow-create":``,"default-first-option":``,loading:r.statusCodeOptionsLoading,onChange:r.onStatusCodeChange},{default:S(()=>[(l(!0),t(s,null,e(r.statusCodeOptions,e=>(l(),a(w,{key:e,label:String(e),value:String(e)},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`,`placeholder`,`loading`,`onChange`])]),_:1})):m(``,!0),r.type===r.serviceType.API?(l(),a(v,{key:3,md:3,xs:24,class:`mb-5 flex px-2 gap-2 items-center justify-end`},{default:S(()=>[o(A,{type:`primary`,plain:``,loading:r.exporting,class:`w-full whitespace-nowrap`,onClick:r.onExport},{default:S(()=>[o(k,{icon:`fa-solid fa-file-export`,class:`mr-1`}),i(` `+c(r.$t(`usage.button.export`)),1)]),_:1},8,[`loading`,`onClick`])]),_:1})):m(``,!0)]),_:1}),o(y,null,{default:S(()=>[o(v,{span:24},{default:S(()=>[r.type===r.serviceType.API?(l(),a(y,{key:0,gutter:24,class:`mb-5`},{default:S(()=>[o(v,{md:6,xs:24},{default:S(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:S(()=>[r.aggLoading?(l(),a(D,{key:0})):(l(),t(`div`,ne,[n(`div`,re,[o(k,{icon:`fa-solid fa-cubes`,class:`icon`})]),n(`div`,ie,[n(`p`,ae,c(r.$t(`usage.title.totalUsed`)),1),n(`p`,oe,c(r.totalUsedString),1)])]))]),_:1})]),_:1}),o(v,{md:18,xs:24},{default:S(()=>[o(j,{shadow:`hover`,class:`h-full`},{default:S(()=>[n(`div`,se,[r.aggLoading?(l(),a(D,{key:0,class:`w-full`})):(l(),a(M,{key:1,data:r.barChartData,options:r.barChartOptions,class:`chart`},null,8,[`data`,`options`]))])]),_:1})]),_:1})]),_:1})):m(``,!0),o(j,{shadow:`hover`},{default:S(()=>[r.type===r.serviceType.API?f((l(),a(I,{key:0,data:r.apiUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:S(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:S(e=>[n(`span`,null,c(e.row?.api?.title),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.statusCode`),width:`120px`},{default:S(e=>[n(`span`,null,c(e.row.status_code),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.elapsed`),width:`120px`},{default:S(e=>[n(`span`,null,c(r.formatElapsed(e.row.elapsed)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:S(e=>[r.getDeductedAmount(e.row)===r.getOriginalAmount(e.row)?(l(),t(`div`,ce,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)])):(l(),t(`div`,le,[u[7]||=n(`p`,null,null,-1),n(`p`,null,[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),n(`p`,null,[n(`del`,null,c(r.getOriginalAmount(e.row)),1)])]))]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:S(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`260px`,"class-name":`text-center`},{default:S(o=>[n(`div`,ue,[o.row.original_amount>o.row.deducted_amount&&o.row.original_amount>0?(l(),a(P,{key:0,type:`success`,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:S(()=>[i(c(((o.row.original_amount-o.row.deducted_amount)*100/o.row.original_amount).toFixed(0)+`% OFF`),1)]),_:2},1024)):m(``,!0),(l(!0),t(s,null,e(r.getSimpleMetadata(o.row.metadata),(e,t)=>(l(),a(P,{key:t,style:{textWrap:`wrap`,height:`fit-content`,lineHeight:`20px`,borderRadius:`10px`}},{default:S(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))])]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.button.viewDetail`),width:`120px`,"class-name":`text-center`},{default:S(e=>[e.row.id?(l(),a(A,{key:0,type:`primary`,plain:``,size:`small`,class:`!px-2 !py-1 !text-xs !h-auto !min-h-0`,onClick:t=>r.onShowDetail(e.row)},{default:S(()=>[i(c(r.$t(`usage.button.viewDetail`)),1)]),_:1},8,[`onClick`])):m(``,!0)]),_:1},8,[`label`]),o(N,{prop:`trace_id`,label:r.$t(`application.field.traceId`),width:`200px`,"class-name":`text-center`},{default:S(e=>[n(`span`,de,c(e.row.trace_id),1),e.row.trace_id?(l(),t(`span`,fe,[o(F,{content:e.row.trace_id,class:`inline-block`},null,8,[`content`])])):m(``,!0)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:S(e=>[n(`span`,pe,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):m(``,!0),r.type===r.serviceType.Proxy?f((l(),a(I,{key:1,data:r.proxyUsages,stripe:``,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`),class:`min-h-[calc(100vh-350px)] mb-5`},{default:S(()=>[o(N,{label:r.$t(`application.field.name`),width:`160px`},{default:S(e=>[n(`span`,null,c(e.row?.service?.title),1)]),_:1},8,[`label`]),o(N,{prop:`remaining_amount`,label:r.$t(`usage.field.remainingAmount`),width:`160px`,"class-name":`text-center`},{default:S(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1),n(`span`,null,c(r.getOriginalAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`deducted_amount`,label:r.$t(`usage.field.deductedAmount`),width:`150px`,"class-name":`text-center`},{default:S(e=>[n(`span`,null,c(r.getDeductedAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.balanceAfter`),width:`160px`,"class-name":`text-center`},{default:S(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(N,{prop:`metadata`,label:r.$t(`usage.field.metadata`),width:`200px`,"class-name":`text-center`},{default:S(n=>[(l(!0),t(s,null,e(n.row.metadata,(e,t)=>(l(),a(P,{key:t,class:`mb-2`},{default:S(()=>[i(c(t)+`: `+c(e),1)]),_:2},1024))),128))]),_:1},8,[`label`]),o(N,{label:r.$t(`usage.field.createdAt`),width:`200px`},{default:S(e=>[n(`span`,me,c(r.$dayjs.format(e.row.created_at)),1)]),_:1},8,[`label`])]),_:1},8,[`data`,`empty-text`])),[[V,r.loading]]):m(``,!0)]),_:1})]),_:1})]),_:1}),o(z,{modelValue:r.detailDialogVisible,"onUpdate:modelValue":u[6]||=e=>r.detailDialogVisible=e,title:r.$t(`usage.dialog.detailTitle`),width:`70%`,top:`5vh`,"destroy-on-close":``},{default:S(()=>[o(R,{modelValue:r.detailActiveTab,"onUpdate:modelValue":u[5]||=e=>r.detailActiveTab=e},{default:S(()=>[o(L,{label:r.$t(`usage.dialog.request`),name:`request`},{default:S(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.request?(l(),t(`pre`,he,c(r.formatJson(r.detailRow.metadata.request)),1)):(l(),t(`p`,ge,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`]),o(L,{label:r.$t(`usage.dialog.response`),name:`response`},{default:S(()=>[r.detailLoading?(l(),a(D,{key:0,rows:6,animated:``})):r.detailRow?.metadata?.response?(l(),t(`pre`,_e,c(r.formatJson(r.detailRow.metadata.response)),1)):(l(),t(`p`,ve,c(r.$t(`usage.dialog.noData`)),1))]),_:1},8,[`label`])]),_:1},8,[`modelValue`])]),_:1},8,[`modelValue`,`title`]),o(y,null,{default:S(()=>[o(v,{span:10,offset:14},{default:S(()=>[n(`div`,ye,[o(B,{"current-page":r.page,"page-size":r.limit,total:r.total,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var xe=B(Z,[[`render`,be],[`__scopeId`,`data-v-38f1845c`]]);export{xe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-BJr3w4hQ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-BTBWqAH2.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-DEohLcGY.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-Cj731jri.js";import{Dr as w,E as T,H as E,Hr as D,I as O,Lr as k,Or as A,br as j,qr as M,xr as N,zn as P}from"./index-BSyVXYs6.js";import{t as F}from"./index.es-1ILd8U96.js";import{t as I}from"./CopyToClipboard-CzuAFvmK.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:M,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:j,serviceType:N,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return k()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||P.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{D.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{D.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:E,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:O,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=w.INDIVIDUAL){return new Promise((t,n)=>{P.getAll({limit:this.limit,...e===w.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:A.USAGE,scope:e}).then(({data:n})=>{e===w.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{D.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(w.INDIVIDUAL),this.onFetchApplications(w.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){P.create({type:A.USAGE,scope:w.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(w.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=T(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as s,Wt as c,Z as l,dt as u,k as d,nt as f,tt as p,ut as m}from"./vendor-chart-BJCvKk8-.js";import{t as h}from"./button-BydTr5nV.js";import{n as g,t as ee}from"./table-BJr3w4hQ.js";import{t as _}from"./card-DjyfNde2.js";import{n as v,t as y}from"./row-CoiUfzQY.js";import{t as b}from"./empty-CdsD8g84.js";import{t as x}from"./Pagination-BDXF90km.js";import{t as S}from"./skeleton-BwNBivMN.js";import{t as C}from"./switch-EzOTmpa3.js";import{Bn as w,E as T,Jr as E,L as D,Or as O,Rr as k,Sr as A,U as j,Ur as M,kr as N,xr as P}from"./index-CZO1Gi94.js";import{t as F}from"./index.es-CLoebfsT.js";import{t as I}from"./CopyToClipboard-CfaMivRn.js";var L=r({name:`ConsoleApplicationList`,components:{Pagination:x,CopyToClipboard:I,ElTable:ee,ElRow:y,ElButton:h,ElCol:v,ElTag:E,ElSkeleton:S,ElSwitch:C,ElEmpty:b,ElTableColumn:g,ElCard:_,FontAwesomeIcon:F},data(){return{credentialType:P,serviceType:A,individualApplications:[],globalApplications:[],individualApplicationsTotal:void 0,globalApplicationsTotal:void 0,loading:!1,buying:!1,limit:10,form:{amount:1},active:{service:void 0,application:void 0}}},computed:{redirect(){return this.$route.query?.redirect},page(){return parseInt(this.$route.query.page?.toString()||`1`)},showGlobalPayment(){return!0}},watch:{page:{handler(){this.onFetchData()}}},mounted(){this.onInitializeGlobalApplication(),this.onFetchData()},methods:{rowCanPay(e){return k()?(e?.packages||[]).some(e=>e?.metadata?.apple_product_id):!0},updateAllowConsumeGlobal(e,t){!e||!e.id||w.updateAllConsumeGlobal(e.id,{...e,allow_consume_global:!!t}).then(()=>{M.success(this.$t(`application.message.updateSuccessfully`).toString())}).catch(()=>{M.error(this.$t(`application.message.updateFailed`).toString())})},onGoUsage(e){this.$router.push({name:j,query:{application_id:e.id,type:e?.service?.type}})},onBuyMore(e){e?.id&&this.$router.push({name:D,params:{id:e.id}})},onPageChange(e){this.$router.push({name:this.$route.name?.toString(),query:{...this.$route.query,page:e}})},onFetchApplications(e=O.INDIVIDUAL){return new Promise((t,n)=>{w.getAll({limit:this.limit,...e===O.INDIVIDUAL?{offset:(this.page-1)*this.limit}:{},user_id:this.$store.getters.user.id,ordering:`-created_at`,type:N.USAGE,scope:e}).then(({data:n})=>{e===O.INDIVIDUAL?(this.individualApplications=n.items,this.individualApplicationsTotal=n.count):(this.globalApplications=n.items,this.globalApplicationsTotal=n.count),t(n)}).catch(e=>{M.error(this.$t(`application.message.fetchFailed`).toString()),n(e)})})},onFetchData(){this.loading=!0,Promise.all([this.onFetchApplications(O.INDIVIDUAL),this.onFetchApplications(O.GLOBAL)]).then(()=>{this.loading=!1}).catch(()=>{this.loading=!1})},onInitializeGlobalApplication(){w.create({type:N.USAGE,scope:O.GLOBAL,user_id:this.$store.getters.user.id}).finally(()=>{this.onFetchApplications(O.GLOBAL)})},getRemainingAmount(e){if(e.remaining_amount===void 0||e.remaining_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.remaining_amount?.toFixed(6)} ${t}`},getUsedAmount(e){if(e.used_amount===void 0||e.used_amount===null)return``;let t=this.$t(`service.unit.${e?.service?.unit||`credit`}s`);return`${e.used_amount?.toFixed(6)} ${t}`}}}),R={class:`title`},z={key:1,class:`summary-card`},B={class:`icon-wrapper`},V={class:`label`},H={class:`value`},U={class:`description`},W={key:1,class:`flex flex-row justify-between items-center gap-3`},G={class:`summary-card min-w-0 flex-1`},K={class:`flex justify-start items-center gap-2 mb-2 w-full`},q={class:`icon-wrapper !mb-0`},J={class:`text-[var(--el-text-color-regular)] text-[14px] truncate`},te={class:`label`},Y={class:`value`},X={class:`description`},Z={class:`flex flex-col items-end gap-2 shrink-0`},Q={class:`copy`},ne={key:0,class:`expired-at`},re={class:`flex flex-wrap items-center justify-end gap-1`},ie={class:`application-cards block sm:hidden`},ae={class:`flex items-center gap-2 flex-wrap`},oe={class:`application-card__name`},se={class:`application-card__id`},ce={class:`truncate`},le={class:`application-card__row`},ue={class:`label`},de={class:`value`},fe={key:0,class:`application-card__row`},pe={class:`label`},$={class:`value`},me={key:1,class:`application-card__row`},he={class:`label`},ge={class:`flex items-center justify-end gap-2 mt-3`},_e={class:`pagination`};function ve(r,h,g,ee,_,v){let y=p(`el-col`),b=p(`el-row`),x=p(`el-skeleton`),S=p(`font-awesome-icon`),C=p(`el-card`),w=p(`copy-to-clipboard`),T=p(`el-button`),E=p(`el-table-column`),D=p(`el-tag`),O=p(`el-switch`),k=p(`el-table`),A=p(`el-empty`),j=p(`pagination`),M=f(`loading`);return l(),a(b,{class:`application-list`},{default:m(()=>[o(y,{span:24},{default:m(()=>[o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`h2`,R,c(r.$t(`common.title.allApplications`)),1)]),_:1})]),_:1}),o(b,{gutter:15,class:`mb-3`},{default:m(()=>[o(y,{md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,z,[n(`div`,B,[o(S,{icon:`fa-solid fa-cubes-stacked`})]),n(`p`,V,c(r.$t(`application.title.count`)),1),n(`p`,H,c(r.individualApplicationsTotal),1),n(`p`,U,c(r.$t(`application.message.countDescription`)),1)]))]),_:1})]),_:1}),r.showGlobalPayment&&r.globalApplications?.length>0?(l(),a(y,{key:0,md:12,xs:24},{default:m(()=>[o(C,{shadow:`hover`,class:`relative min-h-[180px] mb-2`,"body-style":{padding:`18px 20px`}},{default:m(()=>[r.loading?(l(),a(x,{key:0})):(l(),t(`div`,W,[n(`div`,G,[n(`div`,K,[n(`div`,q,[o(S,{icon:`fa-solid fa-wallet`})]),n(`span`,J,[i(c(r.$t(`application.field.id`))+`: `+c(r.globalApplications?.[0]?.id)+` `,1),r.globalApplications?.[0]?.id?(l(),a(w,{key:0,content:r.globalApplications?.[0]?.id,class:`inline-block`},null,8,[`content`])):d(``,!0)])]),n(`p`,te,c(r.$t(`application.title.globalBalance`)),1),n(`p`,Y,c(r.globalApplications?.[0]?.remaining_amount?.toFixed(6)||`0.000000`)+` `+c(r.$t(`service.unit.credits`)),1),n(`p`,X,c(r.$t(`application.message.globalBalanceDescription`)),1)]),n(`div`,Z,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:h[0]||=e=>r.onGoUsage(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1}),r.showGlobalPayment?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:h[1]||=e=>r.onBuyMore(r.globalApplications?.[0])},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1})):d(``,!0)])]))]),_:1})]),_:1})):d(``,!0)]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[o(C,{shadow:`hover`,class:`applications-table-card hidden sm:block`},{default:m(()=>[u((l(),a(k,{data:r.individualApplications,stripe:``,class:`applications-table !min-h-[calc(100vh-420px)]`,"table-layout":`fixed`,"empty-text":r.$t(`common.message.noData`)},{default:m(()=>[o(E,{prop:`id`,label:r.$t(`application.field.id`),width:`200px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(e.row.id),1),n(`span`,Q,[o(w,{content:e?.row?.id,class:`inline-block`},null,8,[`content`])])]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.type`),width:`90px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e.row?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.name`),width:`180px`},{default:m(e=>[n(`span`,null,c(e.row?.service?.title),1),e.row?.role===`grantee`?(l(),a(D,{key:0,type:`info`,size:`small`,round:``,class:`ml-2`},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),_:1},8,[`label`]),o(E,{prop:`remaining_amount`,label:r.$t(`application.field.remainingAmount`),width:`150px`,"class-name":`text-center`},{default:m(e=>[n(`span`,null,c(r.getRemainingAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`used_amount`,label:r.$t(`application.field.usedAmount`),width:`150px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[n(`span`,null,c(r.getUsedAmount(e.row)),1)]),_:1},8,[`label`]),o(E,{prop:`allow_consume_global`,label:r.$t(`application.field.allowConsumeGlobal`),width:`120px`,"class-name":`hidden sm:table-cell text-center`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.service?.type===r.serviceType.API?(l(),a(O,{key:0,modelValue:e.row.allow_consume_global,"onUpdate:modelValue":t=>e.row.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e.row,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])):d(``,!0)]),_:1},8,[`label`]),o(E,{label:r.$t(`application.field.expiredAt`),width:`180px`,"class-name":`hidden sm:table-cell`,"label-class-name":`hidden sm:table-cell`},{default:m(e=>[e.row.expired_at?(l(),t(`span`,ne,c(r.$dayjs.format(e.row.expired_at)),1)):d(``,!0)]),_:1},8,[`label`]),o(E,{fixed:`right`,width:`200px`},{default:m(e=>[n(`div`,re,[o(T,{class:`!m-0 !px-2`,size:`small`,round:``,onClick:t=>r.onGoUsage(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e?.row)?(l(),a(T,{key:0,class:`!m-0 !px-2`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e?.row)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:1})]),_:1},8,[`data`,`empty-text`])),[[M,r.loading]])]),_:1}),n(`div`,ie,[r.loading?(l(),a(x,{key:0,rows:4,animated:``})):(l(),t(s,{key:1},[r.individualApplications?.length?(l(!0),t(s,{key:1},e(r.individualApplications,e=>(l(),a(C,{key:e.id,shadow:`hover`,class:`application-card mb-2`,"body-style":{padding:`14px 16px`}},{default:m(()=>[n(`div`,ae,[n(`span`,oe,c(e?.service?.title),1),e?.type===`Period`?(l(),a(D,{key:0,type:`success`,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.period`)),1)]),_:1})):e?.type===`Usage`?(l(),a(D,{key:1,effect:`dark`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.type.usage`)),1)]),_:1})):d(``,!0),e?.role===`grantee`?(l(),a(D,{key:2,type:`info`,size:`small`,round:``},{default:m(()=>[i(c(r.$t(`application.badge.shared`)),1)]),_:1})):d(``,!0)]),n(`div`,se,[n(`span`,ce,c(r.$t(`application.field.id`))+`: `+c(e.id),1),o(w,{content:e.id,class:`inline-block shrink-0`},null,8,[`content`])]),n(`div`,le,[n(`span`,ue,c(r.$t(`application.field.remainingAmount`)),1),n(`span`,de,c(r.getRemainingAmount(e)),1)]),e?.expired_at?(l(),t(`div`,fe,[n(`span`,pe,c(r.$t(`application.field.expiredAt`)),1),n(`span`,$,c(r.$dayjs.format(e.expired_at)),1)])):d(``,!0),e.service?.type===r.serviceType.API?(l(),t(`div`,me,[n(`span`,he,c(r.$t(`application.field.allowConsumeGlobal`)),1),o(O,{modelValue:e.allow_consume_global,"onUpdate:modelValue":t=>e.allow_consume_global=t,"active-value":!0,"inactive-value":!1,onChange:t=>r.updateAllowConsumeGlobal(e,t)},null,8,[`modelValue`,`onUpdate:modelValue`,`onChange`])])):d(``,!0),n(`div`,ge,[o(T,{class:`!m-0 !px-3`,size:`small`,round:``,onClick:t=>r.onGoUsage(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-chart-line`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.usage`)),1)]),_:1},8,[`onClick`]),r.rowCanPay(e)?(l(),a(T,{key:0,class:`!m-0 !px-3`,type:`primary`,round:``,size:`small`,onClick:t=>r.onBuyMore(e)},{default:m(()=>[o(S,{icon:`fa-solid fa-coins`,class:`mr-1 text-[12px]`}),i(` `+c(r.$t(`application.button.buyMore`)),1)]),_:1},8,[`onClick`])):d(``,!0)])]),_:2},1024))),128)):(l(),a(A,{key:0,description:r.$t(`common.message.noData`)},null,8,[`description`]))],64))])]),_:1})]),_:1}),o(b,null,{default:m(()=>[o(y,{span:24},{default:m(()=>[n(`div`,_e,[o(j,{"current-page":r.page,"page-size":r.limit,total:r.individualApplicationsTotal,onChange:r.onPageChange},null,8,[`current-page`,`page-size`,`total`,`onChange`])])]),_:1})]),_:1})]),_:1})]),_:1})}var ye=T(L,[[`render`,ve],[`__scopeId`,`data-v-b4164ed9`]]);export{ye as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime--c01j_DQ.js";import{A as e,D as t,E as n,F as r,N as i,O as a,P as o,Wt as s,Z as c,k as l,tt as u,ut as d}from"./vendor-chart-BJCvKk8-.js";import{t as f}from"./button-BydTr5nV.js";import{t as p}from"./Navigator-
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{A as e,D as t,E as n,F as r,N as i,O as a,P as o,Wt as s,Z as c,k as l,tt as u,ut as d}from"./vendor-chart-BJCvKk8-.js";import{t as f}from"./button-BydTr5nV.js";import{t as p}from"./Navigator-DtlLm4nK.js";import{t as m}from"./checkbox-BC1X4B2U.js";import{t as h}from"./divider-LA__Fty9.js";import"./constants-DJZQuGxz.js";import{Bn as g,E as _,Kr as v,Or as y,Pr as b,Ur as x,jr as S,kr as C,zt as w}from"./index-CZO1Gi94.js";import{t as T}from"./Status-vzlZd2A6.js";var E=r({name:`ApplicationConfirm`,components:{ElDialog:v,ElDivider:h,ElCheckbox:m,ElButton:f},props:{visible:{type:Boolean,required:!1,default:!1}},emits:[`update:visible`,`apply`],data(){return{checked:!0}},watch:{},methods:{getBaseUrlPlatform:b,onApply(){if(!this.checked){x.error(this.$t(`application.message.notAgreePolicy`));return}this.$emit(`apply`)}}}),D={class:`content py-[10px] px-[40px]`},O={class:`my-4`},k={class:`policy mb-[10px]`},A={class:`policy-title text-[12px] relative -bottom-[3px]`},j=[`href`];function M(e,n,r,l,f,p){let m=u(`el-divider`),h=u(`el-checkbox`),g=u(`el-button`),_=u(`el-dialog`);return c(),a(_,{"model-value":e.visible,width:`500px`,title:e.$t(`application.message.welcome`),center:``,onClose:n[1]||=t=>e.$emit(`update:visible`,!1)},{default:d(()=>[t(`div`,D,[t(`p`,O,s(e.$t(`application.message.notApplied`)),1),o(m,{class:`my-2`}),t(`div`,k,[o(h,{modelValue:e.checked,"onUpdate:modelValue":n[0]||=t=>e.checked=t,size:`large`,class:`policy-checkbox mr-[10px]`},null,8,[`modelValue`]),t(`span`,A,s(e.$t(`application.message.readPolicy`)),1),t(`a`,{class:`policy-title text-[12px] relative -bottom-[3px] text-[var(--el-color-primary)] cursor-pointer no-underline`,target:`_blank`,href:e.getBaseUrlPlatform()+`/terms`},` \xA0`+s(e.$t(`application.message.policy`)),9,j)]),o(g,{round:``,type:`primary`,onClick:e.onApply},{default:d(()=>[i(s(e.$t(`common.button.start`)),1)]),_:1},8,[`onClick`])])]),_:1},8,[`model-value`,`title`])}var N=_(E,[[`render`,M]]),P=15e3,F=r({name:`LayoutMain`,components:{Navigator:p,ApplicationStatus:T,ApplicationConfirm:N},provide(){return{initialized:n(()=>this.initialized)}},data(){return{initialized:!1,applying:!1,mobile:typeof window<`u`&&window.innerWidth<768,initializeRunId:0,balanceTimer:0}},computed:{appName(){return this.$route.meta.appName},application(){return this.$store.state[this.appName]?.application},applications(){let e=this.$store.state[this.appName]?.applications??[];console.debug(`individualApplications`,e);let t=this.$store.state.applications??[];return console.debug(`globalApplications`,t),t.concat(e)},loading(){return this.$store.state[this.appName]?.status?.getApplications===S.Request},service(){return this.$store.state[this.appName]?.service},userId(){return this.$store.state.user?.id}},watch:{appName(){this.initialize()},userId(e,t){e&&e!==t&&this.initialize()}},mounted(){this.initialize(),window.addEventListener(`resize`,this.onResize),this.balanceTimer=window.setInterval(this.refreshBalances,P),document.addEventListener(`visibilitychange`,this.onVisibility)},beforeUnmount(){window.removeEventListener(`resize`,this.onResize),window.clearInterval(this.balanceTimer),document.removeEventListener(`visibilitychange`,this.onVisibility)},methods:{onResize(){this.mobile=window.innerWidth<768},onVisibility(){typeof document<`u`&&!document.hidden&&this.refreshBalances()},async refreshBalances(){if(!this.appName||!this.$store.state.token?.access||typeof document<`u`&&document.hidden||this.loading)return;await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]);let e=this.$store.state[this.appName]?.application;if(!e)return;let t=this.applications?.find(t=>t.id===e.id);t&&t!==e&&this.$store.commit(`${this.appName}/setApplication`,t)},async initialize(){let e=++this.initializeRunId;if(this.initialized=!1,console.debug(`Fetching all individual and global applications for`,this.appName),await Promise.allSettled([this.$store.dispatch(`getApplications`),this.$store.dispatch(`${this.appName}/getApplications`)]),e!==this.initializeRunId)return;console.debug(`Fetched all applications`,this.applications),this.$store.state.applications?.length===0&&await this.onAutoApply();let t=this.$store.state[this.appName]?.application;console.debug(`current application`,t);let n=w(this.applications,t);console.debug(`final application`,n),n&&(console.debug(`set final application`,n,n?.type),await this.$store.dispatch(`${this.appName}/setApplication`,n)),console.debug(`finished initialization`),this.initialized=!0},onApply(){this.onAutoApply()},async onAutoApply(){try{await g.create({type:C.USAGE,scope:y.GLOBAL,user_id:this.$store.getters.user.id}),this.applying=!1,await this.$store.dispatch(`getApplications`),this.showWelcomeToast()}catch(e){e?.response?.data?.code===`duplication`?await this.$store.dispatch(`getApplications`):x.error(this.$t(`application.message.applyFailed`))}},showWelcomeToast(){let e=this.$store.state.applications?.[0],t=Math.floor(e?.remaining_amount??0);x({message:t>0?this.$t(`application.message.welcomeWithCredits`,{credits:t}):this.$t(`application.message.welcomeNoCredits`),type:`success`,duration:6e3,showClose:!0})}}}),I={class:`wrapper`};function L(t,n,r,i,s,d){let f=u(`router-view`),p=u(`navigator`),m=u(`application-status`),h=u(`application-confirm`);return c(),e(`div`,I,[o(f,{class:`main`}),o(p,{class:`navigator`,direction:t.mobile?`row`:`column`},null,8,[`direction`]),t.application?(c(),a(m,{key:0,class:`status-floating fixed right-2 z-[200]`,application:t.application,applications:t.applications,"show-price":!1,authenticated:!!t.$store.state.token.access,service:t.service,onSelect:n[0]||=e=>t.$store.dispatch(`${t.appName}/setApplication`,e)},null,8,[`application`,`applications`,`authenticated`,`service`])):l(``,!0),o(h,{modelValue:t.applying,"onUpdate:modelValue":n[1]||=e=>t.applying=e,modelModifiers:{visible:!0},onApply:t.onApply},null,8,[`modelValue`,`onApply`])])}var R=_(F,[[`render`,L],[`__scopeId`,`data-v-f14707c1`]]);export{R as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./rolldown-runtime--c01j_DQ.js";import{$ as e,A as t,D as n,F as r,N as i,O as a,P as o,S as ee,Vt as s,Wt as c,Z as l,b as u,k as d,tt as f,ut as p}from"./vendor-chart-BJCvKk8-.js";import{t as m}from"./button-BydTr5nV.js";import{t as h}from"./upload-CtWAL12L.js";import{t as g}from"./image-CJhr3AFE.js";import{t as _}from"./alert-CuX4SjQB.js";import{n as v,r as y}from"./radio-3Hz7h3DR.js";import{t as b}from"./switch-EzOTmpa3.js";import{t as x}from"./vendor-axios-Ck2ffRoh.js";import"./constants-DJZQuGxz.js";import{E as S,It as C,Pr as w,Q as T,Ur as E,Xr as te,tn as D}from"./index-CZO1Gi94.js";import{t as O}from"./index.es-CLoebfsT.js";import{t as k}from"./CopyToClipboard-CfaMivRn.js";import{t as A}from"./BotPlaceholder-B-QupzkZ.js";import{t as j}from"./Hailuo-mXOkenDP.js";import{t as M}from"./TabSwitcher-DUgIYUY0.js";var N=4,P=90,F=r({name:`FishRecorder`,components:{ElButton:m,FontAwesomeIcon:O},emits:[`done`,`cancel`,`update:script`],data(){return{state:`idle`,scriptIndex:0,seconds:0,timerId:0,maxTimerId:0,mediaRecorder:null,stream:null,chunks:[],recordedBlob:null,recordedUrl:``,uploading:!1}},computed:{formattedTime(){let e=Math.floor(this.seconds/60),t=this.seconds%60;return`${e.toString().padStart(2,`0`)}:${t.toString().padStart(2,`0`)}`},currentScript(){let e=`fish.script.passage${this.scriptIndex%N+1}`;return this.$t(e)}},beforeUnmount(){this.cleanup()},mounted(){this.$emit(`update:script`,this.currentScript)},methods:{nextScript(){this.scriptIndex=(this.scriptIndex+1)%N,this.$emit(`update:script`,this.currentScript)},async startRecord(){if(!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`){E.error(this.$t(`fish.message.recorderUnsupported`));return}try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){let t=e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`;E.error(this.$t(t?`fish.message.micDenied`:`fish.message.micError`));return}this.chunks=[];let e=this.pickMimeType();try{this.mediaRecorder=e?new MediaRecorder(this.stream,{mimeType:e}):new MediaRecorder(this.stream)}catch{this.mediaRecorder=new MediaRecorder(this.stream)}this.mediaRecorder.ondataavailable=e=>{e.data&&e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{let e=new Blob(this.chunks,{type:this.mediaRecorder?.mimeType||`audio/webm`});this.recordedBlob=e,this.recordedUrl=URL.createObjectURL(e),this.state=`recorded`,this.releaseStream()},this.mediaRecorder.start(),this.state=`recording`,this.seconds=0,this.timerId=window.setInterval(()=>{this.seconds++},1e3),this.maxTimerId=window.setTimeout(()=>{this.state===`recording`&&this.stopRecord()},P*1e3)},stopRecord(){this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&this.mediaRecorder.stop(),window.clearInterval(this.timerId),window.clearTimeout(this.maxTimerId)},reset(){this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl),this.recordedUrl=``,this.recordedBlob=null,this.state=`idle`,this.seconds=0},onCancel(){this.cleanup(),this.$emit(`cancel`)},cleanup(){this.stopRecord(),this.releaseStream(),this.recordedUrl&&URL.revokeObjectURL(this.recordedUrl)},releaseStream(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null},pickMimeType(){for(let e of[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg`])if(typeof MediaRecorder<`u`&&MediaRecorder.isTypeSupported?.(e))return e},extensionForMime(e){return e.includes(`webm`)?`webm`:e.includes(`mp4`)?`m4a`:e.includes(`ogg`)?`ogg`:e.includes(`wav`)?`wav`:`mp3`},async useRecording(){if(this.recordedBlob){if(this.seconds<3){E.warning(this.$t(`fish.message.recordingTooShort`));return}this.uploading=!0;try{let e=this.$store.state.token?.access,t=this.extensionForMime(this.recordedBlob.type||``),n=new File([this.recordedBlob],`recording-${Date.now()}.${t}`,{type:this.recordedBlob.type||`audio/webm`}),r=new FormData;r.append(`file`,n);let{data:i}=await x.post(`${w()}/api/v1/files/`,r,{headers:{Authorization:`Bearer ${e}`}}),a=i?.file_url;if(!a){E.error(this.$t(`fish.message.uploadError`));return}this.$emit(`done`,{url:a,text:this.currentScript})}catch(e){E.error(this.$t(`fish.message.uploadError`)),console.error(`recorder upload failed`,e)}finally{this.uploading=!1}}}}}),I={class:`recorder`},L={key:0,class:`script`},R={class:`script-header`},z={class:`label`},B={class:`script-text`},V={class:`controls`},H={class:`status`},U={class:`hint`},W={key:1,class:`preview`},G=[`src`],K={class:`preview-actions`},q={class:`footer`};function J(e,r,ee,u,m,h){let g=f(`font-awesome-icon`),_=f(`el-button`);return l(),t(`div`,I,[e.state===`recorded`?d(``,!0):(l(),t(`div`,L,[n(`div`,R,[o(g,{icon:`fa-solid fa-book-open`,class:`icon mr-1`}),n(`span`,z,c(e.$t(`fish.description.readScript`)),1),o(_,{link:``,size:`small`,class:`ml-auto`,disabled:e.state===`recording`,onClick:e.nextScript},{default:p(()=>[o(g,{icon:`fa-solid fa-shuffle`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.nextScript`)),1)]),_:1},8,[`disabled`,`onClick`])]),n(`p`,B,c(e.currentScript),1)])),n(`div`,V,[e.state===`idle`?(l(),a(_,{key:0,type:`danger`,circle:``,size:`large`,title:e.$t(`fish.button.startRecord`),onClick:e.startRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`})]),_:1},8,[`title`,`onClick`])):e.state===`recording`?(l(),a(_,{key:1,type:`warning`,circle:``,size:`large`,title:e.$t(`fish.button.stopRecord`),onClick:e.stopRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-stop`})]),_:1},8,[`title`,`onClick`])):d(``,!0),n(`div`,H,[n(`span`,{class:s([`timer`,e.state===`recording`?`live`:``])},c(e.formattedTime),3),n(`span`,U,c(e.state===`idle`?e.$t(`fish.description.recorderIdle`):e.state===`recording`?e.$t(`fish.description.recorderRecording`):e.$t(`fish.description.recorderRecorded`)),1)])]),e.state===`recorded`&&e.recordedUrl?(l(),t(`div`,W,[n(`audio`,{src:e.recordedUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,G),n(`div`,K,[o(_,{size:`small`,disabled:e.uploading,onClick:e.reset},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.reRecord`)),1)]),_:1},8,[`disabled`,`onClick`]),o(_,{size:`small`,type:`primary`,loading:e.uploading,onClick:e.useRecording},{default:p(()=>[o(g,{icon:`fa-solid fa-check`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useRecording`)),1)]),_:1},8,[`loading`,`onClick`])])])):d(``,!0),n(`div`,q,[o(_,{link:``,size:`small`,disabled:e.uploading||e.state===`recording`,onClick:e.onCancel},{default:p(()=>[i(c(e.$t(`fish.button.cancel`)),1)]),_:1},8,[`disabled`,`onClick`])])])}var Y=S(F,[[`render`,J],[`__scopeId`,`data-v-1958e4a1`]]),X=50*1024*1024,Z=()=>({title:``,description:``,texts:``,voicesUrl:``,visibility:`unlist`,trainMode:`fast`,enhanceAudio:!0,generateSample:!1}),Q=r({name:`FishModelConfigPanel`,components:{ElButton:m,ElInput:te,ElRadioButton:v,ElRadioGroup:y,ElSwitch:b,ElUpload:h,FontAwesomeIcon:O,Recorder:Y},mixins:[C],emits:[`create`],data(){return{form:Z(),fileList:[],uploading:!1,creating:!1,recording:!1,textsAuto:!0}},computed:{uploadUrl(){return w()+`/api/v1/files/`},uploadHeaders(){return{Authorization:`Bearer ${this.$store.state.token?.access}`}},canCreate(){return!!this.form.title.trim()&&!!this.form.voicesUrl&&!this.uploading&&!this.creating},supportsRecorder(){return!!(typeof navigator<`u`?navigator.mediaDevices:void 0)?.getUserMedia&&typeof MediaRecorder<`u`}},methods:{onBeforeUpload(e){return e.size>X?(E.warning(this.$t(`fish.message.audioSizeExceed`)),!1):(this.uploading=!0,!0)},onExceed(){E.warning(this.$t(`fish.message.audioOnlyOne`))},onUploadError(){this.uploading=!1,E.error(this.$t(`fish.message.uploadError`))},onUploadSuccess(e,t,n){this.uploading=!1;let r=e?.file_url;if(!r){E.error(this.$t(`fish.message.uploadError`)),this.fileList=[];return}this.form.voicesUrl=r,this.fileList=n},onRecorded(e){this.form.voicesUrl=e.url,this.recording=!1,e.text&&this.textsAuto&&(this.form.texts=e.text)},onStartRecord(){this.recording=!0,this.textsAuto=!this.form.texts.trim()},onScriptChange(e){this.textsAuto&&this.recording&&(this.form.texts=e)},onTextsInput(){this.textsAuto=!1},clearAudio(){this.form.voicesUrl=``,this.fileList=[]},onCreate(){let e=this.form.title.trim();if(!e){E.warning(this.$t(`fish.message.titleRequired`));return}if(!this.form.voicesUrl){E.warning(this.$t(`fish.message.audioRequired`));return}let t={title:e,voices:this.form.voicesUrl,visibility:this.form.visibility,train_mode:this.form.trainMode,enhance_audio_quality:this.form.enhanceAudio,generate_sample:this.form.generateSample};this.form.description.trim()&&(t.description=this.form.description.trim()),this.form.texts.trim()&&(t.texts=[this.form.texts.trim()]),this.creating=!0,this.$emit(`create`,t),setTimeout(()=>{this.creating=!1,this.form=Z(),this.fileList=[]},600)}}}),ne={class:`flex flex-col h-full`},re={class:`flex-1 overflow-y-auto p-5`},ie={class:`field-block mb-4`},ae={class:`title font-bold`},oe={class:`field-block mb-4`},se={class:`flex items-baseline justify-between mb-1`},ce={class:`title font-bold`},le={key:0,class:`muted`},ue={class:`hint`},de={key:0,class:`audio-actions`},fe={key:1,class:`hint warn`},pe={key:3,class:`mt-2`},me=[`src`],he={class:`ready-actions`},ge={class:`field-block mb-4`},_e={class:`title font-bold`},ve={class:`hint`},ye={class:`field-block mb-4`},be={class:`title font-bold`},xe={class:`field-block mb-4`},Se={class:`title font-bold`},Ce={class:`field-block mb-4`},we={class:`title font-bold`},Te={class:`field-block mb-3`},Ee={class:`field-row`},De={class:`title font-bold`},Oe={class:`hint mt-0 mb-0`},ke={class:`field-block mb-2`},Ae={class:`field-row`},je={class:`title font-bold`},Me={class:`hint mt-0 mb-0`},Ne={class:`flex flex-col items-center justify-center px-5 pb-5`};function Pe(e,r,ee,s,u,m){let h=f(`el-input`),g=f(`font-awesome-icon`),_=f(`el-button`),v=f(`el-upload`),y=f(`recorder`),b=f(`el-radio-button`),x=f(`el-radio-group`),S=f(`el-switch`);return l(),t(`div`,ne,[n(`div`,re,[n(`div`,ie,[n(`h2`,ae,[i(c(e.$t(`fish.name.voiceTitle`))+` `,1),r[9]||=n(`span`,{class:`required`},`*`,-1)]),o(h,{modelValue:e.form.title,"onUpdate:modelValue":r[0]||=t=>e.form.title=t,placeholder:e.$t(`fish.placeholder.voiceTitle`),maxlength:`60`},null,8,[`modelValue`,`placeholder`])]),n(`div`,oe,[n(`div`,se,[n(`h2`,ce,[i(c(e.$t(`fish.name.referenceAudio`))+` `,1),r[10]||=n(`span`,{class:`required`},`*`,-1)]),!e.form.voicesUrl&&!e.recording?(l(),t(`span`,le,c(e.$t(`fish.description.audioRequired`)),1)):d(``,!0)]),n(`p`,ue,c(e.$t(`fish.description.uploadAudio`)),1),!e.form.voicesUrl&&!e.recording?(l(),t(`div`,de,[o(v,{"file-list":e.fileList,"onUpdate:fileList":r[1]||=t=>e.fileList=t,name:`file`,limit:1,class:`upload-wrapper`,action:e.uploadUrl,accept:`.mp3,.wav,.m4a,.ogg,.webm,audio/*`,"show-file-list":!1,"on-exceed":e.onExceed,"on-error":e.onUploadError,"on-success":e.onUploadSuccess,"before-upload":e.onBeforeUpload,headers:e.uploadHeaders},{default:p(()=>[o(_,{type:`primary`,plain:``,round:``,loading:e.uploading},{default:p(()=>[o(g,{icon:`fa-solid fa-upload`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.uploadAudio`)),1)]),_:1},8,[`loading`])]),_:1},8,[`file-list`,`action`,`on-exceed`,`on-error`,`on-success`,`before-upload`,`headers`]),o(_,{type:`primary`,round:``,disabled:!e.supportsRecorder,onClick:e.onStartRecord},{default:p(()=>[o(g,{icon:`fa-solid fa-microphone`,class:`icon mr-1`}),i(` `+c(e.$t(`fish.button.recordAudio`)),1)]),_:1},8,[`disabled`,`onClick`])])):d(``,!0),!e.supportsRecorder&&!e.form.voicesUrl&&!e.recording?(l(),t(`p`,fe,c(e.$t(`fish.message.recorderUnsupported`)),1)):d(``,!0),e.recording?(l(),a(y,{key:2,class:`mt-2`,onDone:e.onRecorded,onCancel:r[2]||=t=>e.recording=!1,"onUpdate:script":e.onScriptChange},null,8,[`onDone`,`onUpdate:script`])):d(``,!0),e.form.voicesUrl&&!e.recording?(l(),t(`div`,pe,[n(`audio`,{src:e.form.voicesUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,me),n(`div`,he,[o(_,{link:``,size:`small`,onClick:e.clearAudio},{default:p(()=>[o(g,{icon:`fa-solid fa-rotate-left`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.replaceAudio`)),1)]),_:1},8,[`onClick`])])])):d(``,!0)]),n(`div`,ge,[n(`h2`,_e,c(e.$t(`fish.name.audioTexts`)),1),n(`p`,ve,c(e.$t(`fish.description.audioTexts`)),1),o(h,{modelValue:e.form.texts,"onUpdate:modelValue":r[3]||=t=>e.form.texts=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.audioTexts`),maxlength:`500`,onInput:e.onTextsInput},null,8,[`modelValue`,`placeholder`,`onInput`])]),n(`div`,ye,[n(`h2`,be,c(e.$t(`fish.name.voiceDescription`)),1),o(h,{modelValue:e.form.description,"onUpdate:modelValue":r[4]||=t=>e.form.description=t,type:`textarea`,rows:2,placeholder:e.$t(`fish.placeholder.voiceDescription`),maxlength:`500`},null,8,[`modelValue`,`placeholder`])]),n(`div`,xe,[n(`h2`,Se,c(e.$t(`fish.name.visibility`)),1),o(x,{modelValue:e.form.visibility,"onUpdate:modelValue":r[5]||=t=>e.form.visibility=t,size:`small`},{default:p(()=>[o(b,{label:`private`,value:`private`},{default:p(()=>[i(c(e.$t(`fish.value.private`)),1)]),_:1}),o(b,{label:`unlist`,value:`unlist`},{default:p(()=>[i(c(e.$t(`fish.value.unlist`)),1)]),_:1}),o(b,{label:`public`,value:`public`},{default:p(()=>[i(c(e.$t(`fish.value.public`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Ce,[n(`h2`,we,c(e.$t(`fish.name.trainMode`)),1),o(x,{modelValue:e.form.trainMode,"onUpdate:modelValue":r[6]||=t=>e.form.trainMode=t,size:`small`},{default:p(()=>[o(b,{label:`fast`,value:`fast`},{default:p(()=>[i(c(e.$t(`fish.value.trainModeFast`)),1)]),_:1}),o(b,{label:`precise`,value:`precise`},{default:p(()=>[i(c(e.$t(`fish.value.trainModePrecise`)),1)]),_:1})]),_:1},8,[`modelValue`])]),n(`div`,Te,[n(`div`,Ee,[n(`h2`,De,c(e.$t(`fish.name.enhanceAudio`)),1),o(S,{modelValue:e.form.enhanceAudio,"onUpdate:modelValue":r[7]||=t=>e.form.enhanceAudio=t},null,8,[`modelValue`])]),n(`p`,Oe,c(e.$t(`fish.description.enhanceAudio`)),1)]),n(`div`,ke,[n(`div`,Ae,[n(`h2`,je,c(e.$t(`fish.name.generateSample`)),1),o(S,{modelValue:e.form.generateSample,"onUpdate:modelValue":r[8]||=t=>e.form.generateSample=t},null,8,[`modelValue`])]),n(`p`,Me,c(e.$t(`fish.description.generateSample`)),1)])]),n(`div`,Ne,[o(_,{type:`primary`,class:`btn w-full`,round:``,disabled:!e.canCreate||e.creating,loading:e.creating,onClick:e.onCreate},{default:p(()=>[o(g,{icon:`fa-solid fa-magic`,class:`mr-2`}),i(` `+c(e.$t(`fish.button.createModel`)),1)]),_:1},8,[`disabled`,`loading`,`onClick`])])])}var Fe=S(Q,[[`render`,Pe],[`__scopeId`,`data-v-d8fc0e55`]]),Ie=r({name:`FishVoiceCard`,components:{ElAlert:_,ElButton:m,ElImage:g,CopyToClipboard:k,FontAwesomeIcon:O},props:{modelValue:{type:Object,required:!0}},computed:{sampleAudioUrl(){let e=this.modelValue?.samples;if(e?.length)return e[0]?.audio},voiceId(){let e=this.modelValue;return(e?.id||e?._id||e?.reference_id||``).toString()},coverSrc(){let e=this.modelValue?.cover_image;return e&&typeof e==`string`?e:void 0},createdAtLabel(){let e=this.modelValue?.created_at;if(e==null||e===``)return null;let t=typeof e==`number`?e:parseFloat(String(e));return!Number.isFinite(t)||t<=0?null:this.$dayjs.format(``+new Date(t*1e3))}},methods:{onUseVoice(){let e=this.voiceId;e&&(this.$store.commit(`fish/setConfig`,{...this.$store.state.fish?.config,reference_id:e}),this.$router.push({name:T}))}}}),Le={class:`card`},Re={class:`left`},ze={class:`main`},Be={class:`header`},Ve={class:`title`},He={key:0,class:`datetime`},Ue={key:0,class:`description`},We={key:1,class:`sample mt-2`},Ge=[`src`],Ke={key:0,class:`text-[var(--el-text-color-regular)] text-xs mb-2`},qe={key:1,class:`text-[var(--el-text-color-regular)] text-xs mb-0`},Je={class:`operations mt-2`};function Ye(e,r,ee,s,m,h){let g=f(`el-image`),_=f(`font-awesome-icon`),v=f(`copy-to-clipboard`),y=f(`el-alert`),b=f(`el-button`);return l(),t(`div`,Le,[n(`div`,Re,[e.coverSrc?(l(),a(g,{key:0,src:e.coverSrc,class:`cover`,fit:`cover`},{error:p(()=>[o(g,{src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`})]),placeholder:p(()=>[...r[0]||=[n(`div`,{class:`cover placeholder`},null,-1)]]),_:1},8,[`src`])):(l(),a(g,{key:1,src:`https://cdn.acedata.cloud/e40fccc727.png`,class:`cover fallback`,fit:`cover`}))]),n(`div`,ze,[n(`div`,Be,[n(`span`,Ve,c(e.modelValue?.title||e.$t(`fish.name.untitledVoice`)),1),e.createdAtLabel?(l(),t(`span`,He,c(e.createdAtLabel),1)):d(``,!0)]),e.modelValue?.description?(l(),t(`p`,Ue,c(e.modelValue?.description),1)):d(``,!0),e.sampleAudioUrl?(l(),t(`div`,We,[n(`audio`,{src:e.sampleAudioUrl,controls:``,preload:`metadata`,class:`w-full`},null,8,Ge)])):d(``,!0),o(y,{closable:!1,class:`mt-2 success`},{default:p(()=>[e.voiceId?(l(),t(`p`,Ke,[o(_,{icon:`fa-solid fa-microphone`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.referenceId`))+`: `+c(e.voiceId)+` `,1),o(v,{content:e.voiceId},null,8,[`content`])])):d(``,!0),e.modelValue?.visibility?(l(),t(`p`,qe,[o(_,{icon:`fa-solid fa-eye`,class:`mr-1`}),i(` `+c(e.$t(`fish.name.visibility`))+`: `+c(e.modelValue?.visibility),1)])):d(``,!0)]),_:1}),n(`div`,Je,[o(b,{type:`primary`,size:`small`,plain:``,disabled:!e.voiceId,onClick:u(e.onUseVoice,[`stop`])},{default:p(()=>[o(_,{icon:`fa-solid fa-volume-high`,class:`mr-1`}),i(` `+c(e.$t(`fish.button.useVoice`)),1)]),_:1},8,[`disabled`,`onClick`])])])])}var Xe=r({name:`FishModelListPanel`,components:{VoiceCard:S(Ie,[[`render`,Ye],[`__scopeId`,`data-v-629e2d04`]]),BotPlaceholder:A,FontAwesomeIcon:O},props:{loading:{type:Boolean,default:!1}},computed:{voices(){return this.$store.state.fish?.voices}}}),Ze={class:`model-list-panel flex flex-col h-full`},Qe={class:`header`},$e={class:`title`},et={key:0,class:`count`},tt={class:`body flex-1 min-h-0`},$={key:0,class:`h-full`},nt={key:1,class:`w-full h-full flex flex-col items-center justify-center text-center px-6`},rt={class:`empty-title`},it={class:`empty-hint`},at={key:2,class:`w-full h-full overflow-y-auto pr-1`};function ot(r,i,s,u,p,m){let h=f(`bot-placeholder`),g=f(`font-awesome-icon`),_=f(`voice-card`);return l(),t(`div`,Ze,[n(`header`,Qe,[n(`h2`,$e,c(r.$t(`fish.title.myVoices`)),1),r.voices?.length?(l(),t(`span`,et,c(r.voices?.length),1)):d(``,!0)]),n(`div`,tt,[r.voices===void 0?(l(),t(`div`,$,[o(h)])):r.voices.length===0?(l(),t(`div`,nt,[o(g,{icon:`fa-solid fa-microphone-lines`,class:`empty-icon`}),n(`p`,rt,c(r.$t(`fish.title.noVoicesYet`)),1),n(`p`,it,c(r.$t(`fish.description.noVoicesYet`)),1)])):(l(),t(`div`,at,[(l(!0),t(ee,null,e(r.voices,e=>(l(),a(_,{key:e.id,"model-value":e},null,8,[`model-value`]))),128))]))])])}var st=r({name:`FishModelIndex`,components:{ModelConfigPanel:Fe,Layout:j,ModelListPanel:S(Xe,[[`render`,ot],[`__scopeId`,`data-v-4aab2294`]]),TabSwitcher:M},inject:[`initialized`],data(){return{loading:!1}},computed:{credential(){return this.$store.state.fish?.credential}},watch:{initialized:{async handler(e){e&&await this.onGetVoices()},immediate:!0}},async mounted(){await this.onGetService()},methods:{async onGetService(){await this.$store.dispatch(`fish/getService`)},async onGetVoices(){await this.$store.dispatch(`fish/getVoices`)},async onCreate(e){let t=this.credential?.token;if(!t){console.error(`no token specified`);return}this.loading=!0,E.info(this.$t(`fish.message.creatingModel`));try{await D.createModel(e,{token:t}),E.success(this.$t(`fish.message.createModelSuccess`)),await this.onGetVoices()}catch(e){let t=e?.response?.data;t?.error?.code===`used_up`?E.error(this.$t(`fish.message.usedUp`)):E.error(t?.error?.message||this.$t(`fish.message.createModelFailed`))}finally{this.loading=!1}}}}),ct={class:`flex flex-col h-full`},lt={class:`flex-1 min-h-0`};function ut(e,t,r,i,ee,s){let c=f(`tab-switcher`),u=f(`model-config-panel`),d=f(`model-list-panel`),m=f(`layout`);return l(),a(m,null,{config:p(()=>[n(`div`,ct,[o(c),n(`div`,lt,[o(u,{onCreate:e.onCreate},null,8,[`onCreate`])])])]),result:p(()=>[o(d,{loading:e.loading},null,8,[`loading`])]),_:1})}var dt=S(st,[[`render`,ut]]);export{dt as default};
|