Method and device for updating page style, equipment and storage medium
By monitoring and updating the style information of the target page in real time, the problem of CSS attribute differences is solved, ensuring the normal operation and consistent style performance of web applications on different platforms and browsers, and improving interactivity and user experience.
Patent Information
- Application Number
- CN202411102770.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-15
AI Technical Summary
In modern web development, CSS attributes differ between different platforms and browsers, affecting the normal work of web applications and making it difficult for developers to achieve consistent cross-platform style performance.
By monitoring the change of style information of the target page, determine the style object associated with the target page, and obtain the initial attribute value from the repository to compare the changed attribute value, and update the style object in real time to cope with the different platforms and browsers difference.
It realizes the normal work of web applications in different environments, improves the interactiveness and user experience of applications, and ensures more consistent style performance.
Smart Images

Figure CN118963804A_ABST
Abstract
Description
Technical Field
[0001] Example embodiments of the present disclosure generally relate to the field of computers, and more particularly, to a method, apparatus, device, and computer-readable storage medium for updating a page style. Background Art
[0002] In modern web development, developers often need to face the differences in Cascading Style Sheets (CSS) properties between different platforms and browsers. Some CSS properties may not be supported or may differ in some platforms or browsers, thus affecting the normal operation of web applications. Summary of the invention
[0003] In a first aspect of the present disclosure, a method for updating a page style is provided. The method includes: in response to a change in style information associated with a target page, determining at least one style object associated with the target page; determining a first set of attribute values of the at least one style object from a repository; and updating the at least one style object based on a comparison between the first set of attribute values and a second set of attribute values, the second set of attribute values being indicated by the changed style information.
[0004] In a second aspect of the present disclosure, a device for updating a page style is provided. The device includes: a style determination module configured to determine at least one style object associated with a target page in response to a change in style information associated with the target page; an attribute determination module configured to determine a first set of attribute values of the at least one style object from a repository; and a style update module configured to update the at least one style object based on a comparison between the first set of attribute values and a second set of attribute values, the second set of attribute values being indicated by the changed style information.
[0005] In a third aspect of the present disclosure, an electronic device is provided. The device includes at least one processing unit; and at least one memory, the at least one memory is coupled to the at least one processing unit and stores instructions for execution by the at least one processing unit. When the instructions are executed by the at least one processing unit, the device executes the method of the first aspect.
[0006] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, wherein a computer program is stored on the computer-readable storage medium, and the computer program can be executed by a processor to implement the method of the first aspect.
[0007] In a fifth aspect of the present disclosure, a computer program product is provided, which includes computer executable instructions, and when the instructions are executed by a processor, the method according to the first aspect of the present disclosure is implemented.
[0008] It should be understood that the contents described in this content section are not intended to limit the key features or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0010] Figure 1 A schematic diagram showing an example environment in which embodiments according to the present disclosure may be implemented;
[0011] Figure 2 A flowchart showing an example process of updating a page style according to some embodiments of the present disclosure;
[0012] Figure 3 A schematic diagram showing an update page style according to some embodiments of the present disclosure;
[0013] Figure 4 A schematic structural block diagram showing an example apparatus for updating a page style according to some embodiments of the present disclosure; and
[0014] Figure 5 A block diagram of an electronic device capable of implementing various embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0015] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0016] It should be noted that the titles of any sections / subsections provided herein are not restrictive. Various embodiments are described throughout this article, and any type of embodiment may be included under any section / subsection. In addition, the embodiments described in any section / subsection may be combined in any manner with any other embodiments described in the same section / subsection and / or different sections / subsections.
[0017] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may be included below. The terms "first", "second", etc. may refer to different or the same objects. Other explicit and implicit definitions may be included below.
[0018] The embodiments of the present disclosure may involve user data, data acquisition and / or use, etc. These aspects are subject to the corresponding laws, regulations and relevant provisions. In the embodiments of the present disclosure, all data collection, acquisition, processing, processing, forwarding, use, etc. are carried out on the premise that the user knows and confirms. Accordingly, when implementing each embodiment of the present disclosure, the type, scope of use, usage scenario, etc. of the data or information that may be involved should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with the relevant laws and regulations. The specific notification and / or authorization method can vary according to the actual situation and application scenario, and the scope of the present disclosure is not limited in this respect.
[0019] In this specification and the embodiments, if personal information processing is involved, it will be processed on the premise of having a legal basis (such as obtaining the consent of the subject of personal information, or it is necessary to perform a contract, etc.), and will only be processed within the scope of regulations or agreements. If a user refuses to process personal information other than the necessary information for basic functions, it will not affect the user's use of basic functions.
[0020] As mentioned above, some CSS properties may not be supported or may differ in some platforms or browsers, which requires developers to find a way to solve these problems to ensure that web applications can work properly in different environments.
[0021] The embodiment of the present disclosure proposes a scheme for updating page style. According to the scheme, in response to a change in style information associated with a target page, at least one style object associated with a target page can be determined; a first set of attribute values of the at least one style object can be determined from a repository; and based on a comparison between the first set of attribute values and a second set of attribute values, the at least one style object can be updated, the second set of attribute values being indicated by the changed style information.
[0022] In this way, the embodiments of the present disclosure can monitor the changes of style information in real time and perform corresponding processing in a timely manner. Therefore, the embodiments of the present disclosure can respond to user interaction or other dynamic changes more flexibly, improving the interactivity of the application and the user experience.
[0023] Various example implementations of the solution are described in detail below in conjunction with the accompanying drawings.
[0024] Example Environment
[0025] Figure 1 1 is a schematic diagram of an example environment 100 in which embodiments of the present disclosure can be implemented. Figure 1 As shown, example environment 100 may include electronic device 110 .
[0026] In the example environment 100, the electronic device 110 may obtain the page code 120 of the target page 130 and accordingly render the target page 130. For example, the target page 130 may include a page in a browser.
[0027] As will be described in detail below, the electronic device 110 dynamically updates the style of the target page 130 in response to the style update associated with the page code 120. The specific process of updating the style of the target page 130 will be described below. Figure 2 and Figure 3 Detailed description.
[0028] In some embodiments, the electronic device 110 can be any type of mobile terminal, fixed terminal or portable terminal, including mobile phones, desktop computers, laptop computers, notebook computers, netbook computers, tablet computers, media computers, multimedia tablets, handheld computers, portable game terminals, VR / AR devices, personal communication systems (PCS) devices, personal navigation devices, personal digital assistants (PDA), audio / video players, digital cameras / camcorders, positioning devices, television receivers, radio broadcast receivers, e-book devices, game devices, or any combination of the foregoing, including accessories and peripherals of these devices or any combination thereof. In some embodiments, the electronic device 110 can also support any type of interface for the user (such as "wearable" circuits, etc.).
[0029] In some embodiments, the electronic device 110 may also be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud code units, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks, and big data and artificial intelligence platforms. The electronic device 110 may include, for example, a computing system / server, such as a mainframe, an edge computing node, a computing device in a cloud environment, and the like.
[0030] It should be understood that the structure and function of the various elements in the environment 100 are described for exemplary purposes only and do not imply any limitation on the scope of the present disclosure.
[0031] Some example embodiments of the present disclosure will be described below with continued reference to the accompanying drawings.
[0032] Example Process
[0033] Figure 2 FIG. 2 is a flowchart showing an example process 200 for updating a page style according to some embodiments of the present disclosure. The process 200 may be implemented at the electronic device 110. Figure 1 Process 200 is described.
[0034] In block 210, the electronic device 110 determines at least one style object associated with the target page in response to a change in the style information associated with the target page. In the present disclosure, a style object refers to a collection of style attributes associated with a page element. These style attributes define how the element is displayed on the page, including but not limited to color, size, layout, font, etc. In Web development, a style object is usually associated with a style attribute of an HTML element or a CSS selector. Taking HTML (HyperText Markup Language) as an example, a style object can be, for example, <style>标签来定义。
[0035] 以下将参考图3来描述过程200。图3示出了根据本公开的一些实施例的更新页面样式的示意图300。
[0036] 在一些实施例中,如图3所示,电子设备110可以通过两种方式来确定样式信息发生变化。样式信息可以表示与目标页面有关的样式对象的一项或多项属性的值。例如,样式信息可以通过CSS(层叠样式表)文件来表示。当某个CSS属性的值发生变化时,样式信息可以被确定发生变化。
[0037] 在一些实施例中,在框305,电子设备110可以侦听目标页面130中的页面元素(例如,HTML元素)的属性或类别发生变化。进一步地,在框310,电子设备110可以对所有注册了侦听的样式对象(也可以简称为样式)进行遍历,以确定侦听该页面元素的属性或类别的至少一个样式对象。
[0038] 在一些场景中,电子设备110可以响应于CSS属性或类别的变化,而对全部注册侦听的样式对象进行遍历。
[0039] 备选地,一些样式对象可以侦听特定属性或类别的改变,并仅在特定属性或类别发生变化时,来触发对应的侦听器。例如,通过下述示例代码,可以注册针对CSS属性"--lynx-display”属性的侦听器。
[0040]
[0041] 在一些实施例中,电子设备110可以检测目标页面130的文档对象模型(DocumentObject Model,DOM)的变化,确定目标页面130中的页面元素的属性或类别发生变化。
[0042] 在另一些实施例中,如图3所示,在框315,电子设备110还可以接收利用浏览器所支持的代理模块(proxy)来修改目标样式对象的目标样式属性的修改请求。
[0043] 例如,在框320,用户代码可以调用style.setProperty来给特定样式对象的特定属性赋值。或者,用户代码可以直接给style.[someproperty]赋值。
[0044] 相应地,在框325,电子设备110可以确定待修改的目标样式属性;在框330,电子设备110可以将修改请求所指示的目标样式对象确定为至少一个样式对象。
[0045] 在框220,电子设备110从存储库中确定至少一个样式对象的第一组属性值。
[0046] 继续参考图3,存储库340例如可以存储全部侦听者(例如,注册侦听的样式对象)的样式属性(例如,CSS属性)的值,也即,第一组属性值。
[0047] 在框230,电子设备110基于第一组属性值与第二组属性值的比较,更新至少一个样式对象,第二组属性值由经变化的样式信息所指示。
[0048] 继续参考图3,在框335,电子设备110可以将存储库340中的第一组属性值与通过侦听确定的第二组属性值进行比较。或者,电子设备110可以将第一组属性值与通过代理模块所赋值的第二组属性值进行比较。
[0049] 在框345,电子设备110可以确定第一组属性值是否与第二组属性值存在不同。如果存在不同,则电子设备110可以在框350基于第二组属性值来更新存储库340,以存储被更新的样式属性的最新值。
[0050] 进一步地,在框355,电子设备110还可以确定至少一个样式对象被应用的至少一项属性值被更新。作为示例,样式对象的一些属性值可能被会影响目标页面的渲染结果,例如,可能被其他样式对象覆盖等。
[0051] 如果确定某个样式对象被应用的属性值被更新,则电子设备110可以基于被应用的改属性的更新值来更新目标页面130。
[0052] 以此方式,本公开的实施例能够实时监测样式信息的变化,并及时执行相应的处理。由此,本公开的实施例能够更加灵活地响应用户交互或其他动态变化,提高了应用的交互性和用户体验。
[0053] 在一些场景中,一些平台(诸如,特定浏览器)可能不支持解析未按照预设标准所撰写的代码。在一些实施例中,为了提高跨平台的适用性,在目标页面的页面代码的编译过程中,电子设备110还可以将页面代码中不满足预设标准的第一代码内容转换为满足预设标准的第二代码内容。
[0054] 在一些实施例中,页面代码包括以层叠样式表(Cascading Style Sheets,CSS)编写的代码部分。
[0055] 例如,在跨平台场景中,一些CSS属性例如可以被编写为:
[0056]
[0057] 然而,一些浏览器可能不支持对于非标准的CSS属性的解析。例如,"display”是一个非标准的CSS属性。相应地,在页面代码的编译过程中,电子设备110可以将非标准的CSS属性转换为满足预设标准的CSS(例如,W3C标准)属性:
[0058]
[0059] 也即,非标准的CSS属性"display”被转换为了符合W3C标准的CSS属性"--lynx-display”。
[0060] 由此,通过将非标准的CSS属性转换为CSS变量,本公开的实施例能够允许开发者在不同的平台和浏览器上实现更一致的样式表现,解决了不同平台间CSS属性差异的问题。
[0061] 示例装置和设备
[0062] 本公开的实施例还提供了用于实现上述方法或过程的相应装置。图4示出了根据本公开的某些实施例的用于更新页面样式的示例装置400的示意性结构框图。装置400可以被实现为或者被包括在电子设备110中。装置400中的各个模块 / 组件可以由硬件、软件、固件或者它们的任意组合来实现。
[0063] 如图4所示,装置400包括样式确定模块410,被配置为响应于与目标页面相关联的样式信息发生变化,确定与目标页面相关联的至少一个样式对象;属性确定模块420,被配置为从存储库中确定至少一个样式对象的第一组属性值;以及样式更新模块430,被配置为基于第一组属性值与第二组属性值的比较,更新至少一个样式对象,第二组属性值由经变化的样式信息所指示。
[0064] 在一些实施例中,样式确定模块410,还被配置为检测目标页面中的页面元素的属性或类别发生变化;以及确定侦听属性或类别的至少一个样式对象。
[0065] 在一些实施例中,样式确定模块410,还被配置为基于与目标页面相关联的文档对象模型的变化,确定目标页面中的页面元素的属性或类别发生变化。
[0066] 在一些实施例中,样式确定模块410,还被配置为接收利用代理模块来修改目标样式对象的目标样式属性的修改请求;以及将目标样式对象确定为至少一个样式对象。
[0067] 在一些实施例中,装置400还包括页面更新模块,被配置为响应于至少一个样式对象被应用的至少一项属性的值被更新,基于至少一项属性的更新值,更新目标页面。
[0068] 在一些实施例中,装置400还包括数据更新模块,被配置为更新存储库中所储存的第一组属性值。
[0069] 在一些实施例中,装置400还包括内容转换模块,被配置为在目标页面的页面代码的编译过程中,将页面代码中不满足预设标准的第一代码内容转换为满足预设标准的第二代码内容。
[0070] 在一些实施例中,页面代码包括以层叠样式表CSS编写的代码部分。
[0071] 装置400中所包括的模块可以利用各种方式来实现,包括软件、硬件、固件或其任意组合。在一些实施例中,一个或多个单元可以使用软件和 / 或固件来实现,例如存储在存储介质上的机器可执行指令。除了机器可执行指令之外或者作为替代,装置400中的部分或者全部模块可以至少部分地由一个或多个硬件逻辑组件来实现。作为示例而非限制,可以使用的示范类型的硬件逻辑组件包括现场可编程门阵列(FPGA)、专用集成电路(ASIC)、专用标准品(ASSP)、片上系统(SOC)、复杂可编程逻辑器件(CPLD),等等。
[0072] 图5示出了其中可以实施本公开的一个或多个实施例的电子设备500的框图。应当理解,图5所示出的电子设备500仅仅是示例性地,而不应当构成对本文所描述的实施例的功能和范围的任何限制。图5所示出的电子设备500可以用于实现图1的电子设备110。
[0073] 如图5所示,电子设备500是通用电子设备的形式。电子设备500的组件可以包括但不限于一个或多个处理器或处理单元510、存储器520、存储设备530、一个或多个通信单元540、一个或多个输入设备550以及一个或多个输出设备560。处理单元510可以是实际或虚拟处理器并且能够根据存储器520中存储的程序来执行各种处理。在多处理器系统中,多个处理单元并行执行计算机可执行指令,以提高电子设备500的并行处理能力。
[0074] 电子设备500通常包括多个计算机存储介质。这样的介质可以是电子设备500可访问的任何可以获取的介质,包括但不限于易失性和非易失性介质、可拆卸和不可拆卸介质。存储器520可以是易失性存储器(例如寄存器、高速缓存、随机访问存储器(RAM))、非易失性存储器(例如,只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、闪存)或它们的某种组合。存储设备530可以是可拆卸或不可拆卸的介质,并且可以包括机器可读介质,诸如闪存驱动、磁盘或者任何其他介质,其可以能够用于存储信息和 / 或数据并且可以在电子设备500内被访问。
[0075] 电子设备500可以进一步包括另外的可拆卸 / 不可拆卸、易失性 / 非易失性存储介质。尽管未在图5中示出,可以提供用于从可拆卸、非易失性磁盘(例如"软盘”)进行读取或写入的磁盘驱动和用于从可拆卸、非易失性光盘进行读取或写入的光盘驱动。在这些情况中,每个驱动可以由一个或多个数据介质接口被连接至总线(未示出)。存储器520可以包括计算机程序产品525,其具有一个或多个程序模块,这些程序模块被配置为执行本公开的各种实施例的各种方法或动作。
[0076] 通信单元540实现通过通信介质与其他电子设备进行通信。附加地,电子设备500的组件的功能可以以单个计算集群或多个计算机器来实现,这些计算机器能够通过通信连接进行通信。因此,电子设备500可以使用与一个或多个其他服务器、网络个人计算机(PC)或者另一个网络节点的逻辑连接来在联网环境中进行操作。
[0077] 输入设备550可以是一个或多个输入设备,例如鼠标、键盘、追踪球等。输出设备560可以是一个或多个输出设备,例如显示器、扬声器、打印机等。电子设备500还可以根据需要通过通信单元540与一个或多个外部设备(未示出)进行通信,外部设备诸如存储设备、显示设备等,与一个或多个使得用户与电子设备500交互的设备进行通信,或者与使得电子设备500与一个或多个其他电子设备通信的任何设备(例如,网卡、调制解调器等)进行通信。这样的通信可以经由输入 / 输出(I / O)接口(未示出)来执行。
[0078] 根据本公开的示例性实现方式,提供了一种计算机可读存储介质,其上存储有计算机可执行指令,其中计算机可执行指令被处理器执行以实现上文描述的方法。根据本公开的示例性实现方式,还提供了一种计算机程序产品,计算机程序产品被有形地存储在非瞬态计算机可读介质上并且包括计算机可执行指令,而计算机可执行指令被处理器执行以实现上文描述的方法。
[0079] 这里参照根据本公开实现的方法、装置、设备和计算机程序产品的流程图和 / 或框图描述了本公开的各个方面。应当理解,流程图和 / 或框图的每个方框以及流程图和 / 或框图中各方框的组合,都可以由计算机可读程序指令实现。
[0080] 这些计算机可读程序指令可以提供给通用计算机、专用计算机或其他可编程数据处理装置的处理单元,从而生产出一种机器,使得这些指令在通过计算机或其他可编程数据处理装置的处理单元执行时,产生了实现流程图和 / 或框图中的一个或多个方框中规定的功能 / 动作的装置。也可以把这些计算机可读程序指令存储在计算机可读存储介质中,这些指令使得计算机、可编程数据处理装置和 / 或其他设备以特定方式工作,从而,存储有指令的计算机可读介质则包括一个制造品,其包括实现流程图和 / 或框图中的一个或多个方框中规定的功能 / 动作的各个方面的指令。
[0081] 可以把计算机可读程序指令加载到计算机、其他可编程数据处理装置、或其他设备上,使得在计算机、其他可编程数据处理装置或其他设备上执行一系列操作步骤,以产生计算机实现的过程,从而使得在计算机、其他可编程数据处理装置、或其他设备上执行的指令实现流程图和 / 或框图中的一个或多个方框中规定的功能 / 动作。
[0082] 附图中的流程图和框图显示了根据本公开的多个实现的系统、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段或指令的一部分,模块、程序段或指令的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个连续的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图和 / 或流程图中的每个方框、以及框图和 / 或流程图中的方框的组合,可以用执行规定的功能或动作的专用的基于硬件的系统来实现,或者可以用专用硬件与计算机指令的组合来实现。
[0083] 以上已经描述了本公开的各实现,上述说明是示例性地,并非穷尽性的,并且也不限于所公开的各实现。在不偏离所说明的各实现的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。本文中所用术语的选择,旨在最好地解释各实现的原理、实际应用或对市场中的技术的改进,或者使本技术领域的其他普通技术人员能理解本文公开的各个实现方式。< / style>
Claims
1. A method for updating a page style, comprising: In response to a change in style information associated with a target page, determining at least one style object associated with the target page; determining a first set of property values for the at least one style object from a repository; as well as The at least one style object is updated based on a comparison of the first set of property values with a second set of property values, the second set of property values being indicated by the changed style information.
2. The method according to claim 1, wherein determining at least one style object associated with the target page in response to a change in style information associated with the target page comprises: Detecting changes in attributes or categories of page elements in the target page; as well as The at least one style object listening to the property or the category is determined.
3. The method according to claim 2, wherein detecting a change in an attribute or category of a page element in the target page comprises: Based on a change in a document object model associated with the target page, it is determined that an attribute of the page element or the category in the target page has changed.
4. The method according to claim 1, wherein determining at least one style object associated with the target page in response to a change in style information associated with the target page comprises: receiving a modification request for modifying a target style attribute of a target style object by using a proxy module; as well as The target style object is determined to be the at least one style object.
5. The method according to claim 1, further comprising: In response to the value of at least one attribute to which the at least one style object is applied being updated, the target page is updated based on the updated value of the at least one attribute.
6. The method according to claim 1, further comprising: The first set of attribute values stored in the repository is updated.
7. The method according to claim 1, further comprising: During the compilation of the page code of the target page, first code content in the page code that does not meet a preset standard is converted into second code content that meets the preset standard.
8. The method according to claim 7, wherein the page code includes a code portion written in Cascading Style Sheets (CSS).
9. A device for updating a page style, comprising: a style determination module, configured to determine at least one style object associated with a target page in response to a change in style information associated with the target page; an attribute determination module configured to determine a first set of attribute values of the at least one style object from a repository; as well as The style update module is configured to update the at least one style object based on a comparison between the first set of property values and a second set of property values indicated by the changed style information.
10. An electronic device, comprising: at least one processing unit; as well as At least one memory, the at least one memory being coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions causing the electronic device to perform the method according to any one of claims 1 to 8 when executed by the at least one processing unit.
11. A computer-readable storage medium having a computer program stored thereon, wherein the computer program can be executed by a processor to implement the method according to any one of claims 1 to 8.
12. A computer program product comprising computer executable instructions, wherein the computer executable instructions, when executed by a processor, implement the method according to any one of claims 1 to 8.
