Skip to content

Commit

Permalink
feat(core): 增加类型定义
Browse files Browse the repository at this point in the history
  • Loading branch information
meixg committed Aug 23, 2019
1 parent 3e7a851 commit 9042b34
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
21 changes: 17 additions & 4 deletions packages/mars-core/types/index.d.ts
@@ -1,14 +1,25 @@
export {default as Vue, PropType} from './vue/index';
import Vue from './vue/index';
import {swanApp, marsApis} from './mars';
export {swanApp} from './mars';
import {
swanApp,
marsApis
} from './mars';
export {
swanApp,
backgroundAudioManager
} from './mars';

// 补充 this. 上的属性和方法
declare module './vue/vue' {
interface Vue {
$myProperty: string;
$mpUpdated: (cb?: Function) => Promise<any>;
$api: marsApis
$api: marsApis;
$mp: {
options: any;
query: any;
scope: any;
}
}
}

Expand All @@ -18,6 +29,8 @@ declare module './vue/options' {
onLoad?: Function;
onReady?: Function;
onHide?: Function;
config?: any
onLaunch?: Function;
config?: any;
onShow?: Function;
}
}
11 changes: 8 additions & 3 deletions packages/mars-core/types/mars.d.ts
Expand Up @@ -3,7 +3,8 @@ import {
swanApiOptionsNavigateToSmartProgram,
swanApiOptionsGetStorage,
backgroundAudioManager,
swanApiOptionsRecognizeImage
swanApiOptionsRecognizeImage,
swanApiOptionsSetKeepScreenOn
} from './swan';
declare global {
const getApp: () => swanApp;
Expand All @@ -15,11 +16,15 @@ export interface swanApp {
$api: marsApis;
}

export {
backgroundAudioManager
} from './swan';

export interface marsApis {
navigateToSmartProgram: (options: swanApiOptionsNavigateToSmartProgram) => Promise<void>;
getStorage: (options: swanApiOptionsGetStorage) => Promise<any>;
setStorage: (options: any) => Promise<any>;
getBackgroundAudioManager: () => Promise<backgroundAudioManager>;
getBackgroundAudioManager: () => backgroundAudioManager;
request: (options: any) => Promise<any>;
login: (options?: any) => Promise<any>;
showModal: (options?: any) => Promise<any>;
Expand All @@ -42,11 +47,11 @@ export interface marsApis {
}[];
}
}>;

createSelectorQuery: () => {
select: (options?: any) => {
boundingClientRect: () => void;
},
exec: (options?: any) => void;
};
setKeepScreenOn: (options?: swanApiOptionsSetKeepScreenOn) => Promise<any>;
}
4 changes: 4 additions & 0 deletions packages/mars-core/types/swan.d.ts
Expand Up @@ -37,6 +37,10 @@ export interface swanApiOptionsShowLoading extends swanApiOptionsBase {
mask?: boolean;
}

export interface swanApiOptionsSetKeepScreenOn extends swanApiOptionsBase {
keepScreenOn: boolean;
}

export interface swanApiOptionsShowToast extends swanApiOptionsBase {
title: string;
icon?: string;
Expand Down

0 comments on commit 9042b34

Please sign in to comment.