mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-05 19:42:07 +08:00
2 lines
6.1 KiB
JavaScript
2 lines
6.1 KiB
JavaScript
import{a as l}from"./vue-hooks-plus@2.2.1_vue@3.5.13_typescript@5.6.3_-3eMKHOaU.js";import"./lodash@4.17.21-Cw59kuJw.js";import{s as n}from"./instance-CzbCXUZF.js";import{c as r,N as o,O as A,L as i,_ as g}from"./naive-ui@2.40.1_vue@3.5.13_typescript@5.6.3_-Bx4bEkBQ.js";import{l as V,b as u,I as t}from"./@vue_runtime-core@3.5.13-BEg_yh4N.js";import{e as R,x as v}from"./@vue_reactivity@3.5.13-Ch1DBDRK.js";import"./js-cookie@3.0.5-Z_8Sd105.js";import"./screenfull@5.2.0-DmMZCkhi.js";import"./call-bind@1.0.7-Cpj98o6Y.js";import"./axios@1.7.5-C8DqakIB.js";import"./hooks-DKN08swi.js";import"./lodash-es@4.17.21-B-5kLwAl.js";import"./@vueuse_core@11.2.0_vue@3.5.13_typescript@5.6.3_-qLonknDl.js";import"./@vueuse_shared@11.2.0_vue@3.5.13_typescript@5.6.3_-C-DuMGMJ.js";import"./currency.js@2.0.4-9OAR_aOO.js";import"./dayjs@1.11.10-C8LoRVP6.js";import"./print-js@1.6.0-BdoEj60G.js";import"./jsbarcode@3.11.6-DGNGFp02.js";import"./@logicflow_core@2.0.6-CHqfytjt.js";import"./mobx-preact@3.0.0_mobx@5.15.7_preact@10.22.0-q-IhwcFu.js";import"./preact@10.22.0-D1_UwAj3.js";import"./mobx@5.15.7-CEMJDQot.js";import"./uuid@9.0.1-CQkTLCs1.js";import"./classnames@2.5.1-nUTIn1-D.js";import"./mousetrap@1.6.5-BTGDluHR.js";import"./mobx-utils@5.6.2_mobx@5.15.7-C1xBETkd.js";import"./utils-DMI3ftdH.js";import"./pinia-plugin-persistedstate@4.1.1_pinia@2.2.4_typescript@5.6.3_vue@3.5.13_typescript@5.6.3____yt6biirdeg4kqzievtaggbt2mm-_Zka_ujQ.js";import"./destr@2.0.3-CVtkxrq9.js";import"./deep-pick-omit@1.2.1-CegYQlcN.js";import"./pinia@2.2.4_typescript@5.6.3_vue@3.5.13_typescript@5.6.3_-BSK3SS9R.js";import"./vue-demi@0.14.10_vue@3.5.13_typescript@5.6.3_-Dq6ymT-8.js";import"./html-to-image@1.11.11-BOFdlgi9.js";import"./vue-router@4.3.2_vue@3.5.13_typescript@5.6.3_-BP6RbFeK.js";import"./vue-i18n@9.13.1_vue@3.5.13_typescript@5.6.3_-B3N1nvv4.js";import"./@intlify_shared@9.13.1-BxU0OzX2.js";import"./@intlify_core-base@9.13.1-C6DqbPB6.js";import"./@intlify_message-compiler@9.13.1-GrLDMuy_.js";import"./echarts@5.5.1-C65RY-Xl.js";import"./zrender@5.6.0-1zVsYK9t.js";import"./tslib@2.3.0-BDyQ-Jie.js";import"./@vue_runtime-dom@3.5.13-BO5HcqNg.js";import"./@vue_shared@3.5.13-Dh1pNJXy.js";import"./interactjs@1.10.26-DZL_TZzP.js";import"./date-fns@3.6.0-q9PkOyxq.js";import"./seemly@0.3.8-DjGKl9dV.js";import"./vueuc@0.4.64_vue@3.5.13_typescript@5.6.3_-BkAdx2tT.js";import"./evtd@0.2.4-CI_DDEu_.js";import"./@css-render_vue3-ssr@0.15.14_vue@3.5.13_typescript@5.6.3_-BRDj2ZMK.js";import"./vooks@0.2.12_vue@3.5.13_typescript@5.6.3_-B9mUPMHL.js";import"./vdirs@0.1.8_vue@3.5.13_typescript@5.6.3_-C0KV5pCE.js";import"./@juggle_resize-observer@3.4.0-C8OzoCMD.js";import"./css-render@0.15.14-C5toWlUr.js";import"./@emotion_hash@0.8.0-WldOFDRm.js";import"./treemate@0.3.11-DKekKYbv.js";import"./date-fns-tz@3.1.3_date-fns@3.6.0-ztskLDQQ.js";import"./async-validator@4.2.5-DKvM95Vc.js";import"./@css-render_plugin-bem@0.15.14_css-render@0.15.14-Be8eOoM-.js";function b(e,a){return l(()=>n(e),Object.assign({},a))}const w=e=>n({url:`https://www.tianqiapi.com/api?version=v9&appid=23035354&appsecret=8YvlPNrz&city=${e}`,method:"get"}),d=()=>n({url:"https://jsonplaceholder.typicode.com/todos/1",method:"get"}),Nu=V({name:"RAxios",setup(){const e=R({weatherData:[],inputCityValue:null,throttleDemoInputValue:null,debounceDemoInputValue:null,weatherDemoInputValue:null}),{data:a,loading:m,run:p}=l(d,{throttleWait:1e3,manual:!0}),{data:s,loading:D,run:F}=l(d,{debounceWait:1e3,manual:!0}),{data:h,loading:c,run:E}=l(w,{throttleWait:1e3,manual:!0}),{data:B,loading:C,run:f}=b({url:"https://jsonplaceholder.typicode.com/todos/1",method:"get",cancelConfig:{cancel:!0}},{manual:!0,onError:()=>{window.$message.error("接口出现异常")}});return{...v(e),throttleDemoValue:a,throttleDemoLoading:m,throttleDemoRun:p,debounceDemoValue:s,debounceDemoLoading:D,debounceDemoRun:F,weatherDemoValue:h,weatherDemoLoading:c,weatherDemoRun:E,demoData:B,demoLoading:C,demoRun:f}},render(){return u(g,null,{default:()=>[u(r,{vertical:!0},{default:()=>[u("h1",null,[t("请求")]),u(o,null,{default:()=>[u("h2",null,[t("useRequest")]),u("p",null,[t("支持配置化请求数据")]),u("h2",null,[t("useHookPlusRequest")]),u("p",null,[t("支持包裹一个拥有 promise 状态的异步函数,可以用来包裹一个 axios 请求返回值方法")])]}),u("h1",null,[t("使用 useRequest 获取")]),u(o,{title:"请求函数"},{default:()=>[u("h3",null,[t("1.基于 axios 封装,能够自动取消连续请求,避免重复渲染造成问题")]),u("h3",null,[t("2.打开控制台 => 网络 => 使用低速3g网络 => 查看控制台被取消的请求")]),u("h3",null,[t("3.详情请查看文档")])]}),u(o,{title:"useRequest示例(手动触发)"},{default:()=>[u(r,{vertical:!0},{default:()=>{var e;return[u(A,{onClick:this.demoRun.bind(this)},{default:()=>[t("获取数据")]}),u("h3",null,[t("结果: "),this.demoLoading?"获取中...":(e=this.demoData)==null?void 0:e.title])]}})]}),u("h1",null,[t("使用 useHookPlusRequest 获取")]),u(o,{title:"节流"},{default:()=>[u(r,{vertical:!0},{default:()=>[u(i,{value:this.throttleDemoInputValue,"onUpdate:value":e=>this.throttleDemoInputValue=e,onUpdateValue:()=>{this.throttleDemoRun()}},null),u("h3",null,[t("不论触发多少次,一秒钟之内仅会触发一次")]),u("h3",null,[t("当前状态: "),this.throttleDemoLoading?"获取中...":"获取成功!!!"])]})]}),u(o,{title:"防抖"},{default:()=>[u(r,{vertical:!0},{default:()=>[u(i,{value:this.debounceDemoInputValue,"onUpdate:value":e=>this.debounceDemoInputValue=e,onUpdateValue:()=>{this.debounceDemoRun()}},null),u("h3",null,[t("一秒后才会执行,如果中途重新请求,则会重新计时")]),u("h3",null,[t("当前状态: "),this.debounceDemoLoading?"获取中...":"获取成功!!!"])]})]}),u(o,{title:"获取气候"},{default:()=>[u(r,{vertical:!0},{default:()=>[u(i,{value:this.weatherDemoInputValue,"onUpdate:value":e=>this.weatherDemoInputValue=e,onUpdateValue:e=>{this.weatherDemoRun(e)}},null),u("h3",null,[t("该示例演示了如何根据动态值获取数据")]),u("h3",null,[t("当前状态: "),this.weatherDemoLoading?"获取中...":"获取成功!!!"])]})]})]})]})}});export{Nu as default};
|