Skip to content

Commit

Permalink
feat(harmony): 支持 setPageMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
StrivingRabbit committed Mar 7, 2025
1 parent 14499a6 commit 1500743
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
10 changes: 6 additions & 4 deletions packages/uni-app-harmony/dist/uni.runtime.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8626,9 +8626,6 @@ function parseRedirectInfo() {
}

const TEMP_PATH = ''; // TODO 需要从applicationContext获取
function setCurrentPageMeta(page, options) {
// TODO: Implement
}

function operateVideoPlayer(videoId, pageId, type, data) {
UniServiceJSBridge.invokeViewMethod('video.' + videoId, {
Expand All @@ -8645,6 +8642,11 @@ function operateMap(id, pageId, type, data, operateMapCallback) {
}, pageId, operateMapCallback);
}

function setCurrentPageMeta(page, options) {
const pageId = getPageIdByVm(page);
UniServiceJSBridge.invokeViewMethod('setPageMeta', options, pageId);
}

const API_UPX2PX = 'upx2px';
const Upx2pxProtocol = [
{
Expand Down Expand Up @@ -10576,7 +10578,7 @@ const setLocale = defineSyncApi(API_SET_LOCALE, (locale) => {

const API_SET_PAGE_META = 'setPageMeta';
const setPageMeta = defineAsyncApi(API_SET_PAGE_META, (options, { resolve }) => {
resolve(setCurrentPageMeta(getCurrentPageVm()));
resolve(setCurrentPageMeta(getCurrentPageVm(), options));
});

const API_SET_BACKGROUND_COLOR = 'setBackgroundColor';
Expand Down
1 change: 1 addition & 0 deletions packages/uni-app-harmony/src/platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export {
getLaunchOptions,
getEnterOptions,
} from '@dcloudio/uni-app-plus/service/framework/app/utils'
export { setCurrentPageMeta } from '../service/api/ui/setPageMeta'
9 changes: 0 additions & 9 deletions packages/uni-app-harmony/src/platform/todo.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import type { SetPageMetaOptions } from '@dcloudio/uni-api'
import type { ComponentPublicInstance } from 'vue'
export {
requestComponentInfo,
addIntersectionObserver,
removeIntersectionObserver,
} from '@dcloudio/uni-app-plus/platform'

export const TEMP_PATH = '' // TODO 需要从applicationContext获取

export function setCurrentPageMeta(
page: ComponentPublicInstance,
options: SetPageMetaOptions
) {
// TODO: Implement
}
1 change: 0 additions & 1 deletion packages/uni-app-harmony/src/service/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './ui/index'
export * from './ui/index'
export * from './keyboard/keyboard'
export { canIUse } from './base/canIUse'
export { navigateTo } from './route/navigateTo'
Expand Down
11 changes: 11 additions & 0 deletions packages/uni-app-harmony/src/service/api/ui/setPageMeta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { SetPageMetaOptions } from '@dcloudio/uni-api'
import type { ComponentPublicInstance } from 'vue'
import { getPageIdByVm } from '@dcloudio/uni-core'

export function setCurrentPageMeta(
page: ComponentPublicInstance,
options: SetPageMetaOptions
) {
const pageId = getPageIdByVm(page)!
UniServiceJSBridge.invokeViewMethod('setPageMeta', options, pageId)
}

0 comments on commit 1500743

Please sign in to comment.