欧美性猛交xxxx免费看_牛牛在线视频国产免费_天堂草原电视剧在线观看免费_国产粉嫩高清在线观看_国产欧美日本亚洲精品一5区

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

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(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)頁(yè),根據(jù)頁(yè)面歷史棧前進(jìn)回退等。

效果預(yù)覽

image.png

使用說明:

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

工程目錄

entry/src/main/ets/
|---Application
|   |---AbilityStage.ets                        // 入口
|---pages
|   |---Index.ets                               // 首頁(yè)
|---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: '頁(yè)簽數(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)頁(yè)及刷新:使用WebController提供的loadUrl可以加載目標(biāo)網(wǎng)址內(nèi)容,使用refresh方法刷新頁(yè)面;
-   頁(yè)面前進(jìn)后退功能:頁(yè)面在前進(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,版本號(hào):3.2.11.9。
  4. 本示例不支持點(diǎn)擊tab頁(yè)簽,切換網(wǎng)頁(yè)并刷新頁(yè)面;
  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)立場(chǎng)。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 瀏覽器
    +關(guān)注

    關(guān)注

    1

    文章

    1036

    瀏覽量

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

    關(guān)注

    57

    文章

    2394

    瀏覽量

    43084
收藏 人收藏

    評(píng)論

    相關(guān)推薦

    E2000 Speedometer測(cè)試瀏覽器性能

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

    訊飛星火瀏覽器插件全新升級(jí)

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

    OpenAI醞釀創(chuàng)新:計(jì)劃開發(fā)集成聊天機(jī)器人的瀏覽器

    近日,人工智能領(lǐng)域的佼佼者OpenAI正醞釀著一項(xiàng)可能改變瀏覽器行業(yè)格局的重大創(chuàng)新——開發(fā)一款能夠與其聊天機(jī)器人無縫結(jié)合的網(wǎng)絡(luò)瀏覽器。 據(jù)知情人士透露,OpenAI已與多家知名網(wǎng)站和應(yīng)用程序
    的頭像 發(fā)表于 11-22 11:06 ?465次閱讀

    AWTK 最新動(dòng)態(tài):支持瀏覽器控件

    導(dǎo)讀AWTK瀏覽器控件,基于webview項(xiàng)目實(shí)現(xiàn),將瀏覽器嵌入到AWTK應(yīng)用程序中,讓開發(fā)者可以方便的集成在線幫助和調(diào)用地圖等功能。awtk-widget-web-view是基于webview實(shí)現(xiàn)的AWTK
    的頭像 發(fā)表于 11-20 01:05 ?283次閱讀
    AWTK 最新動(dòng)態(tài):支持<b class='flag-5'>瀏覽器</b>控件

    寫一個(gè)Chrome瀏覽器插件

    、瀏覽器插件有哪些種類 ?以chromium為內(nèi)核的瀏覽器插件如Chrome ??firefox瀏覽器插件 ???safari瀏覽器插件 本文只介紹Chrome插件的原生
    的頭像 發(fā)表于 11-18 17:12 ?516次閱讀
    寫一個(gè)Chrome<b class='flag-5'>瀏覽器</b>插件

    鴻蒙Flutter實(shí)戰(zhàn):07混合開發(fā)

    # 鴻蒙Flutter實(shí)戰(zhàn):混合開發(fā) 鴻蒙Flutter混合開發(fā)主要有兩種形式。 ## 1.基于har 將flutter module
    發(fā)表于 10-23 16:00

    跨域問題是由瀏覽器的同源策略造成的

    瀏覽器
    jf_62215197
    發(fā)布于 :2024年08月27日 07:51:42

    不只是前端,后端、產(chǎn)品和測(cè)試也需要了解的瀏覽器知識(shí)(二)

    繼上篇《 不只是前端,后端、產(chǎn)品和測(cè)試也需要了解的瀏覽器知識(shí)(一)》介紹了瀏覽器的基本情況、發(fā)展歷史以及市場(chǎng)占有率。 本篇文章將介紹瀏覽器基本原理。 在掌握基本原理后,通過技術(shù)深入,在研發(fā)
    的頭像 發(fā)表于 08-12 14:32 ?402次閱讀
    不只是前端,后端、產(chǎn)品和測(cè)試也需要了解的<b class='flag-5'>瀏覽器</b>知識(shí)(二)

    不只是前端,后端、產(chǎn)品和測(cè)試也需要了解的瀏覽器知識(shí)

    一、我們?yōu)槭裁匆私?b class='flag-5'>瀏覽器? 1. 對(duì)于前端開發(fā)者 1.瀏覽器是用戶體驗(yàn)的第一線。我們需要了解瀏覽器的工作原理,才能有效地設(shè)計(jì)和實(shí)現(xiàn)用戶界面,確保良好的用戶體驗(yàn)。 2.好的產(chǎn)品需要考慮
    的頭像 發(fā)表于 07-01 18:03 ?521次閱讀
    不只是前端,后端、產(chǎn)品和測(cè)試也需要了解的<b class='flag-5'>瀏覽器</b>知識(shí)

    Opera瀏覽器引領(lǐng)潮流,全球首接端側(cè)AI大模型

    昆侖萬維旗下海外平臺(tái)Opera宣布,其旗艦瀏覽器Opera One和游戲瀏覽器Opera GX將正式接入端側(cè)AI大模型,成為全球首個(gè)實(shí)現(xiàn)這一突破的主流瀏覽器。
    的頭像 發(fā)表于 06-03 09:18 ?803次閱讀

    Edge瀏覽器關(guān)閉Microsoft Rewards擴(kuò)展原因揭曉

    據(jù)報(bào)道,近期德國(guó)等地的Microsoft Edge瀏覽器用戶發(fā)現(xiàn),安裝或啟動(dòng)Microsoft Rewards擴(kuò)展后,會(huì)出現(xiàn)“右上角擴(kuò)展被Edge瀏覽器禁用以保障您的瀏覽器安全”的提醒窗口。
    的頭像 發(fā)表于 04-10 09:55 ?935次閱讀

    Mozilla Firefox瀏覽器推出Text Fragments功能,提升用戶體驗(yàn)

    早在2020年,谷歌即在Chrome瀏覽器中推出了“Scroll to Text Fragments”功能,而Edge、Opera、Brave、Vivaldi以及蘋果Safari等基于Chromium的瀏覽器也已支持這一便捷特性。
    的頭像 發(fā)表于 04-08 10:21 ?683次閱讀

    鴻蒙開發(fā)實(shí)戰(zhàn):網(wǎng)絡(luò)請(qǐng)求庫(kù)【axios】

    [Axios]?,是一個(gè)基于 promise 的網(wǎng)絡(luò)請(qǐng)求庫(kù),可以運(yùn)行 node.js 和瀏覽器中。本庫(kù)基于[Axios]原庫(kù)v1.3.4版本進(jìn)行適配,使其可以運(yùn)行在 OpenHarmony,并沿用其現(xiàn)有用法和特性。
    的頭像 發(fā)表于 03-25 16:47 ?4054次閱讀
    <b class='flag-5'>鴻蒙</b><b class='flag-5'>開發(fā)</b><b class='flag-5'>實(shí)戰(zhàn)</b>:網(wǎng)絡(luò)請(qǐng)求庫(kù)【axios】

    Windows 11預(yù)覽版安裝受阻,微軟提示更新設(shè)備或瀏覽器

    該提示翻譯如下:由于安全性考慮,您的設(shè)備或瀏覽器未能順利連接至認(rèn)證服務(wù)。若您確非惡意行為者,請(qǐng)嘗試更新相關(guān)設(shè)備或瀏覽器,以獲取完整使用體驗(yàn)。
    的頭像 發(fā)表于 03-05 14:29 ?1117次閱讀

    鴻蒙實(shí)戰(zhàn)項(xiàng)目開發(fā):【短信服務(wù)】

    、OpenHarmony 多媒體技術(shù)、Napi組件、OpenHarmony內(nèi)核、Harmony南向開發(fā)鴻蒙項(xiàng)目實(shí)戰(zhàn)等等)鴻蒙(Harmony NEXT) 技術(shù)知識(shí)點(diǎn) 如果你是一名An
    發(fā)表于 03-03 21:29