296 lines
10 KiB
TypeScript
296 lines
10 KiB
TypeScript
// Generated by dts-bundle v0.7.3
|
||
|
||
declare module '@jdmini/api' {
|
||
import { onLoginReady, waitLogin } from '@jdmini/api/app';
|
||
import HttpClient, { gatewayHttpClient, baseHttpClient, apiHttpClient } from '@jdmini/api/httpClient';
|
||
import { injectApp, injectPage, injectComponent, hijackApp, hijackAllPage } from '@jdmini/api/injector';
|
||
import adManager from '@jdmini/api/adManager';
|
||
export { onLoginReady, waitLogin, injectApp, injectPage, injectComponent, hijackApp, hijackAllPage, gatewayHttpClient, baseHttpClient, apiHttpClient, HttpClient, adManager, };
|
||
}
|
||
|
||
declare module '@jdmini/api/app' {
|
||
export interface AppOptions {
|
||
gatewayUrl?: string;
|
||
baseUrl?: string;
|
||
apiUrl?: string;
|
||
}
|
||
export interface PageOptions {
|
||
showInterstitialAd?: boolean;
|
||
}
|
||
export function initApp(options?: AppOptions): Promise<void>;
|
||
export function showPage(options: PageOptions | undefined, pageId: string): Promise<void>;
|
||
export const checkTokenValid: () => boolean;
|
||
/**
|
||
* 确保登录完成
|
||
* @param {Function} callback - 回调函数
|
||
* @returns {void}
|
||
*/
|
||
export function onLoginReady(callback: (...args: any[]) => void): void;
|
||
/**
|
||
* 等待登录完成
|
||
* @returns {Promise<void>}
|
||
*/
|
||
export function waitLogin(): Promise<void>;
|
||
export function login(): Promise<void>;
|
||
export function fetchEchoData(): Promise<void>;
|
||
export function trackVisit(): Promise<void>;
|
||
}
|
||
|
||
declare module '@jdmini/api/httpClient' {
|
||
import { HttpClientOptions, RequestOptions, ApiResponse } from '@jdmini/api/types';
|
||
class HttpClient {
|
||
constructor({ baseURL, timeout }: HttpClientOptions);
|
||
setBaseURL(baseURL: string): void;
|
||
/**
|
||
* 请求
|
||
* @param {string} path 路径
|
||
* @param {string} method 方法, 默认GET
|
||
* @param {Object} data 数据, 默认{}
|
||
* @param {Object} options 传入wx.request的其他配置, 默认{}
|
||
* @returns {Promise<Object>} 返回一个Promise对象
|
||
*/
|
||
request<T = any>(path: string, method?: WechatMiniprogram.RequestOption['method'], data?: Record<string, any>, options?: RequestOptions): Promise<ApiResponse<T>>;
|
||
/**
|
||
* 上传文件
|
||
* @param {string} filePath 文件路径
|
||
* @param {Object} data 数据, 默认{}
|
||
* @param {'avatar' | 'file'} type 类型, 默认'file'
|
||
* @returns {Promise<Object>} 返回一个Promise对象
|
||
*/
|
||
uploadFile<T = any>(filePath: string, data?: Record<string, any>, type?: 'avatar' | 'file'): Promise<ApiResponse<T>>;
|
||
/**
|
||
* 上传文件
|
||
* @param {string} filePath 文件路径
|
||
* @param {Object} data 数据, 默认{}
|
||
* @param {'avatar' | 'file'} type 类型, 默认'file'
|
||
* @returns {Promise<Object>} 返回一个Promise对象
|
||
*/
|
||
upload<T = any>(path: string, filePath: string, data?: Record<string, any>): Promise<ApiResponse<T>>;
|
||
/**
|
||
* 删除文件
|
||
* @param {number} fileId 文件id
|
||
* @returns {Promise<Object>} 返回一个Promise对象
|
||
*/
|
||
deleteFile(fileId: number): Promise<ApiResponse<null>>;
|
||
/**
|
||
* 上传头像
|
||
* @param {string} filePath 文件路径
|
||
* @returns {Promise<Object>} 返回一个Promise对象
|
||
*/
|
||
uploadAvatar<T = any>(filePath: string): Promise<ApiResponse<T>>;
|
||
}
|
||
export const gatewayHttpClient: HttpClient;
|
||
export const baseHttpClient: HttpClient;
|
||
export const apiHttpClient: HttpClient;
|
||
export default HttpClient;
|
||
}
|
||
|
||
declare module '@jdmini/api/injector' {
|
||
interface AppConfig {
|
||
onLaunch?: (...args: any[]) => void | Promise<void>;
|
||
[key: string]: any;
|
||
}
|
||
interface PageConfig {
|
||
onShow?: (...args: any[]) => void | Promise<void>;
|
||
[key: string]: any;
|
||
}
|
||
interface ComponentConfig {
|
||
methods?: {
|
||
onLoad?: (...args: any[]) => void | Promise<void>;
|
||
onShow?: (...args: any[]) => void | Promise<void>;
|
||
[key: string]: any;
|
||
};
|
||
[key: string]: any;
|
||
}
|
||
interface InjectAppOptions {
|
||
gatewayUrl?: string;
|
||
baseUrl?: string;
|
||
apiUrl?: string;
|
||
}
|
||
interface InjectPageOptions {
|
||
showInterstitialAd?: boolean;
|
||
}
|
||
/**
|
||
* 注入应用配置
|
||
* @param {Object} options - 配置选项
|
||
* @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
|
||
* @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
|
||
* @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
|
||
* @returns {Function} 返回一个接收应用配置的函数
|
||
*/
|
||
export function injectApp(options?: InjectAppOptions): (appConfig: AppConfig) => AppConfig;
|
||
/**
|
||
* 注入页面配置
|
||
* @param {InjectPageOptions} options - 配置选项
|
||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||
* @returns {Function} 返回一个接收页面配置的函数
|
||
*/
|
||
export function injectPage(options?: InjectPageOptions): (pageConfig?: PageConfig) => PageConfig;
|
||
/**
|
||
* 注入组件配置
|
||
* @param {InjectPageOptions} options - 配置选项
|
||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||
* @returns {Function} 返回一个接收组件配置的函数
|
||
*/
|
||
export function injectComponent(options?: InjectPageOptions): (pageConfig?: PageConfig) => ComponentConfig;
|
||
/**
|
||
* 劫持App
|
||
* @param {InjectAppOptions} options - 配置选项
|
||
* @param {string} [options.gatewayUrl] - 网关地址,默认使用CONFIG.API.GATEWAY_URL
|
||
* @param {string} [options.baseUrl] - 基础地址,默认使用CONFIG.API.BASE_URL
|
||
* @param {string} [options.apiUrl] - api地址,默认使用CONFIG.API.API_URL
|
||
* @returns {void}
|
||
*/
|
||
export const hijackApp: (options?: InjectAppOptions) => void;
|
||
/**
|
||
* 劫持所有Page
|
||
* @param {InjectPageOptions} options - 配置选项
|
||
* @param {boolean} [options.showInterstitialAd] - 是否在onShow显示插屏广告,默认不显示
|
||
* @returns {void}
|
||
*/
|
||
export const hijackAllPage: (options?: InjectPageOptions) => void;
|
||
export {};
|
||
}
|
||
|
||
declare module '@jdmini/api/adManager' {
|
||
import { AdData, LinkData, TopData } from '@jdmini/api/types';
|
||
type Ads = Partial<Record<AdData['appPage'], AdData['ads'][0]['adUnitId']>>;
|
||
class AdManager {
|
||
/**
|
||
* 广告数据
|
||
*/
|
||
ads: Ads;
|
||
/**
|
||
* 友情链接数据
|
||
*/
|
||
link: LinkData[];
|
||
/**
|
||
* 友情链接顶部广告数据
|
||
*/
|
||
top: TopData | null;
|
||
constructor();
|
||
/**
|
||
* 确保广告数据就绪
|
||
* @param {Function} callback - 回调函数
|
||
* @returns {void}
|
||
*/
|
||
onDataReady: (callback: (...args: any[]) => void) => void;
|
||
/**
|
||
* 等待广告数据加载完成
|
||
* @returns {Promise<void>}
|
||
*/
|
||
waitAdData: () => Promise<void>;
|
||
/**
|
||
* 初始化广告数据
|
||
* @returns {void}
|
||
*/
|
||
init: () => void;
|
||
/**
|
||
* 创建并展示插屏广告
|
||
* @returns {Promise<void>}
|
||
*/
|
||
createAndShowInterstitialAd: () => Promise<void>;
|
||
/**
|
||
* 创建并展示激励视频广告
|
||
* @param {any} context - 页面上下文
|
||
* @param {string} [pageId] - 页面ID
|
||
* @returns {Promise<boolean>} 是否完成播放
|
||
*/
|
||
createAndShowRewardedVideoAd: (context: any, pageId?: string) => Promise<boolean>;
|
||
}
|
||
const _default: AdManager;
|
||
export default _default;
|
||
}
|
||
|
||
declare module '@jdmini/api/types' {
|
||
export interface Config {
|
||
API: {
|
||
GATEWAY_URL: string;
|
||
BASE_URL: string;
|
||
API_URL: string;
|
||
};
|
||
APP: {
|
||
APP_ID: number;
|
||
LOGIN_MAX_RETRY: number;
|
||
};
|
||
HTTP: {
|
||
TIMEOUT: number;
|
||
};
|
||
DATA: {
|
||
PAGE_ID: string;
|
||
};
|
||
STORAGE_KEYS: {
|
||
TOKEN: string;
|
||
USER_INFO: string;
|
||
SPA_DATA: string;
|
||
LINK_DATA: string;
|
||
TOP_DATA: string;
|
||
};
|
||
EVENT_KEYS: {
|
||
LOGIN_SUCCESS: string;
|
||
AD_DATA_READY: string;
|
||
REWARDED_VIDEO_AD_CLOSE: string;
|
||
};
|
||
}
|
||
export interface HttpClientOptions {
|
||
baseURL: string;
|
||
timeout?: number;
|
||
}
|
||
export interface RequestOptions {
|
||
headers?: Record<string, string>;
|
||
[key: string]: any;
|
||
}
|
||
export interface LoginData {
|
||
appId: number;
|
||
code: string;
|
||
brand: string;
|
||
model: string;
|
||
platform: string;
|
||
}
|
||
export interface ApiResponse<T = any> {
|
||
code: number;
|
||
message?: string;
|
||
data?: T;
|
||
}
|
||
export interface UserInfo {
|
||
token: string;
|
||
user: {
|
||
id: number;
|
||
name: string;
|
||
avatar: string;
|
||
openId: string;
|
||
};
|
||
}
|
||
export interface EchoData {
|
||
isPublished: boolean;
|
||
spads: AdData[];
|
||
links: LinkData[];
|
||
top: TopData;
|
||
version: number;
|
||
}
|
||
export interface AdData {
|
||
id: number;
|
||
status: number;
|
||
appPage: 'banner' | 'custom' | 'video' | 'interstitial' | 'rewarded';
|
||
ads: {
|
||
id: number;
|
||
type: number;
|
||
adId: number;
|
||
adUnitId: string;
|
||
}[];
|
||
}
|
||
export interface LinkData {
|
||
appId: string;
|
||
appLogo: string;
|
||
linkName: string;
|
||
linkPage: string;
|
||
}
|
||
export interface TopData {
|
||
appId: string;
|
||
appLogo: string;
|
||
linkName: string;
|
||
appDsc: string;
|
||
}
|
||
}
|
||
|