global.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /// <reference types="@tarojs/taro" />
  2. declare module '*.png';
  3. declare module '*.gif';
  4. declare module '*.jpg';
  5. declare module '*.jpeg';
  6. declare module '*.svg';
  7. declare module '*.css';
  8. declare module '*.less';
  9. declare module '*.scss';
  10. declare module '*.sass';
  11. declare module '*.styl';
  12. declare namespace NodeJS {
  13. interface ProcessEnv {
  14. /** NODE 内置环境变量, 会影响到最终构建生成产物 */
  15. NODE_ENV: 'development' | 'production';
  16. /** 当前构建的平台 */
  17. TARO_ENV:
  18. | 'weapp'
  19. | 'swan'
  20. | 'alipay'
  21. | 'h5'
  22. | 'rn'
  23. | 'tt'
  24. | 'qq'
  25. | 'jd'
  26. | 'harmony'
  27. | 'jdrn';
  28. /**
  29. * 当前构建的小程序 appid
  30. * @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
  31. * @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
  32. */
  33. TARO_APP_ID: string;
  34. USE_MSW?: string;
  35. }
  36. }
  37. // Webpack 注入的全局常量
  38. declare const API_BASE_URL_FROM_WEBPACK: string;
  39. declare const MQTT_BROKER_URL_FROM_WEBPACK: string;
  40. // Electron Storage API 类型定义
  41. declare global {
  42. interface Window {
  43. electronStorage?: {
  44. getItem: (key: string) => Promise<string | null>;
  45. setItem: (key: string, value: string) => Promise<void>;
  46. removeItem: (key: string) => Promise<void>;
  47. };
  48. }
  49. }
  50. // Cordova API 类型定义
  51. declare global {
  52. interface Window {
  53. cordova?: any;
  54. }
  55. interface Navigator {
  56. camera?: {
  57. getPicture: (
  58. successCallback: (imageData: string) => void,
  59. errorCallback: (error: string) => void,
  60. options: any
  61. ) => void;
  62. };
  63. }
  64. // Cordova Device 插件类型定义
  65. interface CordovaDevice {
  66. cordova: string;
  67. model: string;
  68. platform: string;
  69. uuid: string;
  70. version: string;
  71. manufacturer: string;
  72. isVirtual: boolean;
  73. serial: string;
  74. }
  75. const device: CordovaDevice;
  76. // Cordova Camera 插件类型定义
  77. const Camera: {
  78. DestinationType: {
  79. DATA_URL: number;
  80. FILE_URI: number;
  81. NATIVE_URI: number;
  82. };
  83. PictureSourceType: {
  84. PHOTOLIBRARY: number;
  85. CAMERA: number;
  86. SAVEDPHOTOALBUM: number;
  87. };
  88. EncodingType: {
  89. JPEG: number;
  90. PNG: number;
  91. };
  92. MediaType: {
  93. PICTURE: number;
  94. VIDEO: number;
  95. ALLMEDIA: number;
  96. };
  97. };
  98. }
  99. export {};