新增插件支持类型提示

This commit is contained in:
cool 2024-05-28 16:17:41 +08:00
parent 450700c211
commit dba0331e44
6 changed files with 5 additions and 81 deletions

View File

@ -144,7 +144,7 @@ export class PluginService extends BaseService {
...params
) {
// 实例
const instance = await this.getInstance(key);
const instance: any = await this.getInstance(key);
return await instance[method](...params);
}

View File

@ -89,7 +89,7 @@ export class UserLoginService extends BaseService {
* @param openid
*/
async uniPhone(access_token, openid, appId) {
const instance = await this.pluginService.getInstance('uniphone');
const instance: any = await this.pluginService.getInstance('uniphone');
const phone = await instance.getPhone(access_token, openid, appId);
if (phone) {
return await this.phone(phone);

View File

@ -32,7 +32,7 @@ export class UserWxService extends BaseService {
* @returns
*/
async getMiniApp() {
const wxPlugin = await this.pluginService.getInstance('wx');
const wxPlugin: any = await this.pluginService.getInstance('wx');
return wxPlugin.MiniApp();
}
@ -41,7 +41,7 @@ export class UserWxService extends BaseService {
* @returns
*/
async getOfficialAccount() {
const wxPlugin = await this.pluginService.getInstance('wx');
const wxPlugin: any = await this.pluginService.getInstance('wx');
return wxPlugin.OfficialAccount();
}
@ -50,7 +50,7 @@ export class UserWxService extends BaseService {
* @returns
*/
async getOpenPlatform() {
const wxPlugin = await this.pluginService.getInstance('wx');
const wxPlugin: any = await this.pluginService.getInstance('wx');
return wxPlugin.OpenPlatform();
}

4
typings/plugin.d.ts vendored
View File

@ -1,12 +1,8 @@
import * as wx from './wx';
import * as uniphone from './uniphone';
import { BaseUpload, MODETYPE } from './upload';
type AnyString = string & {};
/**
*
*/
interface PluginMap {
wx: wx.CoolPlugin;
upload: BaseUpload;
uniphone: uniphone.CoolPlugin;
}

14
typings/uniphone.d.ts vendored
View File

@ -1,14 +0,0 @@
import { BasePlugin } from '@cool-midway/plugin-cli';
/**
*
*/
export declare class CoolPlugin extends BasePlugin {
/**
*
* @param access_token access_token
* @param openid openid
* @param appId appId
*/
getPhone(access_token: string, openid: string, appId: string): Promise<any>;
}
export declare const Plugin: typeof CoolPlugin;

58
typings/wx.d.ts vendored
View File

@ -1,58 +0,0 @@
import { BasePlugin } from '@cool-midway/plugin-cli';
import {
OfficialAccount,
MiniApp,
Pay,
OpenPlatform,
Work,
OpenWork,
} from 'node-easywechat';
/**
*
*/
export declare class CoolPlugin extends BasePlugin {
/**
*
* @param config
* @returns
*/
OfficialAccount(config?: any): Promise<any>;
/**
*
* @param config
* @returns
*/
MiniApp(config?: any): Promise<any>;
/**
*
* @param config
* @returns
*/
Pay(config?: any): Promise<any>;
/**
*
* @param config
* @returns
*/
OpenPlatform(config?: any): Promise<any>;
/**
*
* @param config
* @returns
*/
Work(config?: any): Promise<any>;
/**
*
* @param config
* @returns
*/
OpenWork(config?: any): Promise<any>;
/**
*
* @param app
*/
setCache(
app: OfficialAccount | MiniApp | Pay | OpenPlatform | Work | OpenWork
): Promise<void>;
}
export declare const Plugin: typeof CoolPlugin;