UNPKG

bjchy-auth-sdk

Version:

朝阳区认证SDK - 简洁易用的扫码登录和请求工具包

3 lines (2 loc) 39.3 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("axios"),n={blz:{key:"blz",name:"八里庄街道"},yyc:{key:"yyc",name:"亚运村街道"},hjl:{key:"hjl",name:"呼家楼街道"}};function o(e=window.location.href){const t=new URLSearchParams(window.location.search).get("street");if(t&&n[t])return t;const o=window.location.pathname.split("/").filter((e=>e));for(const l of o)if(n[l])return l;const r=window.location.hostname.toLowerCase();for(const l in n)if(r.includes(l))return l;const i=Object.keys(n).join("|"),s=new RegExp(`(${i})`,"gi"),a=e.match(s);if(a&&a[0]&&n[a[0].toLowerCase()]){return a[0].toLowerCase()}const c=localStorage.getItem("bjchy_current_street");return c&&n[c]?c:null}function r(e){return n[e]||null}function i(e){n[e]&&(localStorage.setItem("bjchy_current_street",e),"undefined"!=typeof window&&(window.__BJCHY_CURRENT_STREET__=e))}const s={baseURL:"https://pdb.bjchy.gov.cn/mdb3/api",timeout:1e4,tokenKey:"bjchy_token",enableAutoDetectStreet:!0,enableTokenAutoRefresh:!0,loginUrl:"/",tokenErrorCodes:["TOKEN_EXPIRED","INVALID_TOKEN","TOKEN_MALFORMED","TOKEN_NOT_ACTIVE","MISSING_TOKEN","MISSING_AUTH_HEADER","INVALID_AUTH_FORMAT","TOKEN_EXTRACTION_ERROR"]};let a={...s};const c=new Set;function l(e={}){console.log("📝 配置SDK:",e);const t={...a,...e};if(e.baseURL&&"string"!=typeof e.baseURL)throw new Error("baseURL 必须是字符串类型");if(e.timeout&&("number"!=typeof e.timeout||e.timeout<=0))throw new Error("timeout 必须是正数");const n={...a};return a=t,c.forEach((e=>{try{e(t,n)}catch(o){console.error("配置监听器执行失败:",o)}})),console.log("✅ SDK配置已更新:",a),a}function u(){return{...a}}function d(e){if("function"!=typeof e)throw new Error("监听器必须是函数");c.add(e)}function f(){const e=u(),n=t.create({baseURL:e.baseURL,timeout:e.timeout,headers:{"Content-Type":"application/json"}});return n.interceptors.request.use((t=>{const n=localStorage.getItem(e.tokenKey);if(n&&(t.headers.Authorization=`Bearer ${n}`),e.enableAutoDetectStreet){const e=o();e&&(t.headers["X-Street-Key"]=e)}return t}),(e=>Promise.reject(e))),n.interceptors.response.use((t=>{const n=t.data;if(n&&!1===n.success&&n.code&&e.tokenErrorCodes.includes(n.code)){localStorage.removeItem(e.tokenKey),localStorage.removeItem("bjchy_user_info"),window.dispatchEvent(new CustomEvent("bjchy-token-expired",{detail:{response:n,streetKey:o()}}));const t=e.loginUrl||"/";return"undefined"!=typeof window&&window.location&&(console.log(`🔄 Token失效(${n.code}),自动跳转到:`,t),console.log("错误信息:",n.error||n.message)),Promise.reject(new Error(n.error||n.message||"Token失效"))}if(e.enableTokenAutoRefresh){const n=t.headers["x-new-token"];n&&localStorage.setItem(e.tokenKey,n)}return t.data}),(t=>{var n;if(401===(null==(n=t.response)?void 0:n.status)){localStorage.removeItem(e.tokenKey),localStorage.removeItem("bjchy_user_info"),window.dispatchEvent(new CustomEvent("bjchy-token-expired",{detail:{error:t,streetKey:o()}}));const n=e.loginUrl||"/";"undefined"!=typeof window&&window.location&&(console.log("🔄 Token过期(401),自动跳转到:",n),window.location.href=n)}return Promise.reject(t)})),n.get=(e,t={})=>n({method:"GET",url:e,params:t}),n.post=(e,t={})=>n({method:"POST",url:e,data:t}),n.put=(e,t={})=>n({method:"PUT",url:e,data:t}),n.delete=(e,t={})=>n({method:"DELETE",url:e,params:t}),n}let g=f();d(((e,t)=>{(e.baseURL!==t.baseURL||e.timeout!==t.timeout||e.tokenKey!==t.tokenKey||e.enableAutoDetectStreet!==t.enableAutoDetectStreet||e.enableTokenAutoRefresh!==t.enableTokenAutoRefresh||e.loginUrl!==t.loginUrl||JSON.stringify(e.tokenErrorCodes)!==JSON.stringify(t.tokenErrorCodes))&&(console.log("🔄 全局配置变更,重新创建默认请求实例"),g=f(),h.get=g.get,h.post=g.post,h.put=g.put,h.delete=g.delete,Object.setPrototypeOf(h,g),Object.assign(h,g))}));const h=new Proxy(g,{get:(e,t)=>g[t],apply:(e,t,n)=>g.apply(t,n)});var p={},m={},y={};let w;const v=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];y.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},y.getSymbolTotalCodewords=function(e){return v[e]},y.getBCHDigit=function(e){let t=0;for(;0!==e;)t++,e>>>=1;return t},y.setToSJISFunction=function(e){if("function"!=typeof e)throw new Error('"toSJISFunc" is not a valid function.');w=e},y.isKanjiModeEnabled=function(){return void 0!==w},y.toSJIS=function(e){return w(e)};var b,E={};function x(){this.buffer=[],this.length=0}(b=E).L={bit:1},b.M={bit:0},b.Q={bit:3},b.H={bit:2},b.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},b.from=function(e,t){if(b.isValid(e))return e;try{return function(e){if("string"!=typeof e)throw new Error("Param is not a string");switch(e.toLowerCase()){case"l":case"low":return b.L;case"m":case"medium":return b.M;case"q":case"quartile":return b.Q;case"h":case"high":return b.H;default:throw new Error("Unknown EC Level: "+e)}}(e)}catch(n){return t}},x.prototype={get:function(e){const t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(let n=0;n<t;n++)this.putBit(1==(e>>>t-n-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var C=x;function I(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}I.prototype.set=function(e,t,n,o){const r=e*this.size+t;this.data[r]=n,o&&(this.reservedBit[r]=!0)},I.prototype.get=function(e,t){return this.data[e*this.size+t]},I.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},I.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var k=I,N={};!function(e){const t=y.getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];const n=Math.floor(e/7)+2,o=t(e),r=145===o?26:2*Math.ceil((o-13)/(2*n-2)),i=[o-7];for(let t=1;t<n-1;t++)i[t]=i[t-1]-r;return i.push(6),i.reverse()},e.getPositions=function(t){const n=[],o=e.getRowColCoords(t),r=o.length;for(let e=0;e<r;e++)for(let t=0;t<r;t++)0===e&&0===t||0===e&&t===r-1||e===r-1&&0===t||n.push([o[e],o[t]]);return n}}(N);var A={};const T=y.getSymbolSize;A.getPositions=function(e){const t=T(e);return[[0,0],[t-7,0],[0,t-7]]};var R={};!function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t=3,n=3,o=40,r=10;function i(t,n,o){switch(t){case e.Patterns.PATTERN000:return(n+o)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return o%3==0;case e.Patterns.PATTERN011:return(n+o)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(o/3))%2==0;case e.Patterns.PATTERN101:return n*o%2+n*o%3==0;case e.Patterns.PATTERN110:return(n*o%2+n*o%3)%2==0;case e.Patterns.PATTERN111:return(n*o%3+(n+o)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){const n=e.size;let o=0,r=0,i=0,s=null,a=null;for(let c=0;c<n;c++){r=i=0,s=a=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===s?r++:(r>=5&&(o+=t+(r-5)),s=n,r=1),n=e.get(l,c),n===a?i++:(i>=5&&(o+=t+(i-5)),a=n,i=1)}r>=5&&(o+=t+(r-5)),i>=5&&(o+=t+(i-5))}return o},e.getPenaltyN2=function(e){const t=e.size;let o=0;for(let n=0;n<t-1;n++)for(let r=0;r<t-1;r++){const t=e.get(n,r)+e.get(n,r+1)+e.get(n+1,r)+e.get(n+1,r+1);4!==t&&0!==t||o++}return o*n},e.getPenaltyN3=function(e){const t=e.size;let n=0,r=0,i=0;for(let o=0;o<t;o++){r=i=0;for(let s=0;s<t;s++)r=r<<1&2047|e.get(o,s),s>=10&&(1488===r||93===r)&&n++,i=i<<1&2047|e.get(s,o),s>=10&&(1488===i||93===i)&&n++}return n*o},e.getPenaltyN4=function(e){let t=0;const n=e.data.length;for(let o=0;o<n;o++)t+=e.data[o];return Math.abs(Math.ceil(100*t/n/5)-10)*r},e.applyMask=function(e,t){const n=t.size;for(let o=0;o<n;o++)for(let r=0;r<n;r++)t.isReserved(r,o)||t.xor(r,o,i(e,r,o))},e.getBestMask=function(t,n){const o=Object.keys(e.Patterns).length;let r=0,i=1/0;for(let s=0;s<o;s++){n(s),e.applyMask(s,t);const o=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(s,t),o<i&&(i=o,r=s)}return r}}(R);var S={};const B=E,L=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],M=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];S.getBlocksCount=function(e,t){switch(t){case B.L:return L[4*(e-1)+0];case B.M:return L[4*(e-1)+1];case B.Q:return L[4*(e-1)+2];case B.H:return L[4*(e-1)+3];default:return}},S.getTotalCodewordsCount=function(e,t){switch(t){case B.L:return M[4*(e-1)+0];case B.M:return M[4*(e-1)+1];case B.Q:return M[4*(e-1)+2];case B.H:return M[4*(e-1)+3];default:return}};var P={},U={};const _=new Uint8Array(512),K=new Uint8Array(256);!function(){let e=1;for(let t=0;t<255;t++)_[t]=e,K[e]=t,e<<=1,256&e&&(e^=285);for(let t=255;t<512;t++)_[t]=_[t-255]}(),U.log=function(e){if(e<1)throw new Error("log("+e+")");return K[e]},U.exp=function(e){return _[e]},U.mul=function(e,t){return 0===e||0===t?0:_[K[e]+K[t]]},function(e){const t=U;e.mul=function(e,n){const o=new Uint8Array(e.length+n.length-1);for(let r=0;r<e.length;r++)for(let i=0;i<n.length;i++)o[r+i]^=t.mul(e[r],n[i]);return o},e.mod=function(e,n){let o=new Uint8Array(e);for(;o.length-n.length>=0;){const e=o[0];for(let i=0;i<n.length;i++)o[i]^=t.mul(n[i],e);let r=0;for(;r<o.length&&0===o[r];)r++;o=o.slice(r)}return o},e.generateECPolynomial=function(n){let o=new Uint8Array([1]);for(let r=0;r<n;r++)o=e.mul(o,new Uint8Array([1,t.exp(r)]));return o}}(P);const j=P;function D(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}D.prototype.initialize=function(e){this.degree=e,this.genPoly=j.generateECPolynomial(this.degree)},D.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const n=j.mod(t,this.genPoly),o=this.degree-n.length;if(o>0){const e=new Uint8Array(this.degree);return e.set(n,o),e}return n};var z=D,V={},O={},F={isValid:function(e){return!isNaN(e)&&e>=1&&e<=40}},H={};const J="[0-9]+";let Y="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Y=Y.replace(/u/g,"\\u");const q="(?:(?![A-Z0-9 $%*+\\-./:]|"+Y+")(?:.|[\r\n]))+";H.KANJI=new RegExp(Y,"g"),H.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),H.BYTE=new RegExp(q,"g"),H.NUMERIC=new RegExp(J,"g"),H.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");const Q=new RegExp("^"+Y+"$"),$=new RegExp("^"+J+"$"),X=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");H.testKanji=function(e){return Q.test(e)},H.testNumeric=function(e){return $.test(e)},H.testAlphanumeric=function(e){return X.test(e)},function(e){const t=F,n=H;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(n))throw new Error("Invalid version: "+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,n){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(o){return n}}}(O),function(e){const t=y,n=S,o=E,r=O,i=F,s=t.getBCHDigit(7973);function a(e,t){return r.getCharCountIndicator(e,t)+4}function c(e,t){let n=0;return e.forEach((function(e){const o=a(e.mode,t);n+=o+e.getBitsLength()})),n}e.from=function(e,t){return i.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,o,s){if(!i.isValid(e))throw new Error("Invalid QR Code version");void 0===s&&(s=r.BYTE);const c=8*(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,o));if(s===r.MIXED)return c;const l=c-a(s,e);switch(s){case r.NUMERIC:return Math.floor(l/10*3);case r.ALPHANUMERIC:return Math.floor(l/11*2);case r.KANJI:return Math.floor(l/13);case r.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,n){let i;const s=o.from(n,o.M);if(Array.isArray(t)){if(t.length>1)return function(t,n){for(let o=1;o<=40;o++)if(c(t,o)<=e.getCapacity(o,n,r.MIXED))return o}(t,s);if(0===t.length)return 1;i=t[0]}else i=t;return function(t,n,o){for(let r=1;r<=40;r++)if(n<=e.getCapacity(r,o,t))return r}(i.mode,i.getLength(),s)},e.getEncodedBits=function(e){if(!i.isValid(e)||e<7)throw new Error("Invalid QR Code version");let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=7973<<t.getBCHDigit(n)-s;return e<<12|n}}(V);var Z={};const G=y,W=G.getBCHDigit(1335);Z.getEncodedBits=function(e,t){const n=e.bit<<3|t;let o=n<<10;for(;G.getBCHDigit(o)-W>=0;)o^=1335<<G.getBCHDigit(o)-W;return 21522^(n<<10|o)};var ee={};const te=O;function ne(e){this.mode=te.NUMERIC,this.data=e.toString()}ne.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},ne.prototype.getLength=function(){return this.data.length},ne.prototype.getBitsLength=function(){return ne.getBitsLength(this.data.length)},ne.prototype.write=function(e){let t,n,o;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),o=parseInt(n,10),e.put(o,10);const r=this.data.length-t;r>0&&(n=this.data.substr(t),o=parseInt(n,10),e.put(o,3*r+1))};var oe=ne;const re=O,ie=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function se(e){this.mode=re.ALPHANUMERIC,this.data=e}se.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},se.prototype.getLength=function(){return this.data.length},se.prototype.getBitsLength=function(){return se.getBitsLength(this.data.length)},se.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=45*ie.indexOf(this.data[t]);n+=ie.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(ie.indexOf(this.data[t]),6)};var ae=se;const ce=O;function le(e){this.mode=ce.BYTE,this.data="string"==typeof e?(new TextEncoder).encode(e):new Uint8Array(e)}le.getBitsLength=function(e){return 8*e},le.prototype.getLength=function(){return this.data.length},le.prototype.getBitsLength=function(){return le.getBitsLength(this.data.length)},le.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var ue=le;const de=O,fe=y;function ge(e){this.mode=de.KANJI,this.data=e}ge.getBitsLength=function(e){return 13*e},ge.prototype.getLength=function(){return this.data.length},ge.prototype.getBitsLength=function(){return ge.getBitsLength(this.data.length)},ge.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=fe.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[t]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}};var he,pe=ge,me={exports:{}},ye=me.exports=he={single_source_shortest_paths:function(e,t,n){var o={},r={};r[t]=0;var i,s,a,c,l,u,d,f=he.PriorityQueue.make();for(f.push(t,0);!f.empty();)for(a in s=(i=f.pop()).value,c=i.cost,l=e[s]||{})l.hasOwnProperty(a)&&(u=c+l[a],d=r[a],(void 0===r[a]||d>u)&&(r[a]=u,f.push(a,u),o[a]=s));if(void 0!==n&&void 0===r[n]){var g=["Could not find a path from ",t," to ",n,"."].join("");throw new Error(g)}return o},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],o=t;o;)n.push(o),e[o],o=e[o];return n.reverse(),n},find_path:function(e,t,n){var o=he.single_source_shortest_paths(e,t,n);return he.extract_shortest_path_from_predecessor_list(o,n)},PriorityQueue:{make:function(e){var t,n=he.PriorityQueue,o={};for(t in e=e||{},n)n.hasOwnProperty(t)&&(o[t]=n[t]);return o.queue=[],o.sorter=e.sorter||n.default_sorter,o},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};!function(e){const t=O,n=oe,o=ae,r=ue,i=pe,s=H,a=y,c=ye;function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){const o=[];let r;for(;null!==(r=e.exec(n));)o.push({data:r[0],index:r.index,mode:t,length:r[0].length});return o}function d(e){const n=u(s.NUMERIC,t.NUMERIC,e),o=u(s.ALPHANUMERIC,t.ALPHANUMERIC,e);let r,i;a.isKanjiModeEnabled()?(r=u(s.BYTE,t.BYTE,e),i=u(s.KANJI,t.KANJI,e)):(r=u(s.BYTE_KANJI,t.BYTE,e),i=[]);return n.concat(o,r,i).sort((function(e,t){return e.index-t.index})).map((function(e){return{data:e.data,mode:e.mode,length:e.length}}))}function f(e,s){switch(s){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return o.getBitsLength(e);case t.KANJI:return i.getBitsLength(e);case t.BYTE:return r.getBitsLength(e)}}function g(e,s){let c;const l=t.getBestModeForData(e);if(c=t.from(s,l),c!==t.BYTE&&c.bit<l.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(c)+".\n Suggested mode is: "+t.toString(l));switch(c!==t.KANJI||a.isKanjiModeEnabled()||(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new o(e);case t.KANJI:return new i(e);case t.BYTE:return new r(e)}}e.fromArray=function(e){return e.reduce((function(e,t){return"string"==typeof t?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e}),[])},e.fromString=function(n,o){const r=function(e){const n=[];for(let o=0;o<e.length;o++){const r=e[o];switch(r.mode){case t.NUMERIC:n.push([r,{data:r.data,mode:t.ALPHANUMERIC,length:r.length},{data:r.data,mode:t.BYTE,length:r.length}]);break;case t.ALPHANUMERIC:n.push([r,{data:r.data,mode:t.BYTE,length:r.length}]);break;case t.KANJI:n.push([r,{data:r.data,mode:t.BYTE,length:l(r.data)}]);break;case t.BYTE:n.push([{data:r.data,mode:t.BYTE,length:l(r.data)}])}}return n}(d(n,a.isKanjiModeEnabled())),i=function(e,n){const o={},r={start:{}};let i=["start"];for(let s=0;s<e.length;s++){const a=e[s],c=[];for(let e=0;e<a.length;e++){const l=a[e],u=""+s+e;c.push(u),o[u]={node:l,lastCount:0},r[u]={};for(let e=0;e<i.length;e++){const s=i[e];o[s]&&o[s].node.mode===l.mode?(r[s][u]=f(o[s].lastCount+l.length,l.mode)-f(o[s].lastCount,l.mode),o[s].lastCount+=l.length):(o[s]&&(o[s].lastCount=l.length),r[s][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}i=c}for(let t=0;t<i.length;t++)r[i[t]].end=0;return{map:r,table:o}}(r,o),s=c.find_path(i.map,"start","end"),u=[];for(let e=1;e<s.length-1;e++)u.push(i.table[s[e]].node);return e.fromArray(function(e){return e.reduce((function(e,t){const n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)}),[])}(u))},e.rawSplit=function(t){return e.fromArray(d(t,a.isKanjiModeEnabled()))}}(ee);const we=y,ve=E,be=C,Ee=k,xe=N,Ce=A,Ie=R,ke=S,Ne=z,Ae=V,Te=Z,Re=O,Se=ee;function Be(e,t,n){const o=e.size,r=Te.getEncodedBits(t,n);let i,s;for(i=0;i<15;i++)s=1==(r>>i&1),i<6?e.set(i,8,s,!0):i<8?e.set(i+1,8,s,!0):e.set(o-15+i,8,s,!0),i<8?e.set(8,o-i-1,s,!0):i<9?e.set(8,15-i-1+1,s,!0):e.set(8,15-i-1,s,!0);e.set(o-8,8,1,!0)}function Le(e,t,n){const o=new be;n.forEach((function(t){o.put(t.mode.bit,4),o.put(t.getLength(),Re.getCharCountIndicator(t.mode,e)),t.write(o)}));const r=8*(we.getSymbolTotalCodewords(e)-ke.getTotalCodewordsCount(e,t));for(o.getLengthInBits()+4<=r&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(0);const i=(r-o.getLengthInBits())/8;for(let s=0;s<i;s++)o.put(s%2?17:236,8);return function(e,t,n){const o=we.getSymbolTotalCodewords(t),r=ke.getTotalCodewordsCount(t,n),i=o-r,s=ke.getBlocksCount(t,n),a=o%s,c=s-a,l=Math.floor(o/s),u=Math.floor(i/s),d=u+1,f=l-u,g=new Ne(f);let h=0;const p=new Array(s),m=new Array(s);let y=0;const w=new Uint8Array(e.buffer);for(let C=0;C<s;C++){const e=C<c?u:d;p[C]=w.slice(h,h+e),m[C]=g.encode(p[C]),h+=e,y=Math.max(y,e)}const v=new Uint8Array(o);let b,E,x=0;for(b=0;b<y;b++)for(E=0;E<s;E++)b<p[E].length&&(v[x++]=p[E][b]);for(b=0;b<f;b++)for(E=0;E<s;E++)v[x++]=m[E][b];return v}(o,e,t)}function Me(e,t,n,o){let r;if(Array.isArray(e))r=Se.fromArray(e);else{if("string"!=typeof e)throw new Error("Invalid data");{let o=t;if(!o){const t=Se.rawSplit(e);o=Ae.getBestVersionForData(t,n)}r=Se.fromString(e,o||40)}}const i=Ae.getBestVersionForData(r,n);if(!i)throw new Error("The amount of data is too big to be stored in a QR Code");if(t){if(t<i)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+i+".\n")}else t=i;const s=Le(t,n,r),a=we.getSymbolSize(t),c=new Ee(a);return function(e,t){const n=e.size,o=Ce.getPositions(t);for(let r=0;r<o.length;r++){const t=o[r][0],i=o[r][1];for(let o=-1;o<=7;o++)if(!(t+o<=-1||n<=t+o))for(let r=-1;r<=7;r++)i+r<=-1||n<=i+r||(o>=0&&o<=6&&(0===r||6===r)||r>=0&&r<=6&&(0===o||6===o)||o>=2&&o<=4&&r>=2&&r<=4?e.set(t+o,i+r,!0,!0):e.set(t+o,i+r,!1,!0))}}(c,t),function(e){const t=e.size;for(let n=8;n<t-8;n++){const t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}(c),function(e,t){const n=xe.getPositions(t);for(let o=0;o<n.length;o++){const t=n[o][0],r=n[o][1];for(let n=-2;n<=2;n++)for(let o=-2;o<=2;o++)-2===n||2===n||-2===o||2===o||0===n&&0===o?e.set(t+n,r+o,!0,!0):e.set(t+n,r+o,!1,!0)}}(c,t),Be(c,n,0),t>=7&&function(e,t){const n=e.size,o=Ae.getEncodedBits(t);let r,i,s;for(let a=0;a<18;a++)r=Math.floor(a/3),i=a%3+n-8-3,s=1==(o>>a&1),e.set(r,i,s,!0),e.set(i,r,s,!0)}(c,t),function(e,t){const n=e.size;let o=-1,r=n-1,i=7,s=0;for(let a=n-1;a>0;a-=2)for(6===a&&a--;;){for(let n=0;n<2;n++)if(!e.isReserved(r,a-n)){let o=!1;s<t.length&&(o=1==(t[s]>>>i&1)),e.set(r,a-n,o),i--,-1===i&&(s++,i=7)}if(r+=o,r<0||n<=r){r-=o,o=-o;break}}}(c,s),isNaN(o)&&(o=Ie.getBestMask(c,Be.bind(null,c,n))),Ie.applyMask(o,c),Be(c,n,o),{modules:c,version:t,errorCorrectionLevel:n,maskPattern:o,segments:r}}m.create=function(e,t){if(void 0===e||""===e)throw new Error("No input text");let n,o,r=ve.M;return void 0!==t&&(r=ve.from(t.errorCorrectionLevel,ve.M),n=Ae.from(t.version),o=Ie.from(t.maskPattern),t.toSJISFunc&&we.setToSJISFunction(t.toSJISFunc)),Me(e,n,r,o)};var Pe={},Ue={};!function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");let t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map((function(e){return[e,e]})))),6===t.length&&t.push("F","F");const n=parseInt(t.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:255&n,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});const n=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,o=e.width&&e.width>=21?e.width:void 0,r=e.scale||4;return{width:o,scale:o?4:r,margin:n,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,n){const o=e.getScale(t,n);return Math.floor((t+2*n.margin)*o)},e.qrToImageData=function(t,n,o){const r=n.modules.size,i=n.modules.data,s=e.getScale(r,o),a=Math.floor((r+2*o.margin)*s),c=o.margin*s,l=[o.color.light,o.color.dark];for(let e=0;e<a;e++)for(let n=0;n<a;n++){let u=4*(e*a+n),d=o.color.light;if(e>=c&&n>=c&&e<a-c&&n<a-c){d=l[i[Math.floor((e-c)/s)*r+Math.floor((n-c)/s)]?1:0]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}}(Ue),function(e){const t=Ue;e.render=function(e,n,o){let r=o,i=n;void 0!==r||n&&n.getContext||(r=n,n=void 0),n||(i=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),r=t.getOptions(r);const s=t.getImageWidth(e.modules.size,r),a=i.getContext("2d"),c=a.createImageData(s,s);return t.qrToImageData(c.data,e,r),function(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+"px",t.style.width=n+"px"}(a,i,s),a.putImageData(c,0,0),i},e.renderToDataURL=function(t,n,o){let r=o;void 0!==r||n&&n.getContext||(r=n,n=void 0),r||(r={});const i=e.render(t,n,r),s=r.type||"image/png",a=r.rendererOpts||{};return i.toDataURL(s,a.quality)}}(Pe);var _e={};const Ke=Ue;function je(e,t){const n=e.a/255,o=t+'="'+e.hex+'"';return n<1?o+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':o}function De(e,t,n){let o=e+t;return void 0!==n&&(o+=" "+n),o}_e.render=function(e,t,n){const o=Ke.getOptions(t),r=e.modules.size,i=e.modules.data,s=r+2*o.margin,a=o.color.light.a?"<path "+je(o.color.light,"fill")+' d="M0 0h'+s+"v"+s+'H0z"/>':"",c="<path "+je(o.color.dark,"stroke")+' d="'+function(e,t,n){let o="",r=0,i=!1,s=0;for(let a=0;a<e.length;a++){const c=Math.floor(a%t),l=Math.floor(a/t);c||i||(i=!0),e[a]?(s++,a>0&&c>0&&e[a-1]||(o+=i?De("M",c+n,.5+l+n):De("m",r,0),r=0,i=!1),c+1<t&&e[a+1]||(o+=De("h",s),s=0)):r++}return o}(i,r,o.margin)+'"/>',l='viewBox="0 0 '+s+" "+s+'"',u='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+l+' shape-rendering="crispEdges">'+a+c+"</svg>\n";return"function"==typeof n&&n(null,u),u};const ze=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then},Ve=m,Oe=Pe,Fe=_e;function He(e,t,n,o,r){const i=[].slice.call(arguments,1),s=i.length,a="function"==typeof i[s-1];if(!a&&!ze())throw new Error("Callback required as last argument");if(!a){if(s<1)throw new Error("Too few arguments provided");return 1===s?(n=t,t=o=void 0):2!==s||t.getContext||(o=n,n=t,t=void 0),new Promise((function(r,i){try{const i=Ve.create(n,o);r(e(i,t,o))}catch(s){i(s)}}))}if(s<2)throw new Error("Too few arguments provided");2===s?(r=n,n=t,t=o=void 0):3===s&&(t.getContext&&void 0===r?(r=o,o=void 0):(r=o,o=n,n=t,t=void 0));try{const i=Ve.create(n,o);r(null,e(i,t,o))}catch(c){r(c)}}p.create=Ve.create,p.toCanvas=He.bind(null,Oe.render),p.toDataURL=He.bind(null,Oe.renderToDataURL),p.toString=He.bind(null,(function(e,t,n){return Fe.render(e,n)}));const Je=async(e,t={})=>{try{const n={...{width:200,height:200,margin:2,color:{dark:"#000000",light:"#FFFFFF"}},...t};return await p.toDataURL(e,n)}catch(n){throw console.error("生成二维码失败:",n),n}},Ye=Je,qe={class:"bjchy-qrcode-login",style:{width:"100%","max-width":"400px",margin:"0 auto",padding:"24px",background:"#ffffff","border-radius":"12px","box-shadow":"0 4px 20px rgba(0, 0, 0, 0.08)",border:"1px solid #e5e7eb","font-family":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif"}},Qe={key:0,style:{"text-align":"center","margin-bottom":"32px"}},$e={key:0,style:{margin:"0 0 8px 0","font-size":"24px","font-weight":"600",color:"#1f2937","line-height":"1.3"}},Xe={key:1,style:{margin:"0","font-size":"14px",color:"#6b7280","line-height":"1.4"}},Ze={style:{display:"flex","flex-direction":"column","align-items":"center",gap:"20px"}},Ge={key:0,style:{display:"flex","justify-content":"center","align-items":"center",padding:"40px 20px",background:"#fef2f2","border-radius":"12px",border:"2px solid #fecaca",width:"240px","min-height":"240px","box-sizing":"border-box"}},We={style:{"text-align":"center"}},et={style:{margin:"0","font-size":"14px",color:"#7f1d1d","line-height":"1.4"}},tt={key:1,style:{display:"flex","justify-content":"center","align-items":"center",padding:"20px",background:"#f9fafb","border-radius":"12px",border:"2px dashed #d1d5db"}},nt=["src"],ot={key:2,style:{display:"flex","justify-content":"center","align-items":"center",padding:"40px 20px",background:"#fef2f2","border-radius":"12px",border:"2px solid #fecaca",width:"240px",height:"240px","box-sizing":"border-box"}},rt={key:3,style:{display:"flex","justify-content":"center","align-items":"center","flex-direction":"column",padding:"40px 20px",background:"#f3f4f6","border-radius":"12px",border:"2px dashed #d1d5db",width:"240px",height:"240px","box-sizing":"border-box"}},it={key:4,style:{display:"flex","align-items":"center","justify-content":"center",gap:"12px",padding:"16px 20px",background:"#f8fafc","border-radius":"8px",border:"1px solid #e2e8f0","min-height":"20px"}},st={style:{"font-size":"14px","font-weight":"500",color:"#475569","text-align":"center","line-height":"1.4"}},at=((e,t)=>{const n=e.__vccOpts||e;for(const[o,r]of t)n[o]=r;return n})({__name:"QrCodeLogin",props:{streetKey:{type:String,default:""},title:{type:String,default:""},subtitle:{type:String,default:""}},emits:["login-success","login-error","status-change"],setup(t,{emit:s}){const a=Object.keys(n),c=async(e,t)=>{b.value=!0,p.value="confirmed",A(),R();const n=u();localStorage.setItem(n.tokenKey,e),localStorage.setItem("bjchy_user_info",JSON.stringify(t)),d("login-success",{token:e,userInfo:t,status:"confirmed"})},l=t,d=s,f=e.ref(""),g=e.ref(""),p=e.ref("waiting"),m=e.ref(null),y=e.ref(6e4),w=e.ref(null),v=e.ref(""),b=e.ref(!1),E=e.computed((()=>{if(l.streetKey)return a.includes(l.streetKey)?l.streetKey:(v.value="无效的标识",null);const e=o();return e&&a.includes(e)?e:(v.value="无法获取配置信息。",null)})),x=e.computed((()=>{if(!E.value)return"";const e=r(E.value);return e?e.name:""})),C=e.computed((()=>({waiting:x.value?`请使用微信扫描${x.value}二维码`:"请使用微信扫描二维码",scanned:"扫描成功,请在手机上确认登录",confirmed:"登录成功,正在跳转...",expired:"二维码已过期,请重新生成"}[p.value]||"请使用微信扫描二维码"))),I=()=>{const e={waiting:"background: #94a3b8;",scanned:"background: #f59e0b;",confirmed:"background: #10b981;",expired:"background: #ef4444;"};return"width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; transition: all 0.3s ease; "+(e[p.value]||e.waiting)},k=async()=>{try{if(b.value)return;if(!E.value)return void d("login-error",{type:"invalid-street-key",error:v.value});A(),R(),i(E.value),g.value=B();const e=`https://636c-cloud1-6gb0waw79d5650f1-1311446109.tcb.qcloud.la/webcode/${E.value}/t=scanwebcode&t=scanwebcode&id=${g.value}&p=login`;f.value=await Ye(e,{width:200,height:200}),p.value="waiting",N(),T(),d("status-change",{status:"generated",sessionId:g.value,streetKey:E.value})}catch(e){console.error("生成二维码失败:",e),A(),R(),d("login-error",{type:"qrcode-generation-failed",error:e})}},N=()=>{b.value||(A(),m.value=setInterval((async()=>{try{if(b.value||!g.value||!E.value)return void A();const e=await h.post("/auth/statuscheck",{sessionId:g.value,streetKey:E.value});e.success&&e.data?"confirmed"===e.data.status?await c(e.data.token,e.data.userInfo):"scanned"===e.data.status&&(p.value="scanned",d("status-change",{status:"scanned"})):e.message&&e.message.includes("过期")&&(p.value="expired",A(),R(),d("status-change",{status:"expired"}))}catch(e){console.error("检查登录状态失败:",e)}}),2e3))},A=()=>{m.value&&(clearInterval(m.value),m.value=null)},T=()=>{R(),y.value=6e4,w.value=setInterval((()=>{y.value-=100,y.value<=0&&(p.value="expired",A(),R(),d("status-change",{status:"timeout"}))}),100)},R=()=>{w.value&&(clearInterval(w.value),w.value=null)},S=()=>{E.value&&(A(),R(),setTimeout((()=>{k()}),100))},B=(e=16)=>{const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let o=0;o<e;o++)n+=t.charAt(Math.floor(62*Math.random()));return n};e.watch((()=>l.streetKey),(()=>{v.value="",E.value&&(A(),R(),setTimeout((()=>{k()}),100))}),{immediate:!1});const L=()=>{document.hidden&&!b.value?(A(),R()):!document.hidden&&!b.value&&E.value&&g.value&&(N(),T())};return e.onMounted((async()=>{if(E.value){await(async()=>{const e=new URLSearchParams(window.location.search).get("sid");if(e)try{g.value=e,console.log("检测到URL中的sessionId,尝试直接登录...");const t=await h.post("/auth/statuscheck",{sessionId:e,streetKey:E.value}),{status:n,token:o,userInfo:r}=t.data;return"confirmed"===n&&o?(console.log("URL sessionId登录成功"),await c(o,r),!0):(console.log("URL sessionId登录失败,状态为:",n),!1)}catch(t){return console.error("URL sessionId登录失败:",t),!1}return!1})()||k()}document.addEventListener("visibilitychange",L)})),e.onUnmounted((()=>{b.value=!0,A(),R(),document.removeEventListener("visibilitychange",L)})),(t,n)=>(e.openBlock(),e.createElementBlock("div",qe,[l.title||l.subtitle?(e.openBlock(),e.createElementBlock("div",Qe,[l.title?(e.openBlock(),e.createElementBlock("h2",$e,e.toDisplayString(l.title),1)):e.createCommentVNode("",!0),l.subtitle?(e.openBlock(),e.createElementBlock("p",Xe,e.toDisplayString(l.subtitle),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",Ze,[v.value?(e.openBlock(),e.createElementBlock("div",Ge,[e.createElementVNode("div",We,[n[0]||(n[0]=e.createElementVNode("div",{style:{width:"48px",height:"48px",background:"#fca5a5","border-radius":"50%",display:"flex","align-items":"center","justify-content":"center",margin:"0 auto 16px"}},[e.createElementVNode("span",{style:{color:"#991b1b","font-size":"24px","font-weight":"bold"}},"!")],-1)),n[1]||(n[1]=e.createElementVNode("p",{style:{margin:"0 0 8px 0","font-size":"16px",color:"#991b1b","font-weight":"600"}},"配置错误",-1)),e.createElementVNode("p",et,e.toDisplayString(v.value),1)])])):f.value&&"expired"!==p.value?(e.openBlock(),e.createElementBlock("div",tt,[e.createElementVNode("img",{src:f.value,alt:"登录二维码",style:{width:"200px",height:"200px","border-radius":"8px",display:"block"}},null,8,nt)])):"expired"===p.value?(e.openBlock(),e.createElementBlock("div",ot,[e.createElementVNode("div",{style:{"text-align":"center"}},[n[2]||(n[2]=e.createElementVNode("p",{style:{margin:"0 0 16px 0","font-size":"16px",color:"#991b1b","font-weight":"500"}},"二维码已过期",-1)),e.createElementVNode("button",{onClick:S,style:{background:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",color:"white",border:"none",padding:"12px 24px","border-radius":"8px","font-size":"14px","font-weight":"500",cursor:"pointer","box-shadow":"0 2px 8px rgba(59, 130, 246, 0.3)"}}," 刷新二维码 ")])])):v.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",rt,n[3]||(n[3]=[e.createElementVNode("div",{style:{width:"24px",height:"24px",border:"3px solid #e5e7eb","border-top":"3px solid #3b82f6","border-radius":"50%",animation:"spin 1s linear infinite","margin-bottom":"16px"}},null,-1),e.createElementVNode("p",{style:{margin:"0","font-size":"14px",color:"#6b7280","text-align":"center"}},"正在生成二维码...",-1)]))),v.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",it,[e.createElementVNode("span",st,e.toDisplayString(C.value),1),e.createElementVNode("div",{style:e.normalizeStyle(I())},null,4)]))])]))}},[["__scopeId","data-v-f465c1d0"]]),ct=()=>{const e=localStorage.getItem("bjchy_token"),t=localStorage.getItem("bjchy_user_info");if(!e)return{isLoggedIn:!1,token:null,userInfo:null};try{return{isLoggedIn:!0,token:e,userInfo:t?JSON.parse(t):null}}catch(n){return console.error("解析用户信息失败:",n),localStorage.removeItem("bjchy_user_info"),{isLoggedIn:!!e,token:e,userInfo:null}}};const lt={install:function(e,t={}){(t.baseURL||t.timeout||t.tokenKey||t.loginUrl||t.tokenErrorCodes)&&(console.log("🔧 通过Vue插件配置SDK:",t),l(t)),e.component("QrCodeLogin",at);const n=t.streetKey||o();n&&i(n),e.config.globalProperties.$bjchyAuth={request:h,streetKey:n,detectStreetKey:o,setCurrentStreet:i},e.provide("bjchyAuth",{request:h,streetKey:n,detectStreetKey:o,setCurrentStreet:i})}};exports.QrCodeLogin=at,exports.addConfigListener=d,exports.checkLoginStatus=ct,exports.configureSDK=l,exports.default=lt,exports.detectStreetKey=o,exports.generateQRCode=Je,exports.generateQRCodeImage=Ye,exports.getConfigValue=function(e){return a[e]},exports.getCurrentStreetKey=function(){if("undefined"!=typeof window&&window.__BJCHY_CURRENT_STREET__)return window.__BJCHY_CURRENT_STREET__;const e=localStorage.getItem("bjchy_current_street");return e&&n[e]?e:o()},exports.getCurrentToken=()=>localStorage.getItem("bjchy_token"),exports.getCurrentUser=()=>{const{userInfo:e}=ct();return e},exports.getSDKConfig=u,exports.getStreetConfig=r,exports.logout=async(e={})=>{const{clearLocal:t=!0,sendRequest:n=!0}=e;try{const e={success:!0,localCleared:!1,serverNotified:!1};if(n)try{if(localStorage.getItem("bjchy_token")){const t=await h.get("/auth/logout");e.serverNotified=!0,console.log("服务器退出成功:",t)}}catch(o){console.warn("服务器退出请求失败:",o)}return t&&(localStorage.removeItem("bjchy_token"),localStorage.removeItem("bjchy_user_info"),e.localCleared=!0,console.log("本地认证信息已清除")),e}catch(o){return console.error("退出登录失败:",o),{success:!1,error:o.message||"退出登录失败",localCleared:!1,serverNotified:!1}}},exports.printConfig=function(){console.group("🔧 当前SDK配置"),Object.entries(a).forEach((([e,t])=>{console.log(`${e}:`,t)})),console.groupEnd()},exports.removeConfigListener=function(e){c.delete(e)},exports.request=h,exports.resetSDKConfig=function(){console.log("🔄 重置SDK配置为默认值"),l(s)},exports.setCurrentStreet=i,exports.validateConfig=function(){const e=[];return a.baseURL?"string"!=typeof a.baseURL?e.push("baseURL 必须是字符串"):a.baseURL.startsWith("http")||e.push("baseURL 必须以 http:// 或 https:// 开头"):e.push("baseURL 不能为空"),a.timeout<=0&&e.push("timeout 必须大于 0"),a.tokenKey&&"string"==typeof a.tokenKey||e.push("tokenKey 不能为空且必须是字符串"),{valid:0===e.length,errors:e}}; //# sourceMappingURL=index.cjs.js.map