1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import router from '@system.router'; 17import { Log } from '@ohos/base/src/main/ets/utils/Log'; 18import type { MenuOperation } from '@ohos/base/src/main/ets/operation/MenuOperation'; 19import { MenuContext } from '@ohos/base/src/main/ets/operation/MenuContext'; 20import screenManager from '@ohos/base/src/main/ets/manager/ScreenManager'; 21import { JumpSourceToMain } from '@ohos/base/src/main/ets/data/JumpSourceToMain'; 22import { RouterConstants } from '@ohos/base/src/main/ets/constants/RouterConstants'; 23 24const TAG = "GotoPhotosMenuOperation" 25 26export class GotoPhotosMenuOperation implements MenuOperation { 27 private menuContext: MenuContext; 28 29 constructor(menuContext: MenuContext) { 30 this.menuContext = menuContext; 31 } 32 33 doAction(): void { 34 if (this.menuContext == null) { 35 Log.warn(TAG, 'menuContext is null, return'); 36 return; 37 } 38 let jumpSourceToMain = this.menuContext.jumpSourceToMain; 39 Log.info(TAG, `router to pages/index, jumpSource: ${jumpSourceToMain}`); 40 let leftPos = screenManager.isSidebar(); 41 let pageFrom = RouterConstants.ENTRY_FROM.NORMAL; 42 if (jumpSourceToMain == JumpSourceToMain.CAMERA) { 43 pageFrom = RouterConstants.ENTRY_FROM_CAMERA; 44 } 45 router.replace({ 46 uri: leftPos === true ? 'product/pad/view/index' : 'product/phone/view/index', 47 params: { 48 jumpSource: jumpSourceToMain, 49 pageFrom: pageFrom 50 } 51 }); 52 } 53}