uni-app.d.ts 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. declare module "@dcloudio/vite-plugin-uni";
  2. declare module "@/uni_modules/cool-vibrate" {
  3. export function vibrate(duration: number): void;
  4. }
  5. declare module "@/uni_modules/cool-open-web" {
  6. export function openWeb(url: string): boolean;
  7. }
  8. declare type Theme = "light" | "dark";
  9. declare interface Uni {
  10. setAppTheme(options: {
  11. theme: "auto" | Theme;
  12. success?: () => void;
  13. fail?: (err: {
  14. errCode: number;
  15. errSubject: string;
  16. data: UTSJSONObject;
  17. errMsg: string;
  18. }) => void;
  19. }): void;
  20. onAppThemeChange(callback: (res: { appTheme: Theme }) => void): number;
  21. onOsThemeChange(callback: (res: { osTheme: Theme }) => void): number;
  22. onHostThemeChange(callback: (res: { hostTheme: Theme }) => void): void;
  23. createCanvasContextAsync(options: {
  24. id: string;
  25. component: ComponentInternalInstance;
  26. success?: (context: CanvasContext) => void;
  27. fail?: (err: {
  28. errCode: number;
  29. errSubject: string;
  30. data: UTSJSONObject;
  31. errMsg: string;
  32. }) => void;
  33. complete?: () => void;
  34. }): Promise<CanvasContext>;
  35. rpx2px(px: number): number;
  36. }
  37. declare interface NodeInfo {
  38. bottom?: number;
  39. context?: number;
  40. dataset?: number;
  41. height?: number;
  42. left?: number;
  43. node?: number;
  44. right?: number;
  45. scrollHeight?: number;
  46. scrollLeft?: number;
  47. scrollTop?: number;
  48. scrollWidth?: number;
  49. top?: number;
  50. width?: number;
  51. }
  52. declare interface UniEvent {
  53. bubbles: boolean;
  54. cancelable: boolean;
  55. type: string;
  56. target: any;
  57. currentTarget: any;
  58. timeStamp: number;
  59. [key: string]: any;
  60. }
  61. declare interface UniInputEvent extends UniEvent {
  62. detail: {
  63. value: string;
  64. cursor: number;
  65. };
  66. }
  67. declare interface UniInputConfirmEvent extends UniEvent {
  68. type: "confirm";
  69. detail: {
  70. value: string;
  71. };
  72. }
  73. declare interface UniInputKeyboardHeightChangeEvent extends UniEvent {
  74. type: "keyboardheightchange";
  75. target: {
  76. autofocus: boolean;
  77. disabled: boolean;
  78. type: string;
  79. value: string;
  80. };
  81. currentTarget: {
  82. autofocus: boolean;
  83. disabled: boolean;
  84. type: string;
  85. value: string;
  86. };
  87. isStopPropagation: boolean;
  88. detail: {
  89. duration: number;
  90. height: number;
  91. };
  92. }
  93. declare interface UniTextareaLineChangeEvent extends UniEvent {
  94. detail: {
  95. lineCount: number;
  96. heightRpx: number;
  97. height: number;
  98. };
  99. }
  100. declare interface UniTextareaBlurEvent extends UniEvent {
  101. detail: {
  102. value: string;
  103. cursor: number;
  104. };
  105. }
  106. declare interface UniTouch {
  107. clientX: number;
  108. clientY: number;
  109. force: number;
  110. identifier: number;
  111. pageX: number;
  112. pageY: number;
  113. radiusX: number;
  114. radiusY: number;
  115. rotationAngle: number;
  116. screenX: number;
  117. screenY: number;
  118. }
  119. declare interface UniTouchEvent extends UniEvent {
  120. changedTouches: {
  121. clientX: number;
  122. clientY: number;
  123. force: number;
  124. identifier: number;
  125. pageX: number;
  126. pageY: number;
  127. screenX: number;
  128. screenY: number;
  129. }[];
  130. touches: UniTouch[];
  131. stopPropagation: () => void;
  132. preventDefault: () => void;
  133. }
  134. declare interface UniPointerEvent extends UniEvent {
  135. clickX: number;
  136. clickY: number;
  137. pageX: number;
  138. pageY: number;
  139. screenX: number;
  140. screenY: number;
  141. x: number;
  142. y: number;
  143. }
  144. declare interface UniSliderChangeEvent extends UniEvent {
  145. detail: {
  146. value: number;
  147. };
  148. }
  149. declare interface UniPickerViewChangeEvent extends UniEvent {
  150. detail: {
  151. value: number[];
  152. };
  153. }
  154. declare interface UniScrollEvent extends UniEvent {
  155. detail: {
  156. scrollTop: number;
  157. scrollLeft: number;
  158. scrollHeight: number;
  159. scrollWidth: number;
  160. deltaY: number;
  161. deltaX: number;
  162. };
  163. }
  164. declare interface UniSwiperChangeEvent extends UniEvent {
  165. detail: {
  166. current: number;
  167. currentItemId: string;
  168. source: string;
  169. };
  170. }
  171. declare interface UniMouseEvent extends UniEvent {
  172. clientX: number;
  173. clientY: number;
  174. pageX: number;
  175. pageY: number;
  176. screenX: number;
  177. screenY: number;
  178. x: number;
  179. y: number;
  180. }
  181. declare interface UniImageLoadEvent extends UniEvent {
  182. detail: {
  183. width: number;
  184. height: number;
  185. };
  186. }
  187. declare interface JSON {
  188. parseObject<T>(text: string): T | null;
  189. }
  190. declare type UTSJSONObject = {
  191. [key: string]: any;
  192. parse?<T>(): T | null;
  193. get?(key: string): any | null;
  194. set?(key: string, value: any | null): void;
  195. getAny?(key: string): any | null;
  196. getAny?(key: string, def: any): any;
  197. getBoolean?(key: string): boolean | null;
  198. getBoolean?(key: string, def: any): boolean;
  199. getNumber?(key: string): number | null;
  200. getNumber?(key: string, def: any): number;
  201. getString?(key: string): string | null;
  202. getString?(key: string, def: any): string;
  203. getJSON?(key: string): UTSJSONObject | null;
  204. getJSON?(key: string, def: any): UTSJSONObject;
  205. getArray?<T>(key: string): T[] | null;
  206. getArray?<T>(key: string, def: T[]): T[];
  207. getArray?(key: string): any[] | null;
  208. getArray?(key: string, def: any[]): any[];
  209. toMap?(): Map<string, any>;
  210. };
  211. declare interface ChooseImageTempFile {
  212. path: string;
  213. size: number;
  214. name: string;
  215. type: string;
  216. }
  217. declare type RequestMethod =
  218. | "OPTIONS"
  219. | "GET"
  220. | "HEAD"
  221. | "POST"
  222. | "PUT"
  223. | "DELETE"
  224. | "TRACE"
  225. | "CONNECT";
  226. declare const onAddToFavorites: (
  227. hook: (options: Page.AddToFavoritesOption) => Page.CustomFavoritesContent,
  228. target?: ComponentInternalInstance | null
  229. ) => void;
  230. declare const onBackPress: (
  231. hook: (options: Page.BackPressOption) => any,
  232. target?: ComponentInternalInstance | null
  233. ) => void;
  234. declare const onError: (
  235. hook: (error: string) => void,
  236. target?: ComponentInternalInstance | null
  237. ) => void;
  238. declare const onExit: (hook: () => void, target?: ComponentInternalInstance | null) => void;
  239. declare const onHide: (hook: () => any, target?: ComponentInternalInstance | null) => void;
  240. declare const onInit: (
  241. hook: (query?: AnyObject | undefined) => void,
  242. target?: ComponentInternalInstance | null
  243. ) => void;
  244. declare const onLaunch: (
  245. hook: (options?: App.LaunchShowOption | undefined) => void,
  246. target?: ComponentInternalInstance | null
  247. ) => void;
  248. declare const onLoad: (
  249. hook: (query?: AnyObject | undefined) => void,
  250. target?: ComponentInternalInstance | null
  251. ) => void;
  252. declare const onNavigationBarButtonTap: (
  253. hook: (options: Page.NavigationBarButtonTapOption) => void,
  254. target?: ComponentInternalInstance | null
  255. ) => void;
  256. declare const onNavigationBarSearchInputChanged: (
  257. hook: (event: Page.NavigationBarSearchInputEvent) => void,
  258. target?: ComponentInternalInstance | null
  259. ) => void;
  260. declare const onNavigationBarSearchInputClicked: (
  261. hook: () => any,
  262. target?: ComponentInternalInstance | null
  263. ) => void;
  264. declare const onNavigationBarSearchInputConfirmed: (
  265. hook: (event: Page.NavigationBarSearchInputEvent) => void,
  266. target?: ComponentInternalInstance | null
  267. ) => void;
  268. declare const onNavigationBarSearchInputFocusChanged: (
  269. hook: onNavigationBarSearchInputFocusChangedHook,
  270. target?: ComponentInternalInstance | null
  271. ) => void;
  272. declare type onNavigationBarSearchInputFocusChangedHook = (
  273. options: NavigationBarSearchInputFocusChanged
  274. ) => void;
  275. declare const onPageHide: (hook: () => any, target?: ComponentInternalInstance | null) => void;
  276. declare const onPageNotFound: (
  277. hook: (options: App.PageNotFoundOption) => void,
  278. target?: ComponentInternalInstance | null
  279. ) => void;
  280. declare const onPageScroll: (
  281. hook: (options: Page.PageScrollOption) => void,
  282. target?: ComponentInternalInstance | null
  283. ) => void;
  284. declare const onPageShow: (
  285. hook: ((options?: App.LaunchShowOption | undefined) => void) | (() => void),
  286. target?: ComponentInternalInstance | null
  287. ) => void;
  288. declare const onPullDownRefresh: (
  289. hook: () => any,
  290. target?: ComponentInternalInstance | null
  291. ) => void;
  292. declare const onReachBottom: (hook: () => any, target?: ComponentInternalInstance | null) => void;
  293. declare const onReady: (hook: () => any, target?: ComponentInternalInstance | null) => void;
  294. declare const onResize: (
  295. hook: (options: Page.ResizeOption) => void,
  296. target?: ComponentInternalInstance | null
  297. ) => void;
  298. declare const onSaveExitState: (
  299. hook: onSaveExitStateHook,
  300. target?: ComponentInternalInstance | null
  301. ) => void;
  302. declare type onSaveExitStateHook = () => SaveExitState;
  303. declare const onShareAppMessage: (
  304. hook: (
  305. options: Page.ShareAppMessageOption
  306. ) => Page.CustomShareContent | Promise<Omit<Page.CustomShareContent, "promise">>,
  307. target?: ComponentInternalInstance | null
  308. ) => void;
  309. declare const onShareTimeline: (
  310. hook: () => Page.ShareTimelineContent,
  311. target?: ComponentInternalInstance | null
  312. ) => void;
  313. declare const onShow: (
  314. hook: ((options?: App.LaunchShowOption | undefined) => void) | (() => void),
  315. target?: ComponentInternalInstance | null
  316. ) => void;
  317. declare const onTabItemTap: (
  318. hook: (options: Page.TabItemTapOption) => void,
  319. target?: ComponentInternalInstance | null
  320. ) => void;
  321. declare const onThemeChange: (
  322. hook: (options: UniApp.OnThemeChangeCallbackResult) => void,
  323. target?: ComponentInternalInstance | null
  324. ) => void;
  325. declare const onUnhandledRejection: (
  326. hook: (options: UniApp.OnUnhandledRejectionCallbackResult) => void,
  327. target?: ComponentInternalInstance | null
  328. ) => void;
  329. declare const onUnload: (hook: () => any, target?: ComponentInternalInstance | null) => void;
  330. declare interface UniElement {
  331. $vm: ComponentPublicInstance;
  332. id: string;
  333. firstChild: UniElement;
  334. lastChild: UniElement;
  335. previousSibling: UniElement;
  336. parentElement: UniElement;
  337. children: UniElement[];
  338. attributes: Map<string, any>;
  339. dataset: Map<string, any>;
  340. style: CSSStyleDeclaration;
  341. classList: string[];
  342. takeSnapshot(options: {
  343. success?: (res: { tempFilePath: string }) => void;
  344. fail?: (err: { errCode: number; errMsg: string }) => void;
  345. }): void;
  346. }
  347. declare interface CanvasContext extends HTMLCanvasElement {
  348. createImage(): HTMLImageElement;
  349. reset(): void;
  350. }
  351. declare type Image = HTMLImageElement;
  352. declare type VueApp = any;