You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

2 weeks ago
  1. /**
  2. * Vue Jsonp.
  3. * # Carry Your World #
  4. *
  5. * @author: LancerComet
  6. * @license: MIT
  7. */
  8. import { PluginObject } from 'vue/types/plugin';
  9. declare module 'vue/types/vue' {
  10. interface Vue {
  11. $jsonp: typeof jsonp;
  12. }
  13. }
  14. /**
  15. * Vue JSONP.
  16. */
  17. declare const VueJsonp: PluginObject<never>;
  18. /**
  19. * JSONP function.
  20. *
  21. * @param { string } url Target URL address.
  22. * @param { IJsonpParam } param Querying params object.
  23. * @param { number } timeout Timeout setting (ms).
  24. *
  25. * @example
  26. * jsonp('/url', {
  27. * callbackQuery: ''
  28. * callbackName: '',
  29. * name: 'LancerComet',
  30. * age: 26
  31. * }, 1000)
  32. */
  33. declare function jsonp<T = any>(url: string, param?: IJsonpParam, timeout?: number): Promise<T>;
  34. export { VueJsonp, jsonp };
  35. /**
  36. * JSONP parameter declaration.
  37. */
  38. interface IJsonpParam {
  39. /**
  40. * Callback query name.
  41. * This param is used to define the query name of the callback function.
  42. *
  43. * @example
  44. * // The request url will be "/some-url?myCallback=jsonp_func&myCustomUrlParam=veryNice"
  45. * jsonp('/some-url', {
  46. * callbackQuery: 'myCallback',
  47. * callbackName: 'jsonp_func',
  48. * myCustomUrlParam: 'veryNice'
  49. * })
  50. *
  51. * @default callback
  52. */
  53. callbackQuery?: string;
  54. /**
  55. * Callback function name.
  56. * This param is used to define the jsonp function name.
  57. *
  58. * @example
  59. * // The request url will be "/some-url?myCallback=jsonp_func&myCustomUrlParam=veryNice"
  60. * jsonp('/some-url', {
  61. * callbackQuery: 'myCallback',
  62. * callbackName: 'jsonp_func',
  63. * myCustomUrlParam: 'veryNice'
  64. * })
  65. *
  66. * @default jsonp_ + randomStr()
  67. */
  68. callbackName?: string;
  69. /**
  70. * Custom data.
  71. */
  72. [key: string]: any;
  73. }