WO2018176207A1 - Web主题切换方法及系统 - Google Patents

Web主题切换方法及系统 Download PDF

Info

Publication number
WO2018176207A1
WO2018176207A1 PCT/CN2017/078370 CN2017078370W WO2018176207A1 WO 2018176207 A1 WO2018176207 A1 WO 2018176207A1 CN 2017078370 W CN2017078370 W CN 2017078370W WO 2018176207 A1 WO2018176207 A1 WO 2018176207A1
Authority
WO
WIPO (PCT)
Prior art keywords
background image
theme
file
switching
image
Prior art date
Application number
PCT/CN2017/078370
Other languages
English (en)
French (fr)
Inventor
孙艳峥
王佳
费晓家
Original Assignee
深圳中兴力维技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳中兴力维技术有限公司 filed Critical 深圳中兴力维技术有限公司
Priority to PCT/CN2017/078370 priority Critical patent/WO2018176207A1/zh
Publication of WO2018176207A1 publication Critical patent/WO2018176207A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs

Definitions

  • the present invention relates to the field of Internet technologies, and in particular, to a Web theme switching method and system.
  • the current methods for theme switching are as follows: 1. Design two or more interfaces, and complete the theme switching function by pointing to different interface files, which is equivalent to bursting two sets of systems, all interface designs and style libraries are Not shared, the advantage is that the interface design is rich, operability is strong, and the degree of freedom is high. However, it takes more manpower and time to send more than two sets of system interfaces. For general portals, the theme switching often does not change much. Only individual logos, pictures, and colors need to be switched, so there is no need to send two sets.
  • an object of the present invention is to provide a web theme switching method and system, which solves the problem in the prior art that a plurality of sets of systems or multiple CSS files need to be repeatedly transmitted to implement main body switching. A lot of duplication of work and frequent web requests.
  • a web theme switching method including:
  • the value of the background image positioning attribute is dynamically changed by the JS file to switch the corresponding content in the background image.
  • the step of synthesizing the image material required for the theme switching to obtain the background image comprises: [0011] combining several image materials into one background image according to a preset synthesis rule.
  • the background image localization attribute is calculated according to a preset synthesis rule.
  • the step of dynamically changing the value of the background image positioning attribute by using the JS file to switch the corresponding content in the background image includes:
  • the value of the background image localization attribute is dynamically changed according to the theme type to switch to the corresponding content in the background image.
  • the step of dynamically changing the value of the background image positioning attribute by using the JS file to switch the corresponding content in the background image after the theme switching includes:
  • the value of the background image localization attribute is dynamically changed by the JS file.
  • a web theme switching system including:
  • a background image synthesizing unit configured to synthesize image materials required for theme switching to obtain a background image
  • a public file importing unit configured to introduce a public CSS file and a JS file in a webpage, add a background image positioning attribute in a common CSS file, and a theme switching unit, configured to switch between themes and the dynamics of the JS file. Change the value of the background image positioning property to switch the corresponding content in the background image
  • the background image synthesizing unit is specifically configured to:
  • the background image synthesizing unit is further configured to:
  • the theme switching unit includes:
  • a writing unit configured to write the selected topic type to the cookie
  • a reading unit configured to read a topic type in the cookie through the JS file after loading the page
  • a switching subunit configured to dynamically change the value of the background image positioning attribute according to the theme type, to switch to The corresponding content in the background image.
  • the theme switching unit further includes:
  • the first switching unit is configured to dynamically change the value of the background image positioning attribute through the JS file by acquiring the current geographic location.
  • the web theme switching method and system according to the embodiment of the present invention can realize mutual switching between multiple theme types by using a CSS file by synthesizing the image material into a background image and using the background image positioning method. Avoid topic switching, introduce duplicate files, simplify burst mode, save bursts
  • Reduce web server publishing duplicate resources, reduce frequent file requests, and implement no-refresh theme switching to improve user experience.
  • FIG. 1 is a flowchart of a method for switching a Web topic according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of three topic type switching effects according to an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of background images of three subject types according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of a Web theme switching system according to an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of a topic switching unit according to an embodiment of the present invention.
  • FIG. 1 is a flowchart of a method for switching a Web topic according to an embodiment of the present invention, where the method includes the following steps:
  • a plurality of image materials are used to synthesize the image materials to obtain a background image.
  • three theme types need to be provided to the user for theme switching.
  • three images are collected as image materials, and the three image materials are combined to obtain a background image, which includes the above three images.
  • the content of the image material Since different theme types differ only in a small part of the image material, these different image materials in each theme type are extracted, and a background image is synthesized to avoid referring to duplicate files, thereby reducing the workload of the hairpin, only Process the difference image material.
  • the preset composition rule is defined as: combining the image materials in the horizontal direction, or sequentially arranging the image materials in the vertical direction.
  • the image materials are arranged in the horizontal direction, and the height of each image material is the same.
  • the width of each image material is the width of the background image/the number of image materials.
  • the image materials are arranged in the vertical direction, and the width of each image material is the same.
  • the height of each image material is the height of the background image / the number of image materials.
  • the background image localization attribute is calculated according to a preset synthesis rule. After combining several image materials into one background image, several image materials may be sequentially numbered to obtain an image number, and according to a preset synthesis rule, the position of each image material in the background image, that is, the background image, may be calculated. Positioning attributes, each image number has a value of a corresponding background image positioning attribute, and the value of the background image positioning attribute may be a pixel value or a percentage value, and the image material to be used may be selected, according to the image number , get the value of the corresponding background image positioning property.
  • the background image positioning properties can be quickly calculated to achieve accurate positioning and fast switching of the background image.
  • the pixel value and the percentage value can be converted to each other, and the conversion formula is:
  • x ⁇ width of the container - the width of the background image ⁇ * x percentage
  • y ⁇ the height of the container - the height of the background image ⁇ * y percentage.
  • the width of the background image is W
  • the number of subject types is N
  • the width of the label container is W/N
  • the value of the horizontal offset pixel is X
  • the percentage value is P, horizontally biased.
  • the relationship between the shifted pixel value X and the percentage value P is:
  • the attributes including ba ckground-image, width, and height are set, and the url of the background-image attribute is set as the background image, if included
  • the image material is arranged in landscape orientation, the width is set to 1/3 of the width of the background image, and height is the height of the background image.
  • the class attribute of the tag plus the background image positioning is 1 ⁇ 2background-position: x, y, that is, the setting of the starting position of the background image of the tag is completed.
  • the default value of background-position:x,y property is ⁇ , ⁇ , the first parameter is the horizontal position, and the second parameter is the vertical position.
  • the background image only needs to be positioned in the horizontal direction. Since it only needs to set the background-position-x to be a thousand, the background-position-y is not required to be set.
  • the default is 0 ⁇ 3 ⁇ 4. , equivalent to background-positio x ⁇ Oy ⁇
  • the value of the background image localization attribute is dynamically changed by the JS file to switch the corresponding content in the background image.
  • the dynamic script script theme.js is used to read the saved topic type in the cookie, and the value of the background-position:x,y attribute is dynamically changed, for example, there are three topic types.
  • the theme is Theme 1, Theme 2, Theme 3, the width of the background image is w, and the image material is ⁇ 1 J in the horizontal direction. Just change the background-position:x values to 0, -(w/3)px , -(w/3*2)px, so that you can achieve one-step operation and complete the theme style switching.
  • the invention can complete the theme switching through a background image, a C SS file, a JS file, simplify the directory structure, reduce duplicate CSS files, repeatedly introduce images, and reduce unnecessary http requests caused by theme switching, and reduce page bursts. Workload, and achieve efficient, non-refreshing topic switching to enhance the user experience.
  • the selected theme type is written into the cookie; after loading the page, the theme type in the cooki e is read through the JS file; the value of the background image positioning attribute is dynamically changed according to the theme type to switch to the background image Corresponding content.
  • the value of the background image localization attribute is dynamically changed by the JS file.
  • you can dynamically switch the corresponding topic type For example, in Fujian Bagua, the Fujian feature is presented to the Xinjiang Uygur. The ethnic area switches to a local custom theme.
  • the theme can be switched, the weather temperature value is obtained, and the corresponding topic type is dynamically switched according to the weather temperature value, for example, the snow theme is presented when the ambient temperature is zero, and the scalability of the theme switching is enhanced.
  • the background image positioning method is adopted, and a CSS file can be used to switch between multiple theme types, thereby avoiding theme switching.
  • Introducing duplicate files simplifying burst mode, saving bursts, reducing duplication of resources published by web servers, reducing frequent file requests, enabling non-refresh topic switching, and improving user experience.
  • FIG. 2 is a schematic diagram showing three theme type switching effects according to an embodiment of the present invention, which are three theme types set according to characteristics of three countries: China, the United States, and Africa, and FIG. 3 shows an implementation of the present invention.
  • the specific application is in the control icon switch, and similarly, the image material of the control icon is merged into a background image, and the background image is placed into the image of the web program related style module.
  • the user-set theme is recorded in the browser cookie.
  • the theme.js is used to dynamically change the background-position property to set the starting position of the background image, and all the pages can be completed. Control icon switching function.
  • FIG. 4 is a schematic diagram of a Web theme switching system according to an embodiment of the present invention. For ease of description, only parts related to the embodiment of the present invention are shown, which are as follows:
  • a web theme switching system includes: a background image synthesizing unit 41, a public file importing unit 42 and a theme switching unit 43, wherein:
  • the background image synthesizing unit 41 is configured to synthesize the image material required for the theme switching to obtain a background image.
  • a plurality of image materials are used to synthesize the image materials to obtain a background image.
  • three theme types need to be provided to the user for theme switching.
  • three images are collected as image materials, and the three image materials are combined to obtain a background image, which includes the above three images.
  • the content of the image material Since different theme types differ only in a small part of the image material, these different image materials in each theme type are extracted, and a background image is synthesized to avoid referring to duplicate files, thereby reducing the workload of the hairpin, only Process the difference image material.
  • the background image synthesizing unit is specifically configured to: combine the plurality of image materials into a background image according to a preset synthesis rule.
  • the preset composition rule is defined as: arranging the image materials in the horizontal direction, or sequentially arranging the image materials in the vertical direction.
  • the image materials are arranged in the horizontal direction, and the height of each image material is the same.
  • the width of each image material is the width of the background image/the number of image materials.
  • the image materials are arranged in the vertical direction, and the width of each image material is the same.
  • the height of each image material is the height of the background image / the number of image materials.
  • the background image synthesizing unit is further configured to: calculate a background image positioning attribute according to a preset synthesis rule. After merging several image materials into one background image, several image materials can be sequentially edited No., obtain the image number, according to the preset synthesis rule, the position of each image material in the background image, that is, the background image positioning attribute, each image number has a corresponding background image positioning attribute value, the background
  • the value of the image positioning attribute may be a pixel value or a percentage value. After selecting the image material to be used, the value of the corresponding background image positioning attribute may be obtained according to the image number.
  • the background image positioning attribute can be quickly calculated by the preset synthesis rule, and the precise positioning and fast switching of the background image can be realized.
  • the public file importing unit 42 is configured to introduce a public C SS file and a JS file in the web page, and add a background image positioning attribute to the public CSS file.
  • the pixel value and the percentage value can be converted into each other, and the conversion formula is:
  • x ⁇ width of the container - the width of the background image ⁇ * x percentage
  • y ⁇ the height of the container - the height of the background image ⁇ * y percentage.
  • the width of the background image is W
  • the number of subject types is N
  • the width of the label container is W/N
  • the value of the horizontal offset pixel is X
  • the percentage value is P, horizontally biased.
  • the relationship between the shifted pixel value X and the percentage value P is:
  • a style is added to the label that needs to be switched by the theme, where the attributes including ba ckground-image, width, and height are set, and the url of the background-image attribute is set as the background image, if included
  • the image material is arranged in landscape orientation
  • the width is set to 1/3 of the width of the background image
  • height is the height of the background image.
  • x, y that is, the setting of the starting position of the background image of the label is completed.
  • the default value of background-position:x,y attribute is ⁇ , ⁇ , the first parameter is the horizontal position, and the second parameter is the vertical position.
  • the background image When the image material is arranged in the horizontal direction, the background image only needs to be positioned in the horizontal direction. Since it only needs to set the background-position-x to be a thousand, the background-position-y is not required to be set. The default is 0 ⁇ 3 ⁇ 4. , equivalent to background-positio x ⁇ Oy ⁇
  • the theme switching unit 43 is configured to dynamically change the value of the background image positioning attribute through the JS file to switch the corresponding content in the background image after the theme is switched.
  • the dynamic script script theme.js is used to read the saved topic type in the cookie, and the value of the background-position:x,y attribute is dynamically changed, for example, there are three topic types.
  • the theme is Theme 1, Theme 2, Theme 3, the width of the background image is w, and the image material is ⁇ 1 J in the horizontal direction.
  • the invention can complete the theme switching through a background image, a C SS file, a JS file, simplify the directory structure, reduce duplicate CSS files, repeatedly introduce images, and reduce unnecessary http requests caused by theme switching, and reduce page bursts. Workload, and achieve efficient, non-refreshing topic switching to enhance the user experience.
  • FIG. 5 is a schematic diagram of a theme switching unit according to an embodiment of the present invention, and the topic switching unit 43 includes:
  • a writing unit 431, configured to write the selected topic type to the cookie
  • a reading unit 432 configured to read a topic type in the cookie through the JS file after loading the page
  • the switching subunit 433 is configured to dynamically change the value of the background image positioning attribute according to the theme type to switch to the corresponding content in the background image.
  • the theme switching unit further includes: a first switching unit, configured to dynamically change a value of the background image positioning attribute by using a JS file by acquiring a current geographic location.
  • a first switching unit configured to dynamically change a value of the background image positioning attribute by using a JS file by acquiring a current geographic location.
  • the theme can be switched, the weather temperature value is obtained, and the corresponding topic type is dynamically switched according to the weather temperature value, for example, the snow theme is presented when the ambient temperature is zero, and the scalability of the theme switching is enhanced.
  • the background image is determined.
  • Bit mode using a CSS file to achieve mutual switching between multiple topic types, avoiding topic switching, introducing duplicate files, simplifying burst mode, saving bursts, reducing web server publishing duplicate resources, reducing User frequent file requests, no refresh theme switching, and enhance user experience.
  • the technical solution of the present invention which is essential or contributes to the prior art, may be embodied in the form of a software product stored in a storage medium (such as ROM/RAM, disk,
  • a storage medium such as ROM/RAM, disk
  • the optical disc includes a number of instructions for causing a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to perform the methods described in various embodiments of the present invention.
  • the web theme switching method and system according to the embodiment of the present invention can realize the mutual switching between multiple theme types by using a CSS file by synthesizing the image material into a background image and using the background image positioning method. Avoid topic switching, introduce duplicate files, simplify burst mode, save bursts
  • Reduce web server publishing duplicate resources, reduce frequent file requests, and implement no-refresh theme switching to improve user experience.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Human Computer Interaction (AREA)
  • Processing Or Creating Images (AREA)

Abstract

本发明公开了一种Web主题切换方法及系统,属于互联网技术领域。该方法包括:将主题切换所需的图像素材进行合成,得到背景图像;在Web页面中,引入公共CSS文件及JS文件,在公共CSS文件中添加背景图像定位属性;在主题切换时,通过JS文件动态改变背景图像定位属性的值,以将背景图像中对应的内容进行切换。本发明通过将图像素材合成为一个背景图像后,采用背景图像定位的方式,利用一个CSS文件即可实现多个主题类型之间的相互切换,避免了主题切换时引入重复文件,简化开发模式、节约开发时间,减少web服务器发布重复的资源,减少用户频繁的文件请求,实现无刷新主题切换,提升用户体验。

Description

Web主题切换方法及系统
技术领域
[0001] 本发明涉及互联网技术领域, 尤其涉及一种 Web主题切换方法及系统。
背景技术
[0002] 目前的主题切换通常采用的方法有: 1、 设计两套以上的界面, 通过指向不同 的界面文件完成主题切换功能, 这相当于幵发两套以上系统, 所有界面设计及 样式库均不共用, 这样的好处是界面设计丰富性, 可操作性较强, 自由度较高 。 但是幵发两套以上系统界面需要投入更多的人力及吋间, 对于一般的门户网 站, 主题切换往往改动并不大, 只有个别 logo、 图片、 颜色需要切换, 所以并不 需要幵发两套以上系统; 2、 通过点击自定义的主题样式, 利用 Javascript技术或 者 Spring Mvc等技术动态改变页面当前弓 I用的主题 CSS文件, 并且将当前的主题 样式写入 Cookie、 Session或者写入数据库中, 以便于下次该用户重新访问页面吋 , 调用的就是上次设置好的主题样式。 这种方式不要要设计多套 html界面文件, 只需设计多套 ess主题文件以及对应的切图文件, 不同主题的 ess文件及图片存放 的路径不同, 当用户需要切换主题皮肤的吋候, 只需指向 theme文件夹下的不同 主题文件夹下的 CSS文件。
[0003] 上述技术方案存在以下缺点: 1、 需要多套样式库, 2、 文件目录结构比较多, 3、 切换主题吋需要重新请求图片及 CSS文件。 采用上述技术方案在主题切换吋 会造成的重复文件的引入, 以及幵发多套主题使得需要重复幵发工作, 并且主 题切换会导致频繁的 Web请求。
技术问题
[0004] 有鉴于此, 本发明的目的在于提供一种 Web主题切换方法及系统, 以解决现有 技术中需要通过需要重复幵发多套系统或者多个 CSS文件以实现主体切换的功能 , 导致幵发工作大量重复、 Web请求频繁的问题。
问题的解决方案
技术解决方案 [0005] 本发明解决上述技术问题所采用的技术方案如下:
[0006] 根据本发明的一个方面, 提供的一种 Web主题切换方法, 包括:
[0007] 将主题切换所需的图像素材进行合成, 得到背景图像;
[0008] 在 Web页面中, 引入公共 CSS文件及 JS文件, 在所述公共 CSS文件中添加背景 图像定位属性;
[0009] 在主题切换吋, 通过所述 JS文件动态改变所述背景图像定位属性的值, 以将所 述背景图像中对应的内容进行切换。
[0010] 优选地, 将主题切换所需的图像素材进行合成, 得到背景图像的步骤, 包括: [0011] 根据预设合成规则, 将若干图像素材合并为一背景图像。
[0012] 优选地, 根据预设合成规则计算背景图像定位属性。
[0013] 优选地, 该在主题切换吋, 通过 JS文件动态改变背景图像定位属性的值, 以将 背景图像中对应的内容进行切换的步骤, 包括:
[0014] 将所选的主题类型写入 cookie;
[0015] 在加载页面吋, 通过 JS文件读取 cookie内的主题类型;
[0016] 根据主题类型动态改变背景图像定位属性的值, 以切换至背景图像中对应的内 容。
[0017] 优选地, 该在主题切换吋, 通过 JS文件动态改变背景图像定位属性的值, 以将 背景图像中对应的内容进行切换的步骤, 还包括:
[0018] 通过获取当前地理位置, 通过 JS文件动态改变背景图像定位属性的值。
[0019] 根据本发明的另一个方面, 提供的一种 Web主题切换系统, 包括:
[0020] 背景图像合成单元, 用于将主题切换所需的图像素材进行合成, 得到背景图像
[0021] 公共文件引入单元, 用于在 Web页面中, 引入公共 CSS文件及 JS文件, 在公共 CSS文件中添加背景图像定位属性; 以及主题切换单元, 用于在主题切换吋, 通 过 JS文件动态改变背景图像定位属性的值, 以将背景图像中对应的内容进行切换
[0022] 优选地, 该背景图像合成单元具体用于:
[0023] 根据预设合成规则, 将若干图像素材合并为一背景图像。 [0024] 优选地, 该背景图像合成单元还用于:
[0025] 根据预设合成规则计算背景图像定位属性。
[0026] 优选地, 该主题切换单元包括:
[0027] 写入单元, 用于将所选的主题类型写入 cookie;
[0028] 读取单元, 用于在加载页面吋, 通过 JS文件读取 cookie内的主题类型; 以及 [0029] 切换子单元, 用于根据主题类型动态改变背景图像定位属性的值, 以切换至背 景图像中对应的内容。
[0030] 优选地, 该主题切换单元还包括:
[0031] 第一切换单元, 用于通过获取当前地理位置, 通过 JS文件动态改变背景图像定 位属性的值。
发明的有益效果
有益效果
[0032] 本发明实施例的 Web主题切换方法及系统, 通过将图像素材合成为一个背景图 像后, 采用背景图像定位的方式, 利用一个 CSS文件即可实现多个主题类型之间 的相互切换, 避免了主题切换吋引入重复文件, 简化幵发模式、 节约幵发吋间
, 减少 web服务器发布重复的资源, 减少用户频繁的文件请求, 实现无刷新主题 切换, 提升用户体验。
对附图的简要说明
附图说明
[0033] 图 1为本发明实施例的一种 Web主题切换方法的流程图;
[0034] 图 2为本发明实施例的三种主题类型切换效果的示意图;
[0035] 图 3为本发明实施例的三种主题类型的背景图像的示意图;
[0036] 图 4为本发明实施例的一种 Web主题切换系统的示意图;
[0037] 图 5为本发明实施例的主题切换单元的示意图。
[0038] 本发明目的的实现、 功能特点及优点将结合实施例, 参照附图做进一步说明。
本发明的实施方式 [0039] 为了使本发明所要解决的技术问题、 技术方案及有益效果更加清楚、 明白, 以 下结合附图和实施例, 对本发明进行进一步详细说明。 应当理解, 此处所描述 的具体实施例仅仅用以解释本发明, 并不用于限定本发明。
[0040] 图 1示出了本发明实施例的一种 Web主题切换方法的流程图, 该方法包括以下 步骤:
[0041] S101、 将主题切换所需的图像素材进行合成, 得到背景图像。
[0042] 在本发明实施例中, Web主题切换吋, 采用若干张图像素材, 将图像素材进行 合成, 则得到背景图像。 例如, 需要向用户提供三种主题类型用于主题切换, 在制作吋, 采集三张图像作为图像素材, 将这三张图像素材进行合成, 得到一 张背景图像, 该背景图像中包含了上述三张图像素材的内容。 由于不同的主题 类型只是一小部分的图像素材存在区别, 将每种主题类型中这些存在区别的图 像素材进行提取, 合成一张背景图像, 避免引用重复文件, 减少幵发吋的工作 量, 仅对区别的图像素材进行处理。
[0043] 具体地, 根据预设合成规则, 将若干图像素材合并为一背景图像。 为了减少幵 发的工作量, 结合实际应用, 将预设合成规则定义为: 将图像素材以横向依次 排列、 或将图像素材以纵向依次排列。 将图像素材以横向依次排列吋, 每张图 像素材的高度一致, 每张图像素材的宽度为背景图像的宽度 /图像素材的数量; 将图像素材以纵向依次排列吋, 每张图像素材的宽度一致, 每张图像素材的高 度为背景图像的高度 /图像素材的数量。 通过预设合成规则能够快速地获取到图 像素材及背景图像的宽度及高度, 减少后期的运算数据量。
[0044] 进一步地, 根据预设合成规则计算背景图像定位属性。 在将若干图像素材合并 为一背景图像吋, 可以对若干图像素材依次进行编号, 得到图像编号, 根据预 设合成规则, 可以计算出每个图像素材在该背景图像中的位置, 也就是背景图 像定位属性, 每个图像编号具有对应的背景图像定位属性的值, 该背景图像定 位属性的值可以是像素值, 也可以是百分比值, 选定所需使用的图像素材吋, 可以根据该图像编号, 得到对应的背景图像定位属性的值。 通过预设合成规则 可快速地计算得到背景图像定位属性, 实现精准定位、 快速切换背景图像。
[0045] S102、 在 Web页面中, 引入公共 CSS文件及 JS文件, 在公共 CSS文件中添加背 景图像定位属性。
[0046] 在本发明实施例中, 对于多个主题类型, 无需分别引入 CSS文件, 在 Web页面 中引用一个公共 CSS文件 theme.css及一个 JS文件 theme.js , 在公共 CSS文件 theme.c ss中添加背景图像定位属性 background-position: x,y, 其中 x、 y值可以是像素值 , 也可以是百分比值, x、 y值可以为正数或 0, 也可以为负数, 应用坐标规则 X 为负数吋候表示图片左顶点在容器左顶点的左侧, y为负数吋表示图片的左顶点 在容器的左定点的上方, 也就是向左和向上超出容器的范围。
[0047] 进一步地, 像素值和百分比值可以相互进行换算, 换算公式为:
[0048] background-postion:x,y
[0049] x: {容器 (container)的宽度一背景图像的宽度 }*x百分比;
[0050] y: {容器 (container)的高度一背景图像的高度 }*y百分比。
[0051] 以 X轴偏移为例, 背景图像的宽度为 W, 主题类型的个数为 N, 标签容器的宽度 为 W/N, 水平偏移像素值为 X, 百分比值为 P, 水平偏移像素值 X与百分比值 P的 关系即为:
[]
M. =■ -一― ― - ^ : ,
[0052] 具体地, 在 Web页面中, 对需要进行主题切换的标签添加样式, 其中, 包含 ba ckground- image、 width、 height这二个属性, 设置 background- image属性的 url为背 景图像, 若包含三种主题类型, 图像素材以横向依次排列, width设置为背景图 像的宽度 1/3, height为背景图像的高度。 在标签的 class属性加上背景图像定位属 ½background-position:x,y , 即完成该标签背景图像起始位置的设置。
background-position:x,y属性的默认值为 Ο^,Ο^ , 第一个参数为水平位置, 第二个 参数为垂直位置。 当图像素材以横向依次排列, 背景图像只需要水平方向的平 移定位, 因 it匕只需设置 background-position-x属千生, background-position-y属千生不 需设置, 默认为 0<¾, 等同于 background-positio x^ Oy^
[0053] S103、 在主题切换吋, 通过 JS文件动态改变背景图像定位属性的值, 以将背景 图像中对应的内容进行切换。 [0054] 在本发明实施例中, 当用户切换主题吋利用动态脚本 theme.js读取 cookie内的保 存的主题类型, 动态改变 background-position:x,y属性的值, 比如有三种主题类型 , 分别为主题 1, 主题 2, 主题 3, 背景图像的宽度为 w, 图像素材以横向依次排 歹1 J, 只需动态改变 background-position:x的值分别为 0, -(w/3)px, -(w/3*2)px, 这 样即可实现一步操作, 完成主题风格的切换。 本发明通过一张背景图像, 一个 C SS文件, 一个 JS文件即可完成主题切换, 简化目录结构, 减少重复 CSS文件、 重 复引入图像, 并且减少主题切换带来的多余 http请求, 减轻页面幵发工作量, 并 且实现高效、 无刷新的主题切换, 从而提升用户体验。
[0055] 具体地, 将所选的主题类型写入 cookie; 在加载页面吋, 通过 JS文件读取 cooki e内的主题类型; 根据主题类型动态改变背景图像定位属性的值, 以切换至背景 图像中对应的内容。
[0056] 进一步地, 通过获取当前地理位置, 通过 JS文件动态改变背景图像定位属性的 值。 可以结合地理位置进行主题切换, 打幵界面吋, 可以利用地理信息接口获 取当前地理位置, 根据地理位置的不同, 动态切换对应的主题类型, 比如在福 建八闽吋呈现福建特色主题, 到了新疆维吾尔族地区切换成当地风俗主题。 同 样地, 基于天气的变化也可以实现主题切换, 获取气象温度值, 根据气象温度 值动态切换对应的主题类型, 比如在环境温度为零下吋呈现雪景主题, 增强了 主题切换的可扩展性。
[0057] 在本发明实施例中, 通过将图像素材合成为一个背景图像后, 采用背景图像定 位的方式, 利用一个 CSS文件即可实现多个主题类型之间的相互切换, 避免了主 题切换吋引入重复文件, 简化幵发模式、 节约幵发吋间, 减少 web服务器发布重 复的资源, 减少用户频繁的文件请求, 实现无刷新主题切换, 提升用户体验。
[0058] 图 2示出了本发明实施例的三种主题类型切换效果的示意图, 分别是根据中国 , 美国, 非洲三个国家的特点设置的三种主题类型, 图 3示出了本发明实施例的 三种主题类型的背景图像的示意图, 将三种主题类型中的图像素材合成为一张 背景图像。
[0059] 在本发明实施例中, 具体应用在控件图标切换吋, 同样的, 将控件图标的图像 素材合并到一张背景图像上, 将背景图像放入 Web程序相关样式模块的 images文 件夹中, 为需要进行控件图标切换的 Web页面引入 theme.css , 以及 theme.js , 并 为 Web页面需要切换控件图标的 class属性加上 background-position属性。 当用户 在登陆界面切换主题吋, 将用户设置的主题记录到浏览器 Cookie中, 在页面加载 吋, 利用 theme.js动态改变 background-position属性来设置背景图像的起始位置, 即可完成所有页面控件图标切换功能。
[0060] 图 4示出了本发明实施例的一种 Web主题切换系统的示意图, 为了便于说明, 仅示出了与本发明实施例相关的部分, 详述如下:
[0061] 一种 Web主题切换系统, 包括: 背景图像合成单元 41、 公共文件引入单元 42及 主题切换单元 43, 其中:
[0062] 背景图像合成单元 41, 用于将主题切换所需的图像素材进行合成, 得到背景图 像。
[0063] 在本发明实施例中, Web主题切换吋, 采用若干张图像素材, 将图像素材进行 合成, 则得到背景图像。 例如, 需要向用户提供三种主题类型用于主题切换, 在制作吋, 采集三张图像作为图像素材, 将这三张图像素材进行合成, 得到一 张背景图像, 该背景图像中包含了上述三张图像素材的内容。 由于不同的主题 类型只是一小部分的图像素材存在区别, 将每种主题类型中这些存在区别的图 像素材进行提取, 合成一张背景图像, 避免引用重复文件, 减少幵发吋的工作 量, 仅对区别的图像素材进行处理。
[0064] 具体地, 背景图像合成单元具体用于: 根据预设合成规则, 将若干图像素材合 并为一背景图像。 为了减少幵发的工作量, 结合实际应用, 将预设合成规则定 义为: 将图像素材以横向依次排列、 或将图像素材以纵向依次排列。 将图像素 材以横向依次排列吋, 每张图像素材的高度一致, 每张图像素材的宽度为背景 图像的宽度 /图像素材的数量; 将图像素材以纵向依次排列吋, 每张图像素材的 宽度一致, 每张图像素材的高度为背景图像的高度 /图像素材的数量。 通过预设 合成规则能够快速地获取到图像素材及背景图像的宽度及高度, 减少后期的运 算数据量。
[0065] 进一步地, 背景图像合成单元还用于: 根据预设合成规则计算背景图像定位属 性。 在将若干图像素材合并为一背景图像吋, 可以对若干图像素材依次进行编 号, 得到图像编号, 根据预设合成规则, 可以计算出每个图像素材在该背景图 像中的位置, 也就是背景图像定位属性, 每个图像编号具有对应的背景图像定 位属性的值, 该背景图像定位属性的值可以是像素值, 也可以是百分比值, 选 定所需使用的图像素材吋, 可以根据该图像编号, 得到对应的背景图像定位属 性的值。 通过预设合成规则可快速地计算得到背景图像定位属性, 实现精准定 位、 快速切换背景图像。 公共文件引入单元 42, 用于在 Web页面中, 引入公共 C SS文件及 JS文件, 在公共 CSS文件中添加背景图像定位属性。
[0066] 在本发明实施例中, 对于多个主题类型, 无需分别引入 CSS文件, 在 Web页面 中引用一个公共 CSS文件 theme.css及一个 JS文件 theme.js , 在公共 CSS文件 theme.c ss中添加背景图像定位属性 background-position: x,y, 其中 x、 y值可以是像素值 , 也可以是百分比值, x、 y值可以为正数或 0, 也可以为负数, 应用坐标规则 X 为负数吋候表示图片左顶点在容器左顶点的左侧, y为负数吋表示图片的左顶点 在容器的左定点的上方, 也就是向左和向上超出容器的范围。
[0067] 进一步地, 像素值和百分比值可以相互进行换算, 换算公式为:
[0068] background-postion:x,y
[0069] x: {容器 (container)的宽度一背景图像的宽度 }*x百分比;
[0070] y: {容器 (container)的高度一背景图像的高度 }*y百分比。
[0071] 以 X轴偏移为例, 背景图像的宽度为 W, 主题类型的个数为 N, 标签容器的宽度 为 W/N, 水平偏移像素值为 X, 百分比值为 P, 水平偏移像素值 X与百分比值 P的 关系即为:
[]
Figure imgf000010_0001
[0072] 具体地, 在 Web页面中, 对需要进行主题切换的标签添加样式, 其中, 包含 ba ckground- image、 width、 height这二个属性, 设置 background- image属性的 url为背 景图像, 若包含三种主题类型, 图像素材以横向依次排列, width设置为背景图 像的宽度 1/3, height为背景图像的高度。 在标签的 class属性加上背景图像定位属 ½background-position:x,y , 即完成该标签背景图像起始位置的设置。 background-position:x,y属性的默认值为 Ο^,Ο^ , 第一个参数为水平位置, 第二个 参数为垂直位置。 当图像素材以横向依次排列, 背景图像只需要水平方向的平 移定位, 因 it匕只需设置 background-position-x属千生, background-position-y属千生不 需设置, 默认为 0<¾, 等同于 background-positio x^ Oy^
[0073] 主题切换单元 43, 用于在主题切换吋, 通过 JS文件动态改变背景图像定位属性 的值, 以将背景图像中对应的内容进行切换。
[0074] 在本发明实施例中, 当用户切换主题吋利用动态脚本 theme.js读取 cookie内的保 存的主题类型, 动态改变 background-position:x,y属性的值, 比如有三种主题类型 , 分别为主题 1, 主题 2, 主题 3, 背景图像的宽度为 w, 图像素材以横向依次排 歹1 J, 只需动态改变 background-position:x的值分别为 0, -(w/3)px, -(w/3*2)px, 这 样即可实现一步操作, 完成主题风格的切换。 本发明通过一张背景图像, 一个 C SS文件, 一个 JS文件即可完成主题切换, 简化目录结构, 减少重复 CSS文件、 重 复引入图像, 并且减少主题切换带来的多余 http请求, 减轻页面幵发工作量, 并 且实现高效、 无刷新的主题切换, 从而提升用户体验。
[0075] 进一步地, 图 5示出了本发明实施例的主题切换单元的示意图, 主题切换单元 4 3包括:
[0076] 写入单元 431, 用于将所选的主题类型写入 cookie;
[0077] 读取单元 432, 用于在加载页面吋, 通过 JS文件读取 cookie内的主题类型; 以及
[0078] 切换子单元 433, 用于根据主题类型动态改变背景图像定位属性的值, 以切换 至背景图像中对应的内容。
[0079] 进一步地, 主题切换单元还包括: 第一切换单元, 用于通过获取当前地理位置 , 通过 JS文件动态改变所述背景图像定位属性的值。 可以结合地理位置进行主题 切换, 打幵界面吋, 可以利用地理信息接口获取当前地理位置, 根据地理位置 的不同, 动态切换对应的主题类型, 比如在福建八闽吋呈现福建特色主题, 到 了新疆维吾尔族地区切换成当地风俗主题。 同样地, 基于天气的变化也可以实 现主题切换, 获取气象温度值, 根据气象温度值动态切换对应的主题类型, 比 如在环境温度为零下吋呈现雪景主题, 增强了主题切换的可扩展性。
[0080] 在本发明实施例中, 通过将图像素材合成为一个背景图像后, 采用背景图像定 位的方式, 利用一个 CSS文件即可实现多个主题类型之间的相互切换, 避免了主 题切换吋引入重复文件, 简化幵发模式、 节约幵发吋间, 减少 web服务器发布重 复的资源, 减少用户频繁的文件请求, 实现无刷新主题切换, 提升用户体验。 通过以上的实施方式的描述, 本领域的技术人员可以清楚地了解到上述实施例 方法可借助软件加必需的通用硬件平台的方式来实现, 当然也可以通过硬件来 实现, 但很多情况下前者是更佳的实施方式。 基于这样的理解, 本发明的技术 方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来 , 该计算机软件产品存储在一个存储介质 (如 ROM/RAM、 磁碟、 光盘) 中, 包 括若干指令用以使得一台终端设备 (可以是手机, 计算机, 服务器, 空调器, 或者网络设备等) 执行本发明各个实施例所述的方法。
[0082] 以上参照附图说明了本发明的优选实施例, 并非因此局限本发明的权利范围。
本领域技术人员不脱离本发明的范围和实质, 可以有多种变型方案实现本发明 , 比如作为一个实施例的特征可用于另一实施例而得到又一实施例。 凡在运用 本发明的技术构思之内所作的任何修改、 等同替换和改进, 均应在本发明的权 利范围之内。
工业实用性
[0083] 本发明实施例的 Web主题切换方法及系统, 通过将图像素材合成为一个背景图 像后, 采用背景图像定位的方式, 利用一个 CSS文件即可实现多个主题类型之间 的相互切换, 避免了主题切换吋引入重复文件, 简化幵发模式、 节约幵发吋间
, 减少 web服务器发布重复的资源, 减少用户频繁的文件请求, 实现无刷新主题 切换, 提升用户体验。

Claims

权利要求书
[权利要求 1] 一种 Web主题切换方法, 所述方法包括:
将主题切换所需的图像素材进行合成, 得到背景图像;
在 Web页面中, 引入公共 CSS文件及 JS文件, 在所述公共 CSS文件中 添加背景图像定位属性;
在主题切换吋, 通过所述 JS文件动态改变所述背景图像定位属性的值
, 以将所述背景图像中对应的内容进行切换。
[权利要求 2] 根据权利要求 1所述的 Web主题切换方法, 其中, 所述将主题切换所 需的图像素材进行合成, 得到背景图像的步骤, 包括:
根据预设合成规则, 将若干图像素材合并为一背景图像。
[权利要求 3] 根据权利要求 2所述的 Web主题切换方法, 其中, 所述将主题切换所 需的图像素材进行合成, 得到背景图像的步骤, 还包括:
根据所述预设合成规则计算所述背景图像定位属性。
[权利要求 4] 根据权利要求 1所述的 Web主题切换方法, 其中, 所述在主题切换吋
, 通过所述 JS文件动态改变所述背景图像定位属性的值, 以将所述背 景图像中对应的内容进行切换的步骤, 包括:
将所选的主题类型写入 cookie;
在加载页面吋, 通过所述 JS文件读取 cookie内的主题类型; 根据主题类型动态改变所述背景图像定位属性的值, 以切换至所述背 景图像中对应的内容。
[权利要求 5] 根据权利要求 1所述的 Web主题切换方法, 其中, 所述在主题切换吋
, 通过所述 JS文件动态改变所述背景图像定位属性的值, 以将所述背 景图像中对应的内容进行切换的步骤, 还包括: 通过获取当前地理位置, 通过所述 JS文件动态改变所述背景图像定位 属性的值。
[权利要求 6] —种 Web主题切换系统, 所述系统包括:
背景图像合成单元, 用于将主题切换所需的图像素材进行合成, 得到 背景图像; 公共文件引入单元, 用于在 Web页面中, 引入公共 CSS文件及 JS文件 , 在所述公共 CSS文件中添加背景图像定位属性; 以及
主题切换单元, 用于在主题切换吋, 通过所述 JS文件动态改变所述背 景图像定位属性的值, 以将所述背景图像中对应的内容进行切换。
[权利要求 7] 根据权利要求 6所述的 Web主题切换系统, 其中, 所述背景图像合成 单元具体用于:
根据预设合成规则, 将若干图像素材合并为一背景图像。
[权利要求 8] 根据权利要求 7所述的 Web主题切换系统, 其中, 所述背景图像合成 单元, 还用于:
根据所述预设合成规则计算所述背景图像定位属性。
[权利要求 9] 根据权利要求 6所述的 Web主题切换系统, 其中, 所述主题切换单元 包括:
写入单元, 用于将所选的主题类型写入 cookie;
读取单元, 用于在加载页面吋, 通过所述 JS文件读取 cookie内的主题 类型; 以及
切换子单元, 用于根据主题类型动态改变所述背景图像定位属性的值 , 以切换至所述背景图像中对应的内容。
[权利要求 10] 根据权利要求 6所述的 Web主题切换系统, 其中, 所述主题切换单元 还包括:
第一切换单元, 用于通过获取当前地理位置, 通过所述 JS文件动态改 变所述背景图像定位属性的值。
PCT/CN2017/078370 2017-03-28 2017-03-28 Web主题切换方法及系统 WO2018176207A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2017/078370 WO2018176207A1 (zh) 2017-03-28 2017-03-28 Web主题切换方法及系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2017/078370 WO2018176207A1 (zh) 2017-03-28 2017-03-28 Web主题切换方法及系统

Publications (1)

Publication Number Publication Date
WO2018176207A1 true WO2018176207A1 (zh) 2018-10-04

Family

ID=63674032

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/078370 WO2018176207A1 (zh) 2017-03-28 2017-03-28 Web主题切换方法及系统

Country Status (1)

Country Link
WO (1) WO2018176207A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109375923A (zh) * 2018-10-26 2019-02-22 网易(杭州)网络有限公司 变更数据处理方法、装置、存储介质、处理器及服务器
CN110347956A (zh) * 2019-05-31 2019-10-18 江苏创智云智能科技有限公司 基于网络图片的推广方法及装置
CN110471738A (zh) * 2019-08-22 2019-11-19 北京字节跳动网络技术有限公司 应用程序的主题切换方法、装置、电子设备及存储介质
CN111131352A (zh) * 2018-10-31 2020-05-08 北京国双科技有限公司 主题切换方法及装置
CN113569171A (zh) * 2021-09-26 2021-10-29 上海观安信息技术股份有限公司 网页主题更换方法及装置、存储介质、计算机设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102314434A (zh) * 2010-06-30 2012-01-11 中兴通讯股份有限公司 页面背景图合并显示的方法及装置
CN102981722A (zh) * 2012-11-05 2013-03-20 广东欧珀移动通信有限公司 一种切换场景的方法和装置
CN104572668A (zh) * 2013-10-15 2015-04-29 阿里巴巴集团控股有限公司 基于多个样式文件生成合并样式文件的方法和设备
CN106293758A (zh) * 2016-08-17 2017-01-04 深圳市金证科技股份有限公司 一种Web应用界面换肤的方法和装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102314434A (zh) * 2010-06-30 2012-01-11 中兴通讯股份有限公司 页面背景图合并显示的方法及装置
CN102981722A (zh) * 2012-11-05 2013-03-20 广东欧珀移动通信有限公司 一种切换场景的方法和装置
CN104572668A (zh) * 2013-10-15 2015-04-29 阿里巴巴集团控股有限公司 基于多个样式文件生成合并样式文件的方法和设备
CN106293758A (zh) * 2016-08-17 2017-01-04 深圳市金证科技股份有限公司 一种Web应用界面换肤的方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"CSS sprites", COMPUTER KNOWLEDGE AND TECHNOLOGY, 31 July 2011 (2011-07-31), pages 4964 - 4965, ISSN: 1009-3044 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109375923A (zh) * 2018-10-26 2019-02-22 网易(杭州)网络有限公司 变更数据处理方法、装置、存储介质、处理器及服务器
CN109375923B (zh) * 2018-10-26 2022-05-03 网易(杭州)网络有限公司 变更数据处理方法、装置、存储介质、处理器及服务器
CN111131352A (zh) * 2018-10-31 2020-05-08 北京国双科技有限公司 主题切换方法及装置
CN111131352B (zh) * 2018-10-31 2023-01-13 北京国双科技有限公司 主题切换方法及装置
CN110347956A (zh) * 2019-05-31 2019-10-18 江苏创智云智能科技有限公司 基于网络图片的推广方法及装置
CN110471738A (zh) * 2019-08-22 2019-11-19 北京字节跳动网络技术有限公司 应用程序的主题切换方法、装置、电子设备及存储介质
CN113569171A (zh) * 2021-09-26 2021-10-29 上海观安信息技术股份有限公司 网页主题更换方法及装置、存储介质、计算机设备

Similar Documents

Publication Publication Date Title
WO2018176207A1 (zh) Web主题切换方法及系统
CN103235685B (zh) 一种设置终端操作系统桌面内容的方法和装置
CN107831974B (zh) 信息分享方法、装置及存储介质
US20090307602A1 (en) Systems and methods for creating and sharing a presentation
CN102364460B (zh) 基于移动终端的页面自动放大方法和系统
JP5930497B2 (ja) テンプレートファイルの処理方法及び装置
CN106157239B (zh) 一种图片处理方法及相关设备与系统
US9876879B2 (en) Distributed network page generation
JP2014524623A5 (zh)
CN104360847A (zh) 一种用于处理图像的方法与设备
CN103839479A (zh) 一种高效电子地图注记交互方法
CN104536649A (zh) 一种页面的显示方法及装置
CN105701165A (zh) 浏览器模式切换方法及切换装置
JP2007312240A (ja) 携帯端末動的画像表示システム
JP2015035167A (ja) 情報処理装置、情報処理方法及びプログラム
CN113099285A (zh) 展示方法及装置
US20220335977A1 (en) Method and apparatus for editing object, electronic device and storage medium
JP5792326B2 (ja) 読取サービスの提供方法、コンテンツ提供サーバ及びシステム
WO2015058614A1 (zh) 一种书签存储方法及装置、确定待浏览书签的方法及装置
KR100848452B1 (ko) 지도 기반의 컨텐츠 등록/표시 방법
CN105389308A (zh) 网页的显示处理方法及装置
KR100839041B1 (ko) 이미지 파일을 이용한 모바일 인터넷 기반의 웹 콘텐츠제공시스템 및 제공방법
CN105893048A (zh) 浏览器主题更换方法、装置及电子设备
CN105224602A (zh) 一种资源的展示方法和装置
JP2019021255A (ja) デジタル出版システム、デジタル出版方法及びコンピュータプログラム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17903690

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17903690

Country of ref document: EP

Kind code of ref document: A1