(function(s,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("axios")):typeof define=="function"&&define.amd?define(["exports","vue","axios"],r):(s=typeof globalThis<"u"?globalThis:s||self,r(s.GgzcWeb={},s.Vue,s.axios))})(this,function(s,r,T){"use strict";const h="STARTLOADING",p="ENDLOADING",j={namespaced:!0,state:()=>({loadingStatus:{}}),mutations:{[h](t,e){const{fwbm:n}=e;r.set(t.loadingStatus,n,!0)},[p](t,e){const{fwbm:n}=e;r.set(t.loadingStatus,n,!1)}},actions:{startLoading(t,e){t.commit(h,e||[])},endLoading(t,e){t.commit(p,e||[])}}},u={axiosConfig:{timeout:60*1e3,withCredentials:!0},showRequestErr(t){if(this.vue)return this.vue.$message.error(t);console.error("Vue instance not available:",t)},logoutHandle(){this.vue&&this.vue.$store?this.vue.$store.dispatch("logout"):console.warn("Logout handler called but Vue instance or store not available")},install(t,{axiosConfig:e}){this.vue=t,this.axiosConfig={...this.axiosConfig,...e},t.prototype.$request=l}},d=T.create(u.axiosConfig);d.interceptors.request.use(t=>{const e=t,{url:n}=e;if(n.indexOf("?")!==-1?e.url=`${n}&t=${new Date().getTime()}`:e.url=`${n}?t=${new Date().getTime()}`,e.method==="get"&&e.params){let o=`${e.url}&`;for(const a of Object.keys(e.params)){const i=e.params[a],f=`${encodeURIComponent(a)}=`;if(i!==null&&typeof i<"u")if(typeof i=="object")for(const O of Object.keys(i)){const R=`${a}[${O}]`,M=`${encodeURIComponent(R)}=`;o+=`${M}${encodeURIComponent(i[O])}&`}else o+=`${f}${encodeURIComponent(i)}&`}o=o.slice(0,-1),e.params={},e.url=o}return e},t=>(console.log("====>> req err",t),Promise.reject(t))),d.interceptors.response.use(async t=>{const{code:e}=t.data;return e===401?q():e!==1&&e!==0?(t.config.noTips!==!0&&t.data.msg&&u.showRequestErr(t.data.msg),Promise.reject(e)):t.data},t=>{if(t.config.noTips!==!0){let{message:e}=t;e==="Network Error"?e="后端接口连接异常":e.includes("timeout")?e="系统接口请求超时":e.includes("Request failed with status code")&&(e=`系统接口${e.substr(e.length-3)}异常`),u.showRequestErr(e)}return Promise.reject(t)});function q(){return u.showRequestErr("无效的会话,或者会话已过期,请重新登录。").then(()=>{u.logoutHandle()}),Promise.reject("无效的会话,或者会话已过期,请重新登录。")}const g=(t,e)=>d({...t},e),c={store:null,setStore(t){this.store=t},getStore(){return this.store},dispatch(t,e){this.store&&this.store.dispatch(t,e)}},m=(t,e)=>t.then(n=>{console.log("请求返回",n);const o=[null,n];return e&&e(o),o}).catch(n=>{console.error("请求出错",n);const o=[n,null];return e&&e(o),o}),l={async post(t,e,n,o){const a=`${t}/${e}`,i=JSON.stringify(n)||"{}";await c.dispatch("LoadingManager/startLoading",{fwbm:e}),console.log("发起请求",a,"data:",i);const f=g({...o,url:a,data:i,method:"post",headers:{"Content-Type":"application/json"}},o);return m(f,()=>{c.dispatch("LoadingManager/endLoading",{fwbm:e})})},async get(t,e,n,o){const a=`${t}/${e}`;await c.dispatch("LoadingManager/startLoading",{fwbm:e});const i=g({...o,url:a,params:n,method:"get",headers:{"Content-Type":"application/json"}});return m(i,()=>{c.dispatch("LoadingManager/endLoading",{fwbm:e})})},async _fetch(t,e){return console.log("发起请求:",t.method,",",t.url,",data:",t.params),g(t,e)}},$={install(t,{store:e}){c.setStore(e),e.registerModule("LoadingManager",j)}},D="/config",P={async getDefaultConfig(){const[,t]=await l.get(D,"config.json",null,{noTips:!0});return t?t.data||{}:{}}},L="LOAD_CONFIG",S={namespaced:!0,state:()=>({}),mutations:{[L](t,e){Object.entries(e).forEach(([n,o])=>{r.set(t,n,o)})}},actions:{loadConfig(t,e){t.commit(L,typeof e=="object"?e:{})}}},C={install(t,{store:e,extSettings:n}){e.registerModule("settings",S),P.getDefaultConfig().then(o=>{const a={...n,...o};e.dispatch("settings/loadConfig",a)})}},v={request:l},y={RequestPlugin:u,LoadingManagerPlugin:$,ExtSettingsPlugin:C},w={install:function(t,e){Object.values(y).forEach(n=>{t.use(n,e)})},...v,...y};s.ExtSettingsPlugin=C,s.LoadingManagerPlugin=$,s.RequestPlugin=u,s.default=w,s.request=l,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});