UNPKG

bjchy-auth-sdk

Version:

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

78 lines (64 loc) 2 kB
/** * bjchy-auth-sdk TypeScript 声明文件 * @version 2.0.0 */ import { Component } from 'vue' import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios' // 扫码登录组件 export declare const QrCodeLogin: Component<{ streetKey?: 'blz' | 'yyc' | 'hjl' title?: string subtitle?: string onLoginSuccess?: (data: LoginSuccessData) => void onLoginError?: (error: LoginError) => void onStatusChange?: (status: QRStatus) => void }> // 登录成功数据类型 export interface LoginSuccessData { token: string userInfo: { id: string name: string username: string [key: string]: any } [key: string]: any } // 登录错误类型 export interface LoginError { type: 'network' | 'timeout' | 'server' | 'unknown' error: Error | string message?: string } // 二维码状态 export type QRStatus = 'generated' | 'scanned' | 'expired' // 街道键类型 export type StreetKey = 'blz' | 'yyc' | 'hjl' // 街道配置类型 export interface StreetConfig { key: StreetKey name: string } // 请求工具 export declare const request: AxiosInstance export declare function createRequest(config?: AxiosRequestConfig): AxiosInstance // 街道工具 export declare function detectStreetKey(): StreetKey | null export declare function getStreetConfig(streetKey: StreetKey): StreetConfig | null export declare function setCurrentStreet(streetKey: StreetKey): void // 二维码工具 export declare function generateQRCode(data: string): Promise<string> export declare function generateQRCodeImage(data: string, options?: any): Promise<string> // 认证工具 export declare function logout(): void export declare function checkLoginStatus(): boolean export declare function getCurrentUser(): any | null export declare function getCurrentToken(): string | null // 默认导出(Vue插件) declare const BjchyAuthSDK: { install(app: any, options?: { baseURL?: string streetKey?: StreetKey }): void } export default BjchyAuthSDK