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)不再提示

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

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

掃碼添加小助手

加入工程師交流群

瀏覽器

介紹

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

效果預(yù)覽

image.png

使用說明:

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

工程目錄

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

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

下載

如需單獨(dú)下載本工程,執(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)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報(bào)投訴
  • 瀏覽器
    +關(guān)注

    關(guān)注

    1

    文章

    1043

    瀏覽量

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

    關(guān)注

    60

    文章

    2961

    瀏覽量

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

掃碼添加小助手

加入工程師交流群

    評論

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

    無需安裝!在瀏覽器里就能玩轉(zhuǎn)ESP32/ESP8266,這個(gè)神器絕了!

    使用教程)ESP32-運(yùn)行網(wǎng)頁服務(wù)(WebServer)-實(shí)用篇介紹扔掉繁瑣的桌面軟件,一個(gè)瀏覽器搞定所有ESP開發(fā)調(diào)試需求溫馨提示私信:ESPConnect即可獲取
    的頭像 發(fā)表于 01-10 10:01 ?796次閱讀
    無需安裝!在<b class='flag-5'>瀏覽器</b>里就能玩轉(zhuǎn)ESP32/ESP8266,這個(gè)神器絕了!

    M4-R1 開源鴻蒙(OpenHarmory)開發(fā)板丨串口調(diào)試助手實(shí)戰(zhàn)案例

    支持與高集成度設(shè)計(jì),成為開發(fā)者體驗(yàn)與學(xué)習(xí)鴻蒙系統(tǒng)的理想平臺。無論是智慧家居、教學(xué)實(shí)驗(yàn),還是設(shè)備通信,M4-R1都能提供穩(wěn)定可靠的開發(fā)環(huán)境。本次分享的實(shí)戰(zhàn)案例——串口
    的頭像 發(fā)表于 12-31 11:16 ?8520次閱讀
    M4-R1 開源<b class='flag-5'>鴻蒙</b>(OpenHarmory)<b class='flag-5'>開發(fā)</b>板丨串口調(diào)試助手<b class='flag-5'>實(shí)戰(zhàn)</b>案例

    鴻蒙手機(jī)系統(tǒng)6.0用瀏覽器看視頻,視頻顯示不能橫屏。怎么設(shè)置?

    鴻蒙手機(jī)系統(tǒng)6.0用瀏覽器看視頻,視頻顯示不能橫屏。怎么設(shè)置? 如何掂讓這個(gè)豎屏切換為橫屏?
    發(fā)表于 12-20 20:10

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

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

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

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

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

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

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

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

    鴻蒙5開發(fā)寶藏案例分享---性能體驗(yàn)設(shè)計(jì)

    ;性能優(yōu)化\"關(guān)鍵詞! **如果大家在實(shí)戰(zhàn)中遇到卡頓難題,歡迎在評論區(qū)交流~ 也歡迎關(guān)注我,后續(xù)會持續(xù)分享鴻蒙開發(fā)實(shí)戰(zhàn)技巧! **? 希望這篇接地氣的總結(jié)能幫你避開性能深坑!如果覺得有
    發(fā)表于 06-12 16:45

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

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

    鴻蒙5開發(fā)寶藏案例分享---切面編程實(shí)戰(zhàn)揭秘

    鴻蒙切面編程(AOP)實(shí)戰(zhàn)指南:隱藏的寶藏功能大揭秘! 大家好!今天在翻鴻蒙開發(fā)者文檔時(shí),意外發(fā)現(xiàn)了官方埋藏的「切面編程」寶藏案例!實(shí)際開發(fā)
    發(fā)表于 06-12 16:21

    鴻蒙5開發(fā)寶藏案例分享---應(yīng)用架構(gòu)實(shí)戰(zhàn)技巧

    大家好! 今天咱們聊聊鴻蒙開發(fā)中那些“官方文檔提了但實(shí)際開發(fā)難找”的架構(gòu)設(shè)計(jì)技巧。結(jié)合官方文檔,我會用 真實(shí)代碼案例+通俗講解 ,幫你把分層架構(gòu)和線程通信落地到項(xiàng)目里,告別“理論會了,代碼不會
    發(fā)表于 06-12 16:14

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

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

    老電視如何安裝瀏覽器

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

    看點(diǎn):華為首款鴻蒙電腦正式亮相 蘋果探索在瀏覽器中加入AI搜索功能

    給大家?guī)硪恍┬袠I(yè)資訊: 華為首款鴻蒙電腦正式亮相 ?5月8日在鴻蒙電腦技術(shù)與生態(tài)溝通會上華為首款鴻蒙電腦正式亮相。同時(shí)華為智慧辦公將升級為鴻蒙辦公。
    的頭像 發(fā)表于 05-08 11:15 ?885次閱讀

    edge瀏覽器識別 latex語法插件

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