Icon set loading method and device, electronic equipment and medium
By marking and compiling icon files, generating font format files and cascading style sheets, and replacing class name names, the problems of low loading efficiency and conflict of icon sets are solved, and the icon loading efficiency and user experience are improved.
Patent Information
- Application Number
- CN202411189691.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-12-06
AI Technical Summary
Existing icon set loading methods have compatibility issues when dealing with multiple icon set formats, resulting in low icon loading efficiency, affecting user experience, and may have icon conflicts and duplicate loading, increasing maintenance difficulty.
By obtaining the icon files in the icon library, marking the icon elements to be loaded, using the preset compilation tool to generate font format files and cascading style sheets, class name mapping and replacement, ensuring the uniqueness of the icon class name, avoiding conflicts, and improving loading efficiency.
It achieves the improvement of icon loading efficiency, avoids icon conflicts, simplifies icon style management, and improves user experience.
Smart Images

Figure CN119088472A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an icon set loading method, device, electronic device and medium. Background Art
[0002] As for the front-end icon set solution, the industry generally uses iconfont, or uses the icons provided in the component library, which is also a variation of iconfont. Iconfont loads and displays icons in the form of icon sets. Its inspiration comes from the early framework Bootstrap and other mainstream front-end UI (User Interface) frameworks. Iconfont adds free grouping and custom production of icon sets, which was indeed the best solution at the time. However, with the continuous fragmentation of front-end engineering, each component may be introduced separately and packaged on demand. This method of introducing and using the entire package will have many conflicts with the existing architectural design.
[0003] For icon set loading, there will always be requests. For the format compatibility of icon sets, some projects choose to use multiple icon set formats to deal with browser compatibility issues. If the icons in the components are all independent icon sets, then a complete page may have a lot of icon set requests. When the icon set needs to be updated, it may be necessary to regenerate the entire font file and replace the existing file. This process may be cumbersome, and if there are two icon set libraries with the same name on a page, there will be unsolvable conflicts, which will further lead to a slow icon loading process, resulting in extremely low icon loading efficiency and affecting the user experience. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose an icon set loading method, device, electronic device and medium to avoid conflicts between two icons and improve the icon loading efficiency.
[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes an icon set loading method, the method comprising: Obtain an icon file in an icon library, wherein the icon file includes a plurality of icon elements; In response to a resource loading request, determining an icon element to be loaded corresponding to the resource loading request; Marking the icon element to be loaded in the icon file to obtain a marked icon element; Scanning the marked icon file based on a preset compilation tool to obtain a marked icon element set; Generate a font format file and a cascading style sheet according to the mark icon element set, and introduce the font format file into the cascading style sheet; Perform class name mapping on all the mark icon elements through the imported font format file to obtain an icon class name mapping table; The class name of the icon element to be loaded is replaced according to the icon class name mapping table to obtain a loading result.
[0006] In some embodiments, the method of scanning the icon file after the marking process based on the preset compilation tool to obtain the set of marked icon elements includes: Creating a logic plug-in through a preset compilation tool, and mounting the logic plug-in to a compiler instance of the compilation tool, wherein the logic plug-in is used to access information in the compiler instance; The icon file after the marking process is scanned by the compilation tool, and all the marked icon elements in the icon file are collected to obtain a marked icon element set.
[0007] In some embodiments, generating a font format file and a cascading style sheet according to the mark icon element set includes: The fonts of the mark icon elements in the mark icon element set are converted by using a preset icon font generation tool to obtain a font format file and a cascading style sheet.
[0008] In some embodiments, the class name mapping of all the mark icon elements is performed through the imported font format file to obtain an icon class name mapping table, including: For each mark icon element in the mark icon element set, extract the mark icon class name of the mark icon element through the imported font format file, and generate a random hash value through a preset programming tool; Combining the mark icon class name with the random hash value to generate a target class name; All the target class names are sorted to obtain an icon class name mapping table.
[0009] In some embodiments, replacing the class name of the icon element to be loaded according to the icon class name mapping table to obtain the loading result includes: For each icon element to be loaded, obtaining the icon class name of the icon element to be loaded; Searching the mark icon class name corresponding to the icon class name through the icon class name mapping table; The icon class name of the icon element to be loaded is replaced according to the marked icon class name to obtain a loading result.
[0010] In some embodiments, after replacing the class name of the icon element to be loaded according to the icon class name mapping table to obtain the loading result, the method further includes: Update the marked icon element set according to the loading result to obtain a target icon element set; Performing a difference comparison between the mark icon element set and the target icon element set; If there are differences between the mark icon element set and the target icon element set, newly added icon elements are determined in the target icon element set, and a target font format file is generated according to the newly added icon elements, and the target font format file is introduced into the cascading style sheet.
[0011] In some embodiments, the step of marking the icon element to be loaded in the icon file to obtain the marked icon element includes: Performing a search operation on the icon file to find the icon element to be loaded in the icon file; A marking operation is performed on the icon element to be loaded based on a preset marking character to obtain a marked icon element.
[0012] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides an icon set loading device, the device comprising: A data acquisition module, used to acquire an icon file in an icon library, wherein the icon file includes a plurality of icon elements; A request receiving module, configured to determine, in response to a resource loading request, an icon element to be loaded corresponding to the resource loading request; A marking processing module, used for marking the icon element to be loaded in the icon file to obtain a marked icon element; An element scanning module is used to scan the icon file after the marking process based on a preset compilation tool to obtain a set of marked icon elements; A file generation module, used to generate a font format file and a cascading style sheet according to the mark icon element set, and introduce the font format file into the cascading style sheet; A class name mapping module, used to perform class name mapping on all the mark icon elements through the imported font format file to obtain an icon class name mapping table; The class name replacement module is used to replace the class name of the icon element to be loaded according to the icon class name mapping table to obtain a loading result.
[0013] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, an electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the icon set loading method described in the first aspect when executing the computer program.
[0014] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the icon set loading method described in the first aspect.
[0015] The icon set loading method, device, electronic device and storage medium proposed in the present application first obtain an icon file in an icon library, and the icon file includes multiple icon elements. In response to a resource loading request, the icon elements to be loaded corresponding to the resource loading request are determined in the icon file, and then the icon elements to be loaded in the icon file are marked, and the icon elements to be loaded that need to be used are marked to obtain marked icon elements, which are convenient for subsequent processing of the marked icon elements. The marked icon file is scanned based on a preset compilation tool to obtain a set of marked icon elements, thereby realizing the collection of all marked marked icon elements. Afterwards, a font format file and a cascading style sheet are generated according to the set of marked icon elements, and the font format file is introduced into the cascading style sheet, so as to ensure that the images of the same marked icon elements The consistency of the mark is improved, and by introducing the font format file into the cascading style sheet, the network overhead can be reduced, which is convenient for the unified management of the style of icon elements, can reduce repeated loading, and improve the page loading speed. Then, the class name of all the mark icon elements is mapped through the introduced font format file to obtain the icon class name mapping table, thereby ensuring that the class name of each icon is unique and avoiding naming conflicts caused by using the same icon name in multiple projects. Finally, the class name of the icon element to be loaded is replaced according to the icon class name mapping table, so that the icon elements to be loaded can be correctly displayed, and by directly replacing the class name of the icon element to be loaded, the existing style in the icon library will not be polluted, and the loading result is obtained, which isolates the external style pollution and can avoid the icon conflict, further improving the loading efficiency of the icon and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a flowchart of an icon set loading method provided in an embodiment of the present application; Figure 2 yes Figure 1 Flow chart of step S104 in FIG. Figure 3 It is a specific flow chart of generating a font format file and a cascading style sheet according to a set of marker icon elements provided by an embodiment of the present application; Figure 4 yes Figure 1 Flow chart of step S106 in FIG. Figure 5 yes Figure 1 Flow chart of step S107 in FIG. Figure 6is a specific flow chart of an icon set loading method provided by another embodiment of the present application; Figure 7 yes Figure 1 Flow chart of step S103 in FIG. Figure 8 is a structural schematic diagram of an icon set loading device provided in an embodiment of the present application; Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0018] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0019] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0020] First, some nouns involved in this application are analyzed: Natural Language Processing (NLP): NLP uses computers to process, understand, and apply human languages (such as Chinese, English, etc.). NLP is a branch of artificial intelligence and an interdisciplinary subject between computer science and linguistics. It is often referred to as computational linguistics. Natural language processing includes grammatical analysis, semantic analysis, and text understanding. Natural language processing is commonly used in technical fields such as machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, information intent recognition, information extraction and filtering, text classification and clustering, public opinion analysis, and opinion mining. It involves data mining related to language processing, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, and linguistic research related to language computing.
[0021] User Interface (UI): The user interface is the medium for interaction and information exchange between the system and the user. It realizes the conversion between the internal form of information and the form acceptable to humans. The user interface is the software designed between the user and the hardware for interaction and communication. The purpose is to enable the user to operate the hardware conveniently and efficiently to achieve two-way interaction and complete the work that the hardware wants to complete. The definition of user interface is broad, including human-computer interaction and graphical user interface. User interface exists in all fields involving information exchange between humans and machines.
[0022] Content Delivery Network (CDN): The basic idea of a content delivery network is to avoid bottlenecks and links on the Internet that may affect the speed and stability of data transmission as much as possible, so that content can be transmitted faster and more stably. By placing node servers in various places on the network to form a layer of intelligent virtual network on the existing Internet, the CDN system can redirect user requests to the service node closest to the user in real time based on comprehensive information such as network traffic and the connection and load status of each node, as well as the distance to the user and response time. Its purpose is to enable users to obtain the required content nearby, solve the problem of Internet network congestion, and improve the response speed of users visiting websites.
[0023] Web Open Font Format (WOFF): Web Open Font Format is a font format standard used by web pages. This font format can not only effectively use compression to reduce file size, but also does not contain encryption and is not subject to DRM (Digital Rights Management) restrictions.
[0024] Cascading Style Sheets (CSS): Cascading Style Sheets is a computer language used to express the style of files such as HTML (Hyper Text Markup Language) or XML (Extensible Markup Language). CSS can not only modify web pages statically, but also dynamically format the elements of web pages in conjunction with various scripting languages.
[0025] Based on this, the embodiments of the present application provide an icon set loading method and device, an electronic device and a storage medium to avoid conflicts between two icons and improve the icon loading efficiency.
[0026] The icon set loading method and device, electronic device and storage medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the icon set loading method in the embodiments of the present application is described.
[0027] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0028] The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. Artificial intelligence software technologies mainly include computer vision technology, robotics technology, biometrics technology, module management technology of online meeting systems, natural language processing technology, and machine learning / deep learning.
[0029] The icon set loading method provided in the embodiment of the present application relates to the field of data processing technology. The icon set loading method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, or can be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the icon set loading method, etc., but is not limited to the above forms.
[0030] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0031] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with the relevant laws, regulations, and standards of the relevant countries and regions. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0032] As for the front-end icon set solution, the industry generally uses iconfont, or uses the icons provided in the component library, which is also a variation of iconfont. Iconfont loads and displays icons in the form of icon sets. Its inspiration comes from the early framework Bootstrap and other mainstream front-end UI (User Interface) frameworks. Iconfont adds free grouping and custom production of icon sets, which was indeed the best solution at the time. However, with the continuous fragmentation of front-end engineering, each component may be introduced separately and packaged on demand. This method of introducing and using the entire package will have many conflicts with the existing architectural design.
[0033] For icon set loading, there will always be requests. For the format compatibility of icon sets, some projects choose to use multiple icon set formats to deal with browser compatibility issues. If the icons in the components are all independent icon sets, then a complete page may have a lot of icon set requests. When the icon set needs to be updated, it may be necessary to regenerate the entire font file and replace the existing file. This process may be cumbersome, and if there are two icon set libraries with the same name on a page, there will be unsolvable conflicts, which will further lead to a slow icon loading process, resulting in extremely low icon loading efficiency and affecting the user experience.
[0034] In addition, in the current icon set loading method, the icon set package is produced remotely from iconfont and needs to be created and produced manually. In flexible projects, accurate Tree Shaking cannot be achieved, and all processes that rely on manual operations will tend to be chaotic, which leads to the inability to introduce icons on demand. In addition, many businesses do not even consider their CDN performance during use. As the number of icons continues to increase, the size of the icon set will also continue to increase, and users may not be able to see the icons at any time.
[0035] In order to solve the above problems, the present embodiment provides an icon set loading method, device, electronic device and storage medium. First, an icon file in an icon library is obtained, and the icon file includes multiple icon elements. In response to a resource loading request, the icon elements to be loaded corresponding to the resource loading request are determined in the icon file, and then the icon elements to be loaded in the icon file are marked, and the icon elements to be loaded that need to be used are marked to obtain marked icon elements, which are convenient for subsequent processing of the marked icon elements. The marked icon file is scanned based on a preset compilation tool to obtain a set of marked icon elements, thereby realizing the collection of all marked marked icon elements. Afterwards, a font format file and a cascading style sheet are generated according to the set of marked icon elements, and the font format file is introduced into the cascading style sheet, so as to ensure the same marked icon elements. The icon consistency of the mark elements is improved, and by introducing the font format file into the cascading style sheet, the network overhead can be reduced, which is convenient for the unified management of the style of the icon elements, can reduce repeated loading, and improve the page loading speed. Then, the class name of all the mark icon elements is mapped through the introduced font format file to obtain the icon class name mapping table, so as to ensure that the class name of each icon is unique and avoid naming conflicts caused by using the same icon name in multiple projects. Finally, the class name of the icon element to be loaded is replaced according to the icon class name mapping table, so that the icon elements to be loaded can be correctly displayed, and by directly replacing the class name of the icon element to be loaded, the existing style in the icon library will not be polluted, and the loading result is obtained, which isolates the external style pollution and can avoid the icon conflict, further improve the loading efficiency of the icon and improve the user experience.
[0036] The following is a detailed description with reference to the accompanying drawings.
[0037] Figure 1 is an optional flowchart of the icon set loading method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S107.
[0038] Step S101, obtaining an icon file in an icon library, wherein the icon file includes a plurality of icon elements.
[0039] In step S101 in some embodiments, the embodiment of the present application first obtains an icon file in an icon library, and the icon file includes multiple icon elements, wherein the icon library in the embodiment of the present application can be a FreeIcons icon library, a Unicons icon library, an iconfont icon library, etc., and the embodiment of the present application does not make specific limitations.
[0040] Step S102: in response to a resource loading request, determining an icon element to be loaded corresponding to the resource loading request.
[0041] In step S102 of some embodiments, in response to a resource loading request, an icon element to be loaded corresponding to the resource loading request, ie, an icon element to be loaded, is determined, so that the required icon element can be loaded in a targeted manner later.
[0042] Step S103, marking the icon elements to be loaded in the icon file to obtain marked icon elements.
[0043] In step S103 of some embodiments, the icon elements to be loaded in the icon file are marked, and the marked icon elements are obtained by labeling the icon elements to be loaded, so as to facilitate the subsequent collection of the required marked icon elements.
[0044] Step S104: Scan the marked icon file based on a preset compilation tool to obtain a marked icon element set.
[0045] In step S104 of some embodiments, the marked icon file is scanned based on a preset compilation tool, all marked icon elements in the icon file are traversed, the marked icon elements are scanned and collected, and a marked icon element set is obtained to realize the collection of all marked icon elements.
[0046] It should be noted that the compilation tool in the embodiment of the present application may be webpack, Parcel, Browserify, Prepack, etc., and the compilation tool in the embodiment of the present application is webpack.
[0047] Step S105: Generate a font format file and a cascading style sheet according to the mark icon element set, and introduce the font format file into the cascading style sheet.
[0048] In step S105 of some embodiments, a font format file and a cascading style sheet are generated according to a set of mark icon elements. At this time, the icon font generation tool generates a WOFF file including icon elements and a CSS file, namely, a font format file and a cascading style sheet. The font format file can ensure that all users see the same icon elements, and the icons are applied by using CSS class names, which is easy to manage and maintain. The font format file is introduced into the cascading style sheet to facilitate centralized management and maintenance of font styles, reduce duplicate loading, and improve page loading speed.
[0049] Step S106, performing class name mapping on all mark icon elements through the imported font format file to obtain an icon class name mapping table.
[0050] In step S106 of some embodiments, class names of all mark icon elements are mapped by introducing the font format file to reduce the mutual influence between different CSS rules, improve the encapsulation of the style, and obtain an icon class name mapping table. The icon class name mapping table provides a clear mapping relationship from icon name to class name, making it easier to maintain and update the icon style.
[0051] Step S107, replacing the class name of the icon element to be loaded according to the icon class name mapping table to obtain a loading result.
[0052] In step S107 of some embodiments, the class name of the icon element to be loaded is replaced according to the icon class name mapping table to obtain the loading result, thereby realizing the replacement of the icon class name of the icon element to be loaded. During the replacement process, the existing style will not be polluted and there will be no conflict with other icon sets, thereby avoiding the occurrence of icon set conflicts and isolating the pollution of external styles.
[0053] See also Figure 2 In some embodiments, step S104 may also include but is not limited to steps S201 to S202.
[0054] Step S201 : creating a logic plug-in through a preset compilation tool, and mounting the logic plug-in to a compiler instance of the compilation tool, wherein the logic plug-in is used to access information in the compiler instance.
[0055] Step S202: Scan the marked icon file through a compilation tool, and collect all marked icon elements in the icon file to obtain a marked icon element set.
[0056] In steps S201 to S202 of some embodiments, in the process of scanning the marked icon file based on the preset compilation tool, the embodiment of the present application will first create a logic plug-in through the preset compilation tool, and mount the logic plug-in to the compiler instance of the compilation tool, so that the logic plug-in can access the information in the compiler instance, and can be separately extracted and mounted on the compiler instance of the compilation tool for operation, and then the marked icon file is scanned by the compilation tool, all marked icon elements in the icon file are traversed, and the marked icon elements are scanned and collected to obtain a marked icon element set, thereby realizing the collection of all marked icon elements.
[0057] It should be noted that the compilation tool of the embodiment of the present application can be webpack, Parcel, Browserify, Prepack, etc. The embodiment of the present application takes the compilation tool as webpack and the compiler instance as the compiler instance as an example for explanation. During the compilation stage, the embodiment of the present application will separately extract the plug-in and mount it on the compiler instance of webpack, scan all icon files, collect all registered marker icon elements, and generate a marker icon element set. Specifically, during the code compilation stage, the embodiment of the present application can find out the elements of the form icon={add} in all icon files, and collect the corresponding registered icons to generate an icon set in the form of [add, delete, edit, look].
[0058] See also Figure 3 , Figure 3 This is a specific flow chart of generating a font format file and a cascading style sheet according to a set of marker icon elements provided by an embodiment of the present application. In some embodiments, the method includes but is not limited to step S301.
[0059] Step S301 : performing font conversion on the mark icon elements in the mark icon element set by using a preset icon font generation tool to obtain a font format file and a cascading style sheet.
[0060] In step S301 of some embodiments, in the process of generating a font format file and a cascading style sheet based on a set of mark icon elements, font conversion is performed on the mark icon elements in the mark icon element set through a preset icon font generation tool, and the mark icon elements are converted into icon fonts. At this time, the icon font generation tool generates a WOFF file including the icon elements and a CSS file, namely, a font format file and a cascading style sheet. The font format file can ensure that all users see the same icon elements, and by using CSS class names to apply icons, it is easy to manage and maintain.
[0061] It can be understood that the icon font generation tool in the embodiment of the present application can be IcoMoon or Fontello, and the embodiment of the present application does not make any specific limitation.
[0062] See also Figure 4 In some embodiments, step S106 may also include but is not limited to steps S401 to S403.
[0063] Step S401: for each mark icon element in the mark icon element set, extract the mark icon class name of the mark icon element through the imported font format file, and generate a random hash value through a preset programming tool.
[0064] Step S402: Combine the mark icon class name with the random hash value to generate a target class name.
[0065] Step S403: sort all target class names to obtain an icon class name mapping table.
[0066] In steps S401 to S403 of some embodiments, in the process of mapping the class names of all mark icon elements through the introduced font format file, for each mark icon element in the mark icon element set, the mark icon class name of the mark icon element is extracted through the introduced font format file, and a random hash value is generated through a preset programming tool to ensure that the class name of each mark icon element is unique, and the automatically generated random hash value reduces the need for manual naming and reduces the possibility of errors. The mark icon class name is then combined with the random hash value to generate a target class name. Hashing can reduce the mutual influence between different CSS rules and improve the encapsulation of the style. Finally, all target class names are sorted to obtain an icon class name mapping table. The icon class name mapping table provides a clear mapping relationship from icon name to class name, making it easier to maintain and update icon styles.
[0067] Specifically, the embodiment of the present application generates a target class name by combining the mark icon class name with a random hash value, and takes the mark icon class name as add and the random hash value as baUWV as an example for explanation, where baUWV is a random hash that is generated differently each time a request is requested.
[0068] See also Figure 5 In some embodiments, step S107 may also include but is not limited to steps S501 to S503.
[0069] Step S501: for each icon element to be loaded, obtain the icon class name of the icon element to be loaded.
[0070] Step S502: searching the icon class name corresponding to the icon class name through the icon class name mapping table.
[0071] Step S503: replace the icon class name of the icon element to be loaded according to the marked icon class name to obtain the loading result.
[0072] In steps S501 to S503 of some embodiments, in the process of replacing the class name of the icon element to be loaded according to the icon class name mapping table, for each icon element to be loaded, the icon class name of the icon element to be loaded is obtained. Since the placeholder characters of the icon element to be loaded are only the markup language implemented in this scheme, the embodiment of the present application needs to find the marker icon class name corresponding to the icon class name through the icon class name mapping table, and finally replace the icon class name of the icon element to be loaded according to the marker icon class name to obtain the loading result, thereby realizing the replacement of the icon class name of the icon element to be loaded, and during the replacement process, the existing style will not be polluted, and no conflict will occur with other icon sets, thereby avoiding the occurrence of icon set conflicts and isolating the pollution of external styles.
[0073] It should be noted that the icon class name of the icon element to be loaded is Take the example to illustrate that the mark icon class name corresponding to icon={add} is found in the icon class name mapping table as baUWV, and the hash value corresponding to the icon font is 2Q0w9. At this time, the icon class name of the icon element to be loaded is replaced according to the mark icon class name to obtain the loading result, that is, .
[0074] See also Figure 6 , Figure 6 6 is a specific flow chart of an icon set loading method provided by another embodiment of the present application. In some embodiments, the method includes but is not limited to steps S601 to S603.
[0075] It should be noted that step S601 to step S603 occur after the class name of the icon element to be loaded is replaced according to the icon class name mapping table to obtain the loading result.
[0076] Step S601, updating the marked icon element set according to the loading result to obtain the target icon element set.
[0077] Step S602: performing a difference comparison between the marked icon element set and the target icon element set.
[0078] Step S603: if there are differences between the marked icon element set and the target icon element set, a new icon element is determined in the target icon element set, a target font format file is generated according to the new icon element, and the target font format file is introduced into the target cascading style sheet.
[0079] In steps S601 to S603 of some embodiments, after replacing the class name of the icon element to be loaded according to the icon class name mapping table, the embodiment of the present application will also dynamically introduce the icon library. Specifically, the embodiment of the present application updates the icon element set according to the loading result to obtain the target icon element set, and then compares the difference between the marked icon element set and the target icon element set. It can quickly identify the changes of the icon set in different versions or states, and determine whether there is an increment in the target icon element set. If there is a difference between the marked icon element set and the target icon element set, it means that there is an increment in the target icon element set, and it is necessary to determine the new icon element in the target icon element set, generate a target font format file based on the new icon element, and introduce the target font format file into the cascading style sheet, that is, repeat step S105, introduce the new target font format file into the existing cascading style sheet, so that the icon library can be dynamically updated.
[0080] It should be noted that if there is no difference between the marked icon element set and the target icon element set, it means that there is no increment in the target icon element set and no other processing operation is required.
[0081] It is worth noting that in the process of comparing the difference between the marked icon element set and the target icon element set, the embodiment of the present application will first create a difference function, compare the difference between the marked icon element set and the target icon element set by writing the difference function, and then determine which icons are newly added through the output of the difference function. Alternatively, the embodiment of the present application can directly compare the icons in the marked icon element set and the target icon element set to determine whether there are newly added icons in the target icon element set, etc., and the embodiment of the present application does not make specific restrictions.
[0082] See also Figure 7 In some embodiments, step S103 may also include but is not limited to steps S701 to S702.
[0083] Step S701, performing a search operation on the icon file to find the icon element to be loaded in the icon file.
[0084] Step S702: marking the icon element to be loaded based on a preset marking character to obtain a marked icon element.
[0085] In steps S701 to S702 of some embodiments, in the process of marking the icon elements to be loaded in the icon file, the embodiment of the present application first performs a search operation on the icon file, traverses all icon elements in the icon file to find the icon elements to be loaded in the icon file, and then marks the icon elements to be loaded based on preset marking characters to distinguish the required icon elements from other icon elements to obtain marked icon elements. By labeling the icon elements to be loaded, it is convenient to collect the required marked icon elements later.
[0086] It should be noted that, in the embodiment of the present application, the loading icon element can be marked by coding, that is, the loading icon element can be marked by a preset marking character. Specifically, in the embodiment of the present application, the loading icon element can be marked with code={corresponding to what needs to be displayed}, for example, The embodiment of the present application does not impose any specific limitation on the selection of the preset marking characters.
[0087] See also Figure 8 The embodiment of the present application further provides an icon set loading device, wherein the sorting model includes a first module and a second module, and the device includes: The data acquisition module 801 is used to acquire an icon file in an icon library, wherein the icon file includes a plurality of icon elements; A request receiving module 802 is used to determine, in response to a resource loading request, an icon element to be loaded corresponding to the resource loading request; The marking processing module 803 is used to mark the icon element to be loaded in the icon file to obtain a marked icon element; An element scanning module 804 is used to scan the icon file after the marking process based on a preset compilation tool to obtain a set of marked icon elements; The file generation module 805 is used to generate a font format file and a cascading style sheet according to the mark icon element set, and introduce the cascading style sheet into the font format file; The class name mapping module 806 is used to perform class name mapping on all mark icon elements through the imported font format file to obtain an icon class name mapping table; The class name replacement module 807 is used to replace the class name of the icon element to be loaded according to the icon class name mapping table to obtain the loading result.
[0088] In some embodiments, the icon set loading device also includes a difference comparison module, which is used to update the mark icon element set according to the loading results to obtain the target icon element set; it is also used to perform a difference comparison between the mark icon element set and the target icon element set; if there are differences between the mark icon element set and the target icon element set, newly added icon elements are determined in the target icon element set, and a target font format file and a target cascading style sheet are generated based on the newly added icon elements, and the target cascading style sheet is introduced into the target font format file.
[0089] The specific implementation of the icon set loading device is substantially the same as the specific implementation of the icon set loading method described above, and will not be described in detail herein.
[0090] The embodiment of the present application also provides an electronic device, the electronic device comprising: a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection and communication between the processor and the memory, and the program is executed by the processor to realize the above-mentioned icon set loading method. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0091] See also Fig. 9 , Fig. 9 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes: The processor 901 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application; The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 902 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 902, and the processor 901 calls and executes the icon set loading method of the embodiment of this application; Input / output interface 903, used to implement information input and output; Communication interface 904, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.); A bus 905 that transmits information between various components of the device (e.g., the processor 901, the memory 902, the input / output interface 903, and the communication interface 904); The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .
[0092] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned icon set loading method is implemented.
[0093] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0094] The icon set loading method, device, electronic device and storage medium provided in the embodiments of the present application first obtain an icon file in an icon library, and the icon file includes multiple icon elements. In response to a resource loading request, the icon elements to be loaded corresponding to the resource loading request are determined in the icon file, and then the icon elements to be loaded in the icon file are marked, and the icon elements to be loaded that need to be used are marked to obtain marked icon elements, so as to facilitate subsequent processing of the marked icon elements. The marked icon file is scanned based on a preset compilation tool to obtain a set of marked icon elements, thereby realizing the collection of all marked marked icon elements. Afterwards, a font format file and a cascading style sheet are generated according to the set of marked icon elements, and the font format file is introduced into the cascading style sheet, so as to ensure that the same marked icon elements icon consistency, and by introducing the font format file into the cascading style sheet, the network overhead can be reduced, the unified management of the style of the icon elements is convenient, the repeated loading can be reduced, and the page loading speed can be improved. Then, the class name of all the marker icon elements is mapped through the introduced font format file to obtain the icon class name mapping table, thereby ensuring that the class name of each icon is unique and avoiding naming conflicts caused by using the same icon name in multiple projects. Finally, the class name of the icon element to be loaded is replaced according to the icon class name mapping table, so that the icon element to be loaded can be correctly displayed, and by directly replacing the class name of the icon element to be loaded, the existing style in the icon library will not be polluted, and the loading result is obtained, which isolates the external style pollution and can avoid the icon conflict, further improving the loading efficiency of the icon and improving the user experience.
[0095] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0096] It can be understood by those skilled in the art that Figure 1-7 The technical solutions shown in the figure do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than those shown in the figure, or a combination of certain steps, or different steps.
[0097] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0098] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0099] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0100] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.
[0101] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0102] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0103] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0104] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0105] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A method for loading an icon set, It is characterized in that The method comprises: Obtain an icon file in an icon library, wherein the icon file includes a plurality of icon elements; In response to a resource loading request, determining an icon element to be loaded corresponding to the resource loading request; Marking the icon element to be loaded in the icon file to obtain a marked icon element; Scanning the marked icon file based on a preset compilation tool to obtain a marked icon element set; Generate a font format file and a cascading style sheet according to the mark icon element set, and introduce the font format file into the cascading style sheet; Perform class name mapping on all the mark icon elements through the imported font format file to obtain an icon class name mapping table; The class name of the icon element to be loaded is replaced according to the icon class name mapping table to obtain a loading result.
2. The icon set loading method according to claim 1, It is characterized in that The preset compilation tool is used to scan the icon file after the marking process to obtain a set of marked icon elements, including: Creating a logic plug-in through a preset compilation tool, and mounting the logic plug-in to a compiler instance of the compilation tool, wherein the logic plug-in is used to access information in the compiler instance; The icon file after the marking process is scanned by the compilation tool, and all the marked icon elements in the icon file are collected to obtain a marked icon element set.
3. The icon set loading method according to claim 1, It is characterized in that The step of generating a font format file and a cascading style sheet according to the set of marker icon elements includes: The fonts of the mark icon elements in the mark icon element set are converted by using a preset icon font generation tool to obtain a font format file and a cascading style sheet.
4. The icon set loading method according to claim 1, It is characterized in that The class name mapping of all the mark icon elements is performed through the imported font format file to obtain an icon class name mapping table, including: For each mark icon element in the mark icon element set, extract the mark icon class name of the mark icon element through the imported font format file, and generate a random hash value through a preset programming tool; Combining the mark icon class name with the random hash value to generate a target class name; All the target class names are sorted to obtain an icon class name mapping table.
5. The icon set loading method according to claim 4, It is characterized in that The step of replacing the class name of the icon element to be loaded according to the icon class name mapping table to obtain the loading result includes: For each icon element to be loaded, obtaining the icon class name of the icon element to be loaded; Searching the mark icon class name corresponding to the icon class name through the icon class name mapping table; The icon class name of the icon element to be loaded is replaced according to the marked icon class name to obtain a loading result.
6. The icon set loading method according to claim 1, It is characterized in that After replacing the class name of the icon element to be loaded according to the icon class name mapping table to obtain the loading result, the method further includes: Update the marked icon element set according to the loading result to obtain a target icon element set; Performing a difference comparison between the mark icon element set and the target icon element set; If there are differences between the mark icon element set and the target icon element set, newly added icon elements are determined in the target icon element set, and a target font format file is generated according to the newly added icon elements, and the target font format file is introduced into the cascading style sheet.
7. The icon set loading method according to claim 1, It is characterized in that The step of marking the icon element to be loaded in the icon file to obtain the marked icon element includes: Performing a search operation on the icon file to find the icon element to be loaded in the icon file; A marking operation is performed on the icon element to be loaded based on a preset marking character to obtain a marked icon element.
8. An icon set loading device, It is characterized in that The device comprises: A data acquisition module, used to acquire an icon file in an icon library, wherein the icon file includes a plurality of icon elements; A request receiving module, configured to determine, in response to a resource loading request, an icon element to be loaded corresponding to the resource loading request; A marking processing module, used for marking the icon element to be loaded in the icon file to obtain a marked icon element; An element scanning module is used to scan the icon file after the marking process based on a preset compilation tool to obtain a set of marked icon elements; A file generation module, used for generating a font format file and a cascading style sheet according to the mark icon element set, and introducing the font format file into the cascading style sheet; A class name mapping module, used to perform class name mapping on all the mark icon elements through the imported font format file to obtain an icon class name mapping table; The class name replacement module is used to replace the class name of the icon element to be loaded according to the icon class name mapping table to obtain a loading result.
9. An electronic device, It is characterized in that The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the icon set loading method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the icon set loading method according to any one of claims 1 to 7 is implemented.
