提交 d9102fcd 编写于 作者: D DCloud_LXH

feat(harmony): build ext api

上级 c48b667e
...@@ -2,6 +2,10 @@ import { defineAsyncApi as originalDefineAsyncApi, defineOffApi as originalDefin ...@@ -2,6 +2,10 @@ import { defineAsyncApi as originalDefineAsyncApi, defineOffApi as originalDefin
type Anything = Object | null | undefined; type Anything = Object | null | undefined;
type NullType = null | undefined; type NullType = null | undefined;
type FormatArgsValueType = Function | string | number | boolean; type FormatArgsValueType = Function | string | number | boolean;
interface AsyncApiSuccessResult {
}
interface AsyncApiResult {
}
interface ErrRes { interface ErrRes {
errMsg?: string | null; errMsg?: string | null;
errCode?: number | null; errCode?: number | null;
...@@ -103,6 +107,8 @@ function defineOffApi<T>(name: string, fn: () => void, options: ApiOptions<T>): ...@@ -103,6 +107,8 @@ function defineOffApi<T>(name: string, fn: () => void, options: ApiOptions<T>):
const originalOptions = buildOptions(options as ApiOptions<AsyncMethodOptionLike>); const originalOptions = buildOptions(options as ApiOptions<AsyncMethodOptionLike>);
return originalDefineOffApi(name, fn, originalOptions); return originalDefineOffApi(name, fn, originalOptions);
} }
export { AsyncApiSuccessResult as AsyncApiSuccessResult };
export { AsyncApiResult as AsyncApiResult };
export { ErrRes as ErrRes }; export { ErrRes as ErrRes };
export { ApiExcutor as ApiExcutor }; export { ApiExcutor as ApiExcutor };
export { ProtocolOptions as ProtocolOptions }; export { ProtocolOptions as ProtocolOptions };
......
import { IUniError, UTSObject, UniError, UTSJSONObject, string, AsyncApiSuccessResult, AsyncApiResult, ComponentPublicInstance, ComponentInternalInstance } from './uts' import { IUniError, UTSObject, UniError, UTSJSONObject, string, ComponentPublicInstance, ComponentInternalInstance } from './uts'
import { defineAsyncApi, defineSyncApi, defineTaskApi, defineOnApi, defineOffApi, ApiExcutor, ProtocolOptions, ApiOptions, ErrRes } from './uni-api-shared' import { defineAsyncApi, defineSyncApi, defineTaskApi, defineOnApi, defineOffApi, AsyncApiSuccessResult, AsyncApiResult, ApiExcutor, ProtocolOptions, ApiOptions, ErrRes } from './uni-api-shared'
import bundleManager from '@ohos.bundle.bundleManager'; import bundleManager from '@ohos.bundle.bundleManager';
import deviceInfo from '@ohos.deviceInfo'; import deviceInfo from '@ohos.deviceInfo';
...@@ -33,6 +33,7 @@ import { getOSRuntime, getCurrentPage as getCurrentPage1 } from "../../../resour ...@@ -33,6 +33,7 @@ import { getOSRuntime, getCurrentPage as getCurrentPage1 } from "../../../resour
import { getRealPath as getRealPath1 } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev"; import { getRealPath as getRealPath1 } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev";
import { getRealPath as getRealPath2, Emitter as Emitter1 } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev"; import { getRealPath as getRealPath2, Emitter as Emitter1 } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev";
import { getRealPath } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev"; import { getRealPath } from "../../../resources/rawfile/uni-app/uni-app-harmony-framework-dev";
import harmonyWindow from '@ohos.window';
import harmonyWindow1 from '@ohos.window'; import harmonyWindow1 from '@ohos.window';
import http1 from '@ohos.net.http'; import http1 from '@ohos.net.http';
import http2 from '@ohos.net.http'; import http2 from '@ohos.net.http';
...@@ -607,14 +608,14 @@ export function initUniExtApi(APP_ID: string) { ...@@ -607,14 +608,14 @@ export function initUniExtApi(APP_ID: string) {
}; };
const internalGetWindowInfo = (): GetWindowInfoResult =>{ const internalGetWindowInfo = (): GetWindowInfoResult =>{
const pixelRatio = vp2px(1); const pixelRatio = vp2px(1);
const windowStage: harmonyWindow1.WindowStage = UTSHarmony3.getWindowStage(); const windowStage: harmonyWindow.WindowStage = UTSHarmony3.getWindowStage();
let topRect: harmonyWindow1.Rect = { let topRect: harmonyWindow.Rect = {
top: 0, top: 0,
left: 0, left: 0,
width: 0, width: 0,
height: 136 height: 136
}; };
let bottomRect: harmonyWindow1.Rect = { let bottomRect: harmonyWindow.Rect = {
top: 0, top: 0,
left: 0, left: 0,
width: 0, width: 0,
...@@ -622,8 +623,8 @@ export function initUniExtApi(APP_ID: string) { ...@@ -622,8 +623,8 @@ export function initUniExtApi(APP_ID: string) {
}; };
if (windowStage) { if (windowStage) {
const mainWindow = windowStage.getMainWindowSync(); const mainWindow = windowStage.getMainWindowSync();
topRect = mainWindow.getWindowAvoidArea(harmonyWindow1.AvoidAreaType.TYPE_SYSTEM).topRect; topRect = mainWindow.getWindowAvoidArea(harmonyWindow.AvoidAreaType.TYPE_SYSTEM).topRect;
bottomRect = mainWindow.getWindowAvoidArea(harmonyWindow1.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect; bottomRect = mainWindow.getWindowAvoidArea(harmonyWindow.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect;
} }
const defaultDisplay = display.getDefaultDisplaySync(); const defaultDisplay = display.getDefaultDisplaySync();
const currentPage: ESObject = getCurrentPage(); const currentPage: ESObject = getCurrentPage();
...@@ -2618,11 +2619,11 @@ export function initUniExtApi(APP_ID: string) { ...@@ -2618,11 +2619,11 @@ export function initUniExtApi(APP_ID: string) {
const API_RPX2PX = 'rpx2px'; const API_RPX2PX = 'rpx2px';
const EPS = 1e-4; const EPS = 1e-4;
const rpx2px: Rpx2px = defineSyncApi<number>(API_RPX2PX, (number: number): number =>{ const rpx2px: Rpx2px = defineSyncApi<number>(API_RPX2PX, (number: number): number =>{
const windowStage: harmonyWindow.WindowStage = UTSHarmony6.getWindowStage(); const windowStage: harmonyWindow1.WindowStage = UTSHarmony6.getWindowStage();
let windowWidthInVp: number = 384; let windowWidthInVp: number = 384;
let windowWidthInPx: number = 1344; let windowWidthInPx: number = 1344;
if (windowStage) { if (windowStage) {
const mainWindow: harmonyWindow.Window = windowStage.getMainWindowSync(); const mainWindow: harmonyWindow1.Window = windowStage.getMainWindowSync();
windowWidthInPx = mainWindow.getWindowProperties().windowRect.width; windowWidthInPx = mainWindow.getWindowProperties().windowRect.width;
windowWidthInVp = px2vp(windowWidthInPx); windowWidthInVp = px2vp(windowWidthInPx);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册