tt-extensions.d.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /**
  2. * 补充 @douyin-microapp/typings 中缺失的抖音小程序 API 类型声明
  3. * 这些 API 在运行时是可用的,但在 @douyin-microapp/typings@1.3.1 中未被声明
  4. *
  5. * 如需补充更多缺失的 API,直接在下方 TtExtensions 接口中添加即可,全项目生效。
  6. */
  7. interface ShareAppMessageOptions {
  8. title?: string;
  9. imageUrl?: string;
  10. query?: string;
  11. channel?: string;
  12. desc?: string;
  13. extra?: Record<string, any>;
  14. templateId?: string;
  15. }
  16. interface RequestGamePaymentOptions {
  17. mode: string;
  18. env: number;
  19. platform?: string;
  20. currencyType: string;
  21. buyQuantity?: number;
  22. zoneId?: string;
  23. customId?: string;
  24. goodType?: number;
  25. orderAmount?: number;
  26. goodName?: string;
  27. extraInfo?: string;
  28. success?: (res: any) => void;
  29. fail?: (error: any) => void;
  30. complete?: (res: any) => void;
  31. }
  32. interface OpenAwemeCustomerServiceOptions {
  33. zoneId?: string;
  34. customId?: string;
  35. currencyType?: string;
  36. buyQuantity?: number;
  37. goodType?: number;
  38. orderAmount?: number;
  39. goodName?: string;
  40. extraInfo?: string;
  41. success?: (res: any) => void;
  42. fail?: (error: any) => void;
  43. complete?: (res: any) => void;
  44. }
  45. interface TtExtensions {
  46. /** 主动拉起转发,进入选择通讯录界面 */
  47. shareAppMessage: (options: ShareAppMessageOptions) => void;
  48. /** 监听用户点击右上角菜单中的「转发」按钮时触发的事件 */
  49. onShareAppMessage: (
  50. callback: (options?: {
  51. from?: string;
  52. target?: any;
  53. webViewUrl?: string;
  54. }) => ShareAppMessageOptions
  55. ) => void;
  56. /** 取消监听用户点击右上角菜单中的「转发」按钮时触发的事件 */
  57. offShareAppMessage: (callback?: (...args: any[]) => void) => void;
  58. /** 安卓虚拟支付 */
  59. requestGamePayment: (options: RequestGamePaymentOptions) => void;
  60. /** iOS 拉起抖音客服支付 */
  61. openAwemeCustomerService: (options: OpenAwemeCustomerServiceOptions) => void;
  62. }
  63. declare global {
  64. const tt: typeof import("@douyin-microapp/typings/types/api") & TtExtensions;
  65. }
  66. export {};