Документация
ОС Аврора 5.1.4
Переопределение UserAgent
/*
* SPDX-FileCopyrightText: Copyright 2024 Open Mobile Platform LLC <community@omp.ru>
* SPDX-License-Identifier: Proprietary
*/
/**
* @file
* @brief Содержит пример использования переопределений пользовательского агента
*/
import QtQuick 2.0
import Sailfish.Silica 1.0
import ru.auroraos.WebView 1.0
import ru.auroraos.WebView.Global 1.0
Page {
id: page
SilicaFlickable {
anchors.fill: parent
Column {
anchors.fill: parent
spacing: Theme.paddingLarge
PageHeader {
title: "Пользовательский агент"
}
Row {
spacing: Theme.paddingLarge
Column {
spacing: Theme.paddingLarge
Button {
text: "Установить переопределение"
onClicked: {
webView.userAgent = "тестовая строка";
}
}
Button {
text: "Отключить переопределение"
onClicked: {
webView.userAgent = "";
}
}
Button {
text: "Настольный ПК"
onClicked: {
webView.formFactor = DeviceMode.DESKTOP;
}
}
Button {
text: "Телефон"
onClicked: {
webView.formFactor = DeviceMode.MOBILE;
}
}
}
Column {
spacing: Theme.paddingLarge
Button {
text: "whatismy useragent"
onClicked: {
webView.url = "https://www.whatismybrowser.com/detect/what-is-my-user-agent/";
}
}
Button {
text: "whatismy hints"
onClicked: {
webView.url = "https://www.whatismybrowser.com/detect/client-hints/";
}
}
Button {
text: "ya.ru"
onClicked: {
webView.url = "https://ya.ru";
}
}
TextSwitch {
id: uaOverrideSwitch
text: "UA override"
checked: false
}
}
}
WebItem {
id: webView
width: parent.width
height: page.height - webView.y
url: "https://www.whatismybrowser.com/detect/what-is-my-user-agent/"
userAgentOverride: uaOverrideSwitch.checked
}
}
}
}