chinese直男口爆体育生外卖, 99久久er热在这里只有精品99, 又色又爽又黄18禁美女裸身无遮挡, gogogo高清免费观看日本电视,私密按摩师高清版在线,人妻视频毛茸茸,91论坛 兴趣闲谈,欧美 亚洲 精品 8区,国产精品久久久久精品免费

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

鴻蒙實戰(zhàn)開發(fā):【瀏覽器制作】

jf_46214456 ? 來源:jf_46214456 ? 作者:jf_46214456 ? 2024-03-19 17:47 ? 次閱讀
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

瀏覽器

介紹

本示例使用[@ohos.systemparameter]接口和[Web組件]展示了一個瀏覽器的基本功能,展示網(wǎng)頁,根據(jù)頁面歷史棧前進(jìn)回退等。

效果預(yù)覽

image.png

使用說明:

  1. 連接Wifi,啟動應(yīng)用,展示默認(rèn)頁面內(nèi)容;
  2. 點擊默認(rèn)頁面的圖標(biāo)跳轉(zhuǎn)到對應(yīng)網(wǎng)頁,或者在輸入框輸入網(wǎng)址,點擊右側(cè)跳轉(zhuǎn)按鈕跳轉(zhuǎn)到對應(yīng)網(wǎng)頁;
  3. 點擊輸入框左側(cè)向右向左按鈕進(jìn)行頁面的前進(jìn)后退;
  4. 點擊主頁圖標(biāo)回到主頁,點擊加號按鈕新建一個頁面。

工程目錄

entry/src/main/ets/
|---Application
|   |---AbilityStage.ets                        // 入口
|---pages
|   |---Index.ets                               // 首頁
|---common
|   |---PhoneLayout.ets                         // 窗口管理工具
|   |---TitleBar.ets                            // 導(dǎo)航欄
|---model
|   |---Logger.ts                               // 日志工具
|   |---Browser.ets                             // 瀏覽器實例

具體實現(xiàn)

  • Web展示與歷史棧操作功能在Browser中,源碼參考[Browser.ets]
/*

 * Copyright (c) 2022 Huawei Device Co., Ltd.

 * Licensed under the Apache License, Version 2.0 (the "License");

 * you may not use this file except in compliance with the License.

 * You may obtain a copy of the License at

 *

 *     http://www.apache.org/licenses/LICENSE-2.0

 *

 * Unless required by applicable law or agreed to in writing, software

 * distributed under the License is distributed on an "AS IS" BASIS,

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

 * See the License for the specific language governing permissions and

 * limitations under the License.

 */

import Logger from './Logger'

import prompt from '@ohos.prompt';



export class WebObject {

  controller: WebController;

  isRegistered: boolean;

  constructor(controller: WebController, isRegistered: boolean) {

    this.controller = controller

    this.isRegistered = isRegistered

  }

}



@Observed

class WebKey {

  key: number;

  timestamp: number;



  constructor(key: number, timestamp: number) {

    this.key = key

    this.timestamp = timestamp

  }

}



export enum LoadingStatus {

  LOADING,

  END

}



const TAG: string = '[browser]'



export class Browser {

  inputValue: string = ""

  tabArrayIndex: number = 0

  progress: number = 0

  hideProgress: boolean = true

  loadingStatus: LoadingStatus = LoadingStatus.END



  webArray: Array< WebKey > = [new WebKey(0, new Date().getTime())]

  tabsController: TabsController = new TabsController()

  webControllerArray: Array< WebObject > = [new WebObject(new WebController(), false)]



  deleteTab(index: number) {

    Logger.info(TAG, `delete before tab index= ${index} controller length ${this.webControllerArray.length} tabArrayIndex= ${this.tabArrayIndex}`)

    this.webArray.splice(index, 1)

    this.webControllerArray.splice(index, 1)

    if (this.tabArrayIndex > index || this.tabArrayIndex === this.webArray.length) {

      this.tabArrayIndex -= 1

    }

    for (let i = index;i < this.webArray.length; ++i) {

      this.webArray[i].key -= 1

    }

    for (let i = 0;i < this.webArray.length; ++i) {

      Logger.info(TAG, `key ${this.webArray[i].key}, time=${this.webArray[i].timestamp}`)

    }

    Logger.info(`delete after tab index=${index}, controller length=${this.webControllerArray.length}, tabArrayIndex=${this.tabArrayIndex}`)

    this.tabsController.changeIndex(this.tabArrayIndex)

  }



  getWebArray() {

    return this.webArray

  }



  addTab() {

    if (this.webArray.length > 10) {

      prompt.showToast({

        message: '頁簽數(shù)量已滿'

      })

      return;

    }

    let webController: WebController = new WebController();

    let object = new WebObject(webController, false)

    this.webControllerArray.push(object)

    this.webArray.push(new WebKey(this.webArray.length, new Date().getTime()))

    this.tabArrayIndex = this.webArray.length - 1

    Logger.info(TAG, `add tab index= ${this.tabArrayIndex}`)

    setTimeout(() = > {

      this.tabsController.changeIndex(this.tabArrayIndex)

    }, 50)

  }



  setTabArrayIndex(tabArrayIndex: number) {

    this.tabArrayIndex = tabArrayIndex

  }



  getTabArrayIndex() {

    return this.tabArrayIndex

  }



  setInputVal(inputValue: string) {

    this.inputValue = inputValue

  }



  getInputVal() {

    return this.inputValue

  }



  loadUrl(addr: string) {

    addr = "https://" + addr;

    this.webControllerArray[this.tabArrayIndex].controller.loadUrl({ url: addr })

  }



  Back() {

    if (this.webControllerArray[this.tabArrayIndex].controller.accessBackward()) {

      this.webControllerArray[this.tabArrayIndex].controller.backward()

    }

  }



  Forward() {

    if (this.webControllerArray[this.tabArrayIndex].controller.accessForward()) {

      this.webControllerArray[this.tabArrayIndex].controller.forward()

    }

  }



  Refresh() {

    this.webControllerArray[this.tabArrayIndex].controller.refresh()

  }

}
-   加載網(wǎng)頁及刷新:使用WebController提供的loadUrl可以加載目標(biāo)網(wǎng)址內(nèi)容,使用refresh方法刷新頁面;
-   頁面前進(jìn)后退功能:頁面在前進(jìn)或者后退前使用accessForward/accessBackward查詢是否有歷史記錄,然后調(diào)用forward/backward進(jìn)行前進(jìn)/后退操作。

依賴

不涉及。

約束與限制

  1. 本示例僅支持標(biāo)準(zhǔn)系統(tǒng)上運行;
  2. 本示例需外接鼠標(biāo)進(jìn)行驗證;
  3. 本示例已適配API version 9版本SDK,版本號:3.2.11.9。
  4. 本示例不支持點擊tab頁簽,切換網(wǎng)頁并刷新頁面;
  5. 本示例涉及使用系統(tǒng)接口:[@ohos.systemparameter],需要手動替換Full SDK才能編譯通過。
  6. 本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400, built on April 7, 2023)及以上版本才可編譯運行。

下載

如需單獨下載本工程,執(zhí)行如下命令:

git init
git config core.sparsecheckout true
echo code/BasicFeature/Web/Browser/ > .git/info/sparse-checkout
git remote add origin https://gitee.com/openharmony/applications_app_samples.git
git pull origin master

審核編輯 黃宇

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • 瀏覽器
    +關(guān)注

    關(guān)注

    1

    文章

    1042

    瀏覽量

    36896
  • 鴻蒙
    +關(guān)注

    關(guān)注

    60

    文章

    2839

    瀏覽量

    45334
收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關(guān)推薦
    熱點推薦

    Microsoft Edge瀏覽器iOS端插件功能上線

    在最新發(fā)布的 139 版本中,Microsoft Edge 瀏覽器 iOS 端正式支持插件功能!與此同時,Microsoft Edge 安卓端的插件數(shù)量已躍升至近 30 款。廣告攔截、雙語翻譯、資源下載……你的手機(jī)瀏覽器,也能擁有自定義的「超能力」。
    的頭像 發(fā)表于 08-19 14:29 ?1384次閱讀

    亞馬遜云科技推出Amazon Nova Act SDK預(yù)覽版,加速瀏覽器自動化Agent落地

    北京2025年8月5日 /美通社/ --?亞馬遜云科技日前宣布,推出Amazon Nova Act SDK有限預(yù)覽版,可快速幫助客戶將基于瀏覽器的Agent從原型部署至生產(chǎn)環(huán)境。該SDK可與亞馬遜云
    的頭像 發(fā)表于 08-06 08:42 ?620次閱讀

    微軟Microsoft Edge瀏覽器構(gòu)筑立體式安全防線

    在信息爆炸的今天,釣魚網(wǎng)站、詐騙廣告、隱私追蹤層出不窮。Microsoft Edge 瀏覽器為桌面與移動端用戶構(gòu)筑了立體式安全防線。用七大安全護(hù)盾,保護(hù)你的上網(wǎng)安全。
    的頭像 發(fā)表于 08-04 15:39 ?973次閱讀

    鴻蒙5開發(fā)寶藏案例分享---一多開發(fā)實例(音樂)

    各位開發(fā)者小伙伴們好呀!今天咱們來點硬核干貨!最近在鴻蒙文檔中心挖到一座“金礦”——官方竟然暗藏了100+實戰(zhàn)案例,從分布式架構(gòu)到交互動效優(yōu)化應(yīng)有盡有!這些案例不僅藏著華為工程師的私房技巧,還直接
    的頭像 發(fā)表于 06-30 11:54 ?603次閱讀

    鴻蒙5開發(fā)寶藏案例分享---埋點開發(fā)實戰(zhàn)指南

    鴻蒙埋點開發(fā)寶藏指南:官方案例實戰(zhàn)解析,輕松搞定數(shù)據(jù)追蹤! 大家好呀!我是HarmonyOS開發(fā)路上的探索者。最近在折騰應(yīng)用埋點時,意外發(fā)現(xiàn)了鴻蒙
    發(fā)表于 06-12 16:30

    鴻蒙5開發(fā)隱藏案例分享---自由流轉(zhuǎn)的瀏覽進(jìn)度接續(xù)

    **?**鴻蒙開發(fā)隱藏案例大揭秘!手把手教你玩轉(zhuǎn)應(yīng)用接續(xù)功能? 大家好呀~今天要跟大家分享一個超實用的鴻蒙開發(fā)技巧!之前總覺得鴻蒙的官方文檔
    發(fā)表于 06-03 18:47

    老電視如何安裝瀏覽器

    2017年購買的夏普老電視,1.5G+8G存儲,網(wǎng)上下的瀏覽器APK文件在電視內(nèi)打開就彈出“解析程序包出現(xiàn)問題”。 未知來源選項已打開,存儲空間清空到只剩下三個應(yīng)用(只占用300M左右),基本可
    發(fā)表于 06-01 18:57

    edge瀏覽器識別 latex語法插件

    默認(rèn)的瀏覽器是沒有l(wèi)atex識別功能的,容易顯示為亂碼或者源碼,無法正常識別。本插件需要在瀏覽器的擴(kuò)展程序菜單下安裝,能在edge下完美運行。本插件是免費插件。
    發(fā)表于 03-17 18:03 ?1次下載

    自制 AirTag,支持安卓/鴻蒙/PC/Home Assistant,無需擁有 iPhone

    (有app),iOS/鴻蒙/PC等其他系統(tǒng)(用瀏覽器訪問web 網(wǎng)站) 查看定位標(biāo)簽的位置(下面有截圖)。 注意:雖然查看標(biāo)簽的位置不需要蘋果手機(jī),但是部署服務(wù)時需要有 AppleID 賬號(需要
    發(fā)表于 02-25 11:22

    騰訊AI To C業(yè)務(wù)大調(diào)整:QQ瀏覽器、搜狗等轉(zhuǎn)入CSIG

    騰訊內(nèi)部近期完成了一次重要的產(chǎn)品及團(tuán)隊調(diào)整,標(biāo)志著其AI To C業(yè)務(wù)戰(zhàn)略的新一輪變革。據(jù)悉,QQ瀏覽器、搜狗輸入法以及ima等多款產(chǎn)品和應(yīng)用,將正式并入CSIG(云與智慧產(chǎn)業(yè)事業(yè)群)。 此次調(diào)整
    的頭像 發(fā)表于 02-20 09:22 ?1299次閱讀

    E2000 Speedometer測試瀏覽器性能

    E2000 Speedometer****測試瀏覽器性能 Version:V1.0 日期:2024-12-5 1、瀏覽器基準(zhǔn)測試Speedometer Speedometer是一款專為Web瀏覽器
    發(fā)表于 01-10 21:33

    2024年12月瀏覽器市場份額報告:谷歌Chrome穩(wěn)居榜首

    根據(jù)市場調(diào)查機(jī)構(gòu)Statcounter最新發(fā)布的權(quán)威報告,2024年12月全球瀏覽器市場份額排行榜中,谷歌Chrome瀏覽器再次以卓越的表現(xiàn)穩(wěn)居首位。數(shù)據(jù)顯示,Chrome的市場占有率高達(dá)68.38
    的頭像 發(fā)表于 01-02 14:58 ?3194次閱讀

    鴻蒙Flutter實戰(zhàn):14-現(xiàn)有Flutter 項目支持鴻蒙 II

    分別安裝官方的3.22版本,以及鴻蒙社區(qū)的 3.22.0 版本 3.搭建 Flutter鴻蒙開發(fā)環(huán)境 參考文章《鴻蒙Flutter實戰(zhàn):0
    發(fā)表于 12-26 14:59

    訊飛星火瀏覽器插件全新升級

    時刻陪伴,星火插件讓你的瀏覽器變成真正的生產(chǎn)力工具。
    的頭像 發(fā)表于 12-25 09:48 ?1723次閱讀

    Chrome瀏覽器優(yōu)化Android性能,驍龍8至尊版表現(xiàn)突出

    谷歌近日對Chrome瀏覽器的最新版本進(jìn)行了重大更新,特別針對Android設(shè)備進(jìn)行了性能優(yōu)化,特別是對于搭載驍龍8至尊版處理的旗艦設(shè)備而言。 自Chrome M112版本以來,Android
    的頭像 發(fā)表于 12-13 14:44 ?1695次閱讀