global.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. // Cordova API 类型定义
  38. declare global {
  39. interface Window {
  40. cordova?: any;
  41. }
  42. interface Navigator {
  43. camera?: {
  44. getPicture: (
  45. successCallback: (imageData: string) => void,
  46. errorCallback: (error: string) => void,
  47. options: any
  48. ) => void;
  49. };
  50. }
  51. // Cordova Camera 插件类型定义
  52. const Camera: {
  53. DestinationType: {
  54. DATA_URL: number;
  55. FILE_URI: number;
  56. NATIVE_URI: number;
  57. };
  58. PictureSourceType: {
  59. PHOTOLIBRARY: number;
  60. CAMERA: number;
  61. SAVEDPHOTOALBUM: number;
  62. };
  63. EncodingType: {
  64. JPEG: number;
  65. PNG: number;
  66. };
  67. MediaType: {
  68. PICTURE: number;
  69. VIDEO: number;
  70. ALLMEDIA: number;
  71. };
  72. };
  73. }
  74. export {};