Files
vue-vben-admin/assets/polling-D1wHAL8S.js
2024-08-01 01:56:55 +00:00

2 lines
2.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{i as s}from"./mock-api-CPZhPesm.js";import{P as m}from"./index-BB9V0GyI.js";import{b8 as l,Y as d,B as t,R as p,j as g}from"./antd-BmrhB3rb.js";import{d as i,k as e,G as u}from"./vue-BjERyvPm.js";import{u as f}from"./index-Cw2evmpm.js";import"./entry/index-DShbtsWl.js";import"./useContentViewHeight-w3jL8fd7.js";import"./useWindowSizeFn-Cuml40XT.js";import"./onMountedOrActivated-DcvTUt7V.js";const C=i({setup(){const{data:a,loading:n,run:r,cancel:o}=f(s,{pollingInterval:1e3,pollingWhenHidden:!1});return()=>e(p,{title:"默认用法"},{default:()=>[e(l,null,{default:()=>[e(l.Paragraph,null,{default:()=>[u("通过设置"),e(l.Text,{type:"danger"},{default:()=>[u(" options.pollingInterval ")]}),u("进入轮询模式useRequest 会定时触发 service 执行。")]}),e(l.Paragraph,null,{default:()=>[e(l.Text,{code:!0},{default:()=>["const { data, run, cancel } = useRequest(imitateApi, { pollingInterval: 3000 });"]})]})]}),e("div",null,[e("div",null,[u("Username: "),n.value?"Loading":a.value]),e(d,null,{default:()=>[e(t,{onClick:()=>r()},{default:()=>[u("start")]}),e(t,{type:"dashed",onClick:o},{default:()=>[u("stop")]})]})])]})}}),F=i({setup(){const{data:a,loading:n,run:r,cancel:o}=f(s,{manual:!0,pollingInterval:3e3,pollingErrorRetryCount:3,pollingWhenHidden:!1,onError:c=>{g.error(c.message)}});return()=>e(p,{title:"轮询错误重试",class:"mt-2"},{default:()=>[e(l,null,{default:()=>[e(l.Paragraph,null,{default:()=>[u("通过"),e(l.Text,{type:"danger"},{default:()=>[u(" options.pollingErrorRetryCount ")]}),u("轮询错误重试次数。")]}),e(l.Paragraph,null,{default:()=>[e(l.Text,{code:!0},{default:()=>["const { data, run, cancel } = useRequest(imitateApi, { pollingInterval: 3000, pollingErrorRetryCount: 3 });"]})]})]}),e("div",null,[e("div",null,[u("Username: "),n.value?"Loading":a.value]),e(d,null,{default:()=>[e(t,{onClick:()=>r("lutz",!1)},{default:()=>[u("start")]}),e(t,{type:"dashed",onClick:o},{default:()=>[u("stop")]})]})])]})}}),P=i({setup(){return()=>e(m,null,{default:()=>[e(C,null,null),e(F,null,null)]})}});export{P as default};