fmode-ng-augmentation.d.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Type augmentation for fmode-ng
  2. // 扩展接口,添加缺失的方法定义
  3. // 扩展 fmode-ng/social 的接口
  4. declare module 'fmode-ng/social' {
  5. // 导出 WxworkCurrentChat 接口
  6. export interface WxworkCurrentChat {
  7. type?: string;
  8. chatId?: string;
  9. group?: any;
  10. contact?: any;
  11. id?: string;
  12. [key: string]: any;
  13. }
  14. // 扩展 WxworkAuth 接口
  15. interface WxworkAuth {
  16. currentProfile?(): Promise<any>;
  17. currentContact?(): Promise<any>;
  18. }
  19. // 扩展 WxworkCorp 接口
  20. interface WxworkCorp {
  21. ticket?: {
  22. get(): Promise<any>;
  23. };
  24. auth?: {
  25. getuserinfo(code: string): Promise<any>;
  26. };
  27. externalContact?: {
  28. get(userId: string): Promise<any>;
  29. groupChat: {
  30. get(chatId: string): Promise<any>;
  31. addJoinWay(options: any): Promise<{ config_id?: string; [key: string]: any }>;
  32. getJoinWay(configId: string): Promise<{ join_way?: { qr_code?: string; url?: string; [key: string]: any }; [key: string]: any }>;
  33. };
  34. };
  35. message?: {
  36. sendText(chatId: string, content: string): Promise<any>;
  37. sendMarkdown(options: any): Promise<any>;
  38. sendNews(options: any): Promise<any>;
  39. };
  40. appchat?: {
  41. sendText(chatId: string, message: string): Promise<any>;
  42. };
  43. }
  44. // 扩展 WxworkSDK 接口
  45. interface WxworkSDK {
  46. ww?: any;
  47. getCurrentChat?(): Promise<any>;
  48. syncContact?(contactInfo: any): Promise<any>;
  49. syncGroupChat?(groupInfo: any): Promise<any>;
  50. getCurrentUser?(): Promise<any>;
  51. }
  52. }
  53. // 扩展 Window,声明 window.fmode.alert/input
  54. declare global {
  55. interface Window {
  56. fmode?: {
  57. alert?: (detail: any) => Promise<any> | any;
  58. // 新增:confirm 简化方法,入参支持字符串或配置对象,返回点击结果布尔值
  59. confirm?: (messageOrDetail: any) => Promise<boolean>;
  60. // 保留对象用法:传入配置对象,返回 Alert 的 onDidDismiss 结果
  61. input?: ((detail: any) => Promise<any>)
  62. // 新增字符串简化用法:与await window?.fmode?.input(message, defaultValue) 一致,返回 string 或 null
  63. & ((message: string, defaultValue?: string) => Promise<string | null>);
  64. [key: string]: any;
  65. };
  66. }
  67. }
  68. export {};