Front-end card platform architecture method based on single file page, terminal and storage medium
By encapsulating each card page of the front-end card platform into a single file page and utilizing local storage and CDN hosting resources, the problem of slow loading speed of the front-end card platform is solved, achieving efficient loading and improving user experience.
Patent Information
- Application Number
- CN202410768915.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-09-20
AI Technical Summary
The current front-end card platform needs to load all the resources of the entire project when loading the card page, resulting in high network bandwidth consumption and delay, which affects the user experience, especially in large projects.
Adopting an architecture model based on a single file page, the structure and business functions of each card page are encapsulated in a single HTML file, using local storage to cache initialization data, hosting third-party resources through CDN and image servers, and unifying them through domain name addresses Management and deployment to achieve fast loading and display.
It effectively improves the loading speed of the card platform, reduces the server load, supports independent publishing and reuse, improves development efficiency and system scalability, and ensures the improvement of user experience.
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a front-end card platform architecture method based on a single file page, a front-end card platform architecture terminal based on a single file page and a computer-readable storage medium applying the method. Background Art
[0002] The front-end card platform is a platform that focuses on front-end content display and interaction. It adopts a card-based design concept to present content to users in the form of cards. These cards can contain rich elements such as text, pictures, videos, charts, etc., and support various interactive operations such as clicking, sliding, dragging, etc. The front-end card platform is usually developed based on the front-end framework (such as React, Vue, etc.) to provide flexible and efficient front-end display solutions. Through the card-based design, the front-end card platform can clearly organize and display information, allowing users to quickly find the required content and interact with it. In addition, the front-end card platform also supports dynamic content updates and personalized display, and can make intelligent recommendations and customizations based on user needs and preferences. Therefore, the front-end card platform has been widely used in various websites, applications, large-screen displays and other scenarios and is showing a booming trend.
[0003] As the front-end card platform continues to expand its functions and increase its content, users can access increasingly rich project functions by configuring different card page addresses. However, this growth also brings significant performance challenges. Specifically, when loading each card page, the current card platform must first load all resources of the entire project to which the card page belongs, including images, JavaScript (JS) files, cascading style sheets (CSS), etc. Once all resources are loaded, the system will jump to the user-specified page based on the routing information.
[0004] This loading mechanism is particularly evident for large projects built with frameworks such as Vue and Angular. Even though these projects have been performance optimized, due to the limitations of the loading mechanism, when the business large screen configuration contains multiple card pages (for example, configuring six card pages), even if these card pages are from the same project, the card platform still needs to load the resources of the entire project six times. This not only increases the consumption of network bandwidth, but also causes significant delays and white screen time, seriously affecting the user experience.
[0005] In the current Internet environment, user experience has become one of the key factors that determine the success or failure of a product. Therefore, how to effectively improve the page loading performance of the card platform while maintaining no impact on business projects and compatibility with different technology stacks has become an urgent problem to be solved. This is not only related to the improvement of user experience, but also to the direction of front-end technology development. Summary of the invention
[0006] The main purpose of the present invention is to provide a front-end card platform architecture method, terminal and storage medium based on a single file page, which realizes efficient page loading by quickly loading card resources based on an architecture mode based on a single file page, and effectively improves the loading speed of the card platform.
[0007] To achieve the above object, the present invention provides a front-end card platform architecture method based on a single file page, which includes the following steps:
[0008] Step a. For the card page of the card platform, by setting the page structure and business functions of each card page, and encapsulating it in an HTML single-file page, a card single-page file is obtained;
[0009] Step b. For the initialization data of the card single page file, use the local storage mechanism of the Web browser to cache the data;
[0010] Step c. For third-party resources in the card single page file, use CDN services and image servers for hosting and introduce them in the form of external links;
[0011] Step d. Binding and publishing the card single page file with the business project, or uniformly managing the card single page file through domain name address deployment;
[0012] Step e. Deploy the published card single page file to the corresponding domain name server;
[0013] Step f. By inputting the URL address and parameters of the published card single page file, the configuration of the card in the card platform can be completed, so that the card platform can load and display the corresponding card page.
[0014] Preferably, the step a further comprises:
[0015] Create a card HTML file as a template for the card page and define the basic structure and style of the card HTML file;
[0016] Write or optimize the corresponding business code according to the business functions of the card page, and integrate the business code into the card HTML file;
[0017] Reference or embed the cached data in step b and the third-party resources in step c into the card HTML file;
[0018] Add an iframe tag to the card HTML file.
[0019] Preferably, in step b, using localStorage to cache the initialization data specifically includes:
[0020] Define the query conditions for the data and record a timestamp to track the cache time of the data;
[0021] When the page is first loaded or the user makes a new query, request the data from the server and save the data, query conditions and timestamp to localStorage;
[0022] When the user queries again, the current query conditions are matched with the cached data in localStorage, and the timestamp difference between the current query time and the cache time is calculated based on the timestamp;
[0023] Determine whether the timestamp difference exceeds a preset threshold;
[0024] If the query conditions are consistent and the timestamp difference does not exceed the preset threshold, the localStorage data is used directly;
[0025] If the query condition is inconsistent with the preset query condition, or the timestamp difference exceeds the preset threshold, new data is requested from the server again and the cached data in localStorage is updated.
[0026] Preferably, in step c, the third-party resources include JS, CSS file resources and image resources, and the introduction in the form of external links specifically includes:
[0027] For JS and CSS file resources, replace the file path with the URL after CDN acceleration;
[0028] For image resources, replace the src attribute of the image tag with the URL on the CDN or image hosting server;
[0029] The third-party resource is a core library or a core module in a third-party library.
[0030] Preferably, the step d further comprises:
[0031] Create a Webpack configuration file in the root directory of the business project to perform Webpack packaging operations on the card single page files;
[0032] Add the Webpack packaged files to the dist static file directory of the business project;
[0033] Upload the files in the dist static file directory to the server or static file hosting service through a deployment tool or script.
[0034] Preferably, the step f further comprises:
[0035] Obtain the URL address of the card single page file input by the user, and identify the actual location of the card single page file by parsing the URL address;
[0036] Extract the parameters contained in the URL address, parse the parameters, and customize the display mode and content of the card according to the parameter values;
[0037] Use the parsed URL address to send an HTTP request to the server to obtain the content of the card single page file;
[0038] Parse the server's response content and insert it into the card platform's DOM model.
[0039] Preferably, the method further includes inserting a new card into the card platform, specifically including:
[0040] Execute steps a to c to create a new card and obtain a new card single-page file;
[0041] Step d1. Identify the existing business projects in the card platform, and determine the business projects to be integrated with the new card single-page file, bind and publish the new card single-page file with the business project to be integrated, and update the configuration file of the business project to be integrated;
[0042] Step e1. Deploy the new card single page file to the corresponding domain name server and update the routing configuration of the card platform;
[0043] Step f1. By inputting the URL address and parameters of the new card single page file, the corresponding card page is loaded and displayed, and the layout of the card platform is adaptively adjusted.
[0044] Preferably, the method further includes performing card replacement in the card platform, specifically including:
[0045] Execute steps a to c to create a new card to be replaced, and obtain a new card single-page file;
[0046] Step d2. Confirm the original card to be replaced, unbind the original card single-page file from the business project in the card platform, bind and publish the new card single-page file with the business project, and update the configuration file of the business project;
[0047] Step e2. Deploy the new card single page file to the corresponding domain name server and update the routing configuration of the card platform;
[0048] Step f2. By inputting the URL address and parameters of the new card single page file, the corresponding card page is loaded and displayed, and the cached data in the original card is migrated to the new card or cleared.
[0049] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, which includes a memory, a processor, and a front-end card platform architecture program based on a single file page stored in the memory and executable on the processor, and the front-end card platform architecture program based on a single file page, when executed by the processor, implements the steps of the front-end card platform architecture method based on a single file page as described above.
[0050] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, on which a front-end card platform architecture program based on a single file page is stored. When the front-end card platform architecture program based on a single file page is executed by a processor, the steps of the front-end card platform architecture method based on a single file page as described above are implemented.
[0051] The beneficial effects of the present invention are:
[0052] (1) The present invention adopts a card page based on a single HTML file. By encapsulating the page structure and business functions of each card page in a single HTML file, it is compatible with project technology stacks of different frameworks, supports independent publishing without affecting the project, and does not cause the performance of the card platform page to slow down as the complexity of the project increases. It can also effectively improve the loading speed of the card platform;
[0053] (2) The present invention is based on single-file page development, and independently develops the card pages of independent business projects into single-file pages. Each single-file page contains complete business logic and style, ensuring complete functions and unified style. These single-file pages can be normally accessed by domain name plus path, providing a basis for subsequent card platform integration;
[0054] (3) The present invention uses the local storage mechanism of the Web browser to cache the initialization data of the card single-page file, and uses CDN (content distribution network) services and image servers to host third-party resources (such as pictures, fonts, scripts, etc.) referenced in the card single-page file, and introduces them in the form of external links, thereby reducing the data transmission pressure of the server, ensuring the efficient and stable loading of these resources, and improving the scalability of the overall system;
[0055] (4) The present invention can realize flexible configuration and reuse of cards by binding and publishing single-page card files with business projects, or managing them uniformly through domain name addresses, and enables different business projects to share the same set of card templates, thereby improving development efficiency;
[0056] (5) The present invention adds an iframe tag to the card HTML file, so that complex functions or pages can be embedded into the card as independent units without the need to reconstruct the entire card page, thereby increasing the flexibility and scalability of the card;
[0057] (6) The present invention tracks the cache time of data by setting a timestamp and a preset threshold, so that developers can flexibly control the cache validity period of data; and when a large number of users access the same data, since the data is still valid in the local cache (that is, the timestamp difference does not exceed the preset threshold), the data can be directly read from localStorage without requesting the data from the server again, so the server request volume will be greatly reduced, thereby reducing the server load;
[0058] (7) The present invention creates a Webpack configuration file in the root directory of the business project, which can easily define packaging rules, plug-in configuration, etc., to achieve automated construction; and through Webpack packaging, multiple functional components can be packaged into an independent card single-page file, which not only improves the security of resources, but also facilitates reuse and management, making the code easier to expand and maintain. When it is necessary to add new functions or modify existing functions, only the corresponding modules or components need to be modified;
[0059] (8) The solution of the present invention can quickly create and insert new cards in the card platform without large-scale modification of the entire platform, thereby increasing the flexibility and scalability of the platform. By updating the configuration files of the business items and the routing configuration of the card platform, it ensures that the new cards can be seamlessly integrated into the existing system, supports the rapid launch of new functions, and is conducive to business development and innovation.
[0060] (9) The present invention ensures the continuity of business logic by unbinding the original card single-page file from the business project in the card platform and binding and publishing the new card single-page file to the business project; in addition, the cache data in the original card is migrated to the new card, ensuring the continuity and availability of data, which is of great significance for maintaining the consistency and integrity of user data;
[0061] (10) The present invention is based on the front-end microservice architecture model. In the entire front-end card platform, the card platform is an independent service, and the card pages configured in the platform are also separate services. Each card page has a unique address and supports independent operation without interfering with other card pages. DETAILED DESCRIPTION
[0062] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the following will be clearly and completely described in combination with the specific technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0063] The present invention independently develops the page embedded in the card platform into a single file page, so that the card page can be normally accessed by domain name plus path, and then the card platform can set the corresponding card accessible path address when configuring different project cards. The method of configuring the card page in this way can effectively solve the problem that the loaded page will not slow down as the project volume increases; at the same time, combined with data cache, high-performance loading of the card platform page is achieved. The specific implementation scheme is as follows:
[0064] First embodiment (card platform architecture method):
[0065] This embodiment provides a front-end card platform architecture method based on a single file page, which includes the following steps:
[0066] Step a. For the card page of the card platform, by setting the page structure and business functions of each card page and encapsulating it in an HTML single-file page, a card single-page file is obtained;
[0067] Step b. For the initialization data of the card single page file, use the local storage mechanism of the Web browser to cache the data;
[0068] Step c. For third-party resources in the card single page file, use CDN services and image servers for hosting and introduce them in the form of external links;
[0069] Step d. Binding and publishing the card single page file with the business project, or uniformly managing the card single page file through domain name address deployment;
[0070] Step e. Deploy the published card single page file to the corresponding domain name server;
[0071] Step f. By inputting the URL address and parameters of the published card single page file, the configuration of the card in the card platform can be completed, so that the card platform can load and display the corresponding card page.
[0072] In this embodiment, the card page of the card platform is embedded based on iframe, and all the business codes of the card page in the project are written into a single html file page so that it can run independently. Specifically, the step a further includes:
[0073] Create a card HTML file as a template for the card page and define the basic structure and style of the card HTML file;
[0074] Write or optimize the corresponding business code according to the business functions of the card page, and integrate the business code into the card HTML file;
[0075] Reference or embed the cached data in step b and the third-party resources in step c into the card HTML file;
[0076] Add an iframe tag to the card HTML file.
[0077] The iframe (Inline Frame) tag is used to embed another HTML document in the current HTML document. The iframe can be used as an inline frame to display the content of another page inside the current page without having to jump to a new page.
[0078] The iframe tag includes the following attributes:
[0079] src attribute: specifies the URL of the page to be embedded;
[0080] frameborder attribute: specifies whether to display the border of the iframe. Setting it to "0" is usually used to hide the border.
[0081] scrolling attribute: specifies whether the iframe displays a scroll bar, which can be set to "yes", "no", or "auto";
[0082] Width and height attributes: specify the width and height of the iframe respectively, either in pixels (such as "800px") or in percentages.
[0083] Based on the iframe card platform, the content within each iframe is isolated from its parent page and other iframe content, which helps prevent cross-site scripting attacks (XSS) and other security issues; iframe allows content from different sources to be embedded in the same page without being restricted by the same-origin policy; each iframe can load its content independently without blocking the loading of the main page or other iframes; the card platform can independently develop and update card pages without modifying the main application or website.
[0084] Therefore, the iframe-based card platform can provide a flexible way to embed card pages from different sources while maintaining the isolation between the main page and the card page. This is very useful for platforms that need to integrate card content from multiple different services or teams.
[0085] In this embodiment, in step b, localStorage is used to cache the initialization data, which specifically includes:
[0086] Define the query conditions for the data and record a timestamp to track the cache time of the data;
[0087] When the page is first loaded or the user makes a new query, request the data from the server and save the data, query conditions and timestamp to localStorage;
[0088] When the user queries again, the current query conditions are matched with the cached data in localStorage, and the timestamp difference between the current query time and the cache time is calculated based on the timestamp;
[0089] Determine whether the timestamp difference exceeds a preset threshold;
[0090] If the query conditions are consistent and the timestamp difference does not exceed the preset threshold, the localStorage data is used directly;
[0091] If the query condition is inconsistent with the preset query condition, or the timestamp difference exceeds the preset threshold, new data is requested from the server again and the cached data in localStorage is updated.
[0092] Among them, localStorage is an API provided by the web browser, which allows you to store key-value data in the user's browser. This data is persistent and will not be lost even if the page is closed or the browser is restarted. When saving data to localStorage, you need to convert the data into a string format and use the localStorage.setItem() method to save the data to localStorage.
[0093] In this embodiment, in step c, the third-party resources include JS, CSS file resources and image resources, and the introduction in the form of external links specifically includes:
[0094] For JS and CSS file resources, replace the file path with the URL after CDN acceleration;
[0095] For image resources, replace the src attribute of the image tag with the URL on the CDN or image hosting server;
[0096] The third-party resource is a core library or a core module in a third-party library.
[0097] Since the business of the card page only uses part of the functions and features of the third-party library, the introduced third-party js, css and other libraries are adjusted to introduce core libraries or core modules to make the resource volume loaded by the single card page small enough.
[0098] Among them, the external link forms specifically include the following:
[0099] Anchor Text Link:
[0100] An anchor text link is a link that uses a keyword or phrase to point to a page or resource. For example, embedding a link in the text such as "Click here to see more pictures", where "Click here" is the anchor text, which links to the page or resource containing the picture.
[0101] Hyperlink:
[0102] A hyperlink is a connection from a web page to a target, which can be another web page or other types of resources (such as JS, CSS files or pictures). This type of link can usually be accessed directly by clicking on it.
[0103] Plain Text Link:
[0104] A plain text link has only the URL but no hyperlink text. That is, the URL text is displayed directly, but the page or resource pointed to cannot be reached by directly clicking. Users need to manually copy and paste it into the address bar of the browser to access it.
[0105] Image Link:
[0106] Image links are images that are used as links. When you click on an image, it will jump to a specified page or resource. Although images themselves can contain links, search engines usually cannot directly identify the image content, but rely on the image's alt attribute or surrounding text for identification.
[0107] CSS External Links:
[0108] For CSS file resources, the external link form is usually through <link> The tag references an external CSS file in the HTML document section, or through the @import rule in <style>标签内导入外部CSS文件。
[0109] 本实施例中,对于CSS文件资源,采用<link>标签作为优选的引用方式,并且在页面加载时并行下载CSS文件,提高页面加载速度;对于图片和JS文件资源,使用超链接形式进行引用。
[0110] 本实施例中,所述步骤d进一步包括:
[0111] 在业务项目的根目录下创建Webpack配置文件,用于对卡片单页文件执行Webpack打包操作;
[0112] 将Webpack打包后文件加入到业务项目的dist静态文件目录;
[0113] 通过部署工具或脚本将dist静态文件目录中的文件上传到服务器或静态文件托管服务。
[0114] 其中,Webpack是一个静态模块打包器,支持JavaScript、CSS、图片等资源的打包。Webpack将所有模块及其依赖项视为静态资源,并创建一个依赖关系图,将这些资源转换为有效的输出文件。Webpack配置文件通常称为webpack.config.js,用于定义Webpack的打包规则和行为,具体包括:入口(Entry):用于指定Webpack应该从哪个模块开始构建依赖图;出口(Output):用于指定Webpack构建完成后输出的文件名和目录;模块规则(ModuleRules):用于定义Webpack如何处理不同类型的文件(如JavaScript、CSS、图片等)。
[0115] 在项目中,dist静态文件目录即"distribution"(发布)目录,用于存放最终的构建产物(即打包后的文件)。Webpack打包后的文件(如压缩后的JavaScript、CSS文件,以及图片等静态资源)会被放置在该dist静态文件目录中。
[0116] 本实施例中,所述步骤e中,发布卡片单页文件到对应的域名服务器,使当前卡片html单页可以通过域名地址加路径的方式访问,地址格式为:www.xxxx.com / xxx / xxx.html,采用该地址形式替换传统的vue,angular框架等项目的路由地址形式,具有更好的加载性能、兼容性、独立性。
[0117] 本实施例中,所述步骤f进一步包括:
[0118] 获取用户输入的卡片单页文件的URL地址,并通过解析该URL地址识别出卡片单页文件的实际位置;
[0119] 提取URL地址中包含的参数,并通过解析该参数以及根据参数值定制卡片的显示方式和显示内容;
[0120] 使用解析后的URL地址发送HTTP请求到服务器,以获取卡片单页文件的内容;
[0121] 解析服务器的响应内容,并将其插入到卡片平台的DOM模型中。
[0122] 所述DOM模型,即文档对象模型(Document Object Model,简称DOM),是W3C组织推荐的处理可扩展置标语言(如HTML和XML)的标准编程接口,是一种与平台和语言无关的应用程序接口(API)。
[0123] DOM模型将文档(如HTML或XML文件)抽象为一个由节点和对象组成的树形结构,树形结构中的每个节点(Node)都代表了文档中的一个部分,比如一个HTML元素、一个文本片段或一个属性。节点之间的关系构成了文档的层次结构,例如父子关系、兄弟关系等。
[0124] 本实施例中,将服务器的响应内容插入到卡片平台的DOM模型中,是指从服务器获取HTML、XML或其他类型的文档数据,并使用DOM API将其解析为DOM树形结构;然后,通过使用DOM API遍历所述DOM树形结构,找到需要插入卡片内容的位置,并将卡片内容作为新的节点或子节点添加到DOM树中,最后,浏览器就会根据更新后的DOM树形结构重新渲染页面,显示出包含卡片内容的完整页面。
[0125] 采用本实施例的方案,不论是添加新卡片,还是替换原卡片,都能良好兼容现有卡片平台,并且不影响项目业务,还能有效解决卡片平台加载过程性能慢的问题,实现卡片平台页面快速加载,有效提升客户体验。
[0126] 第二实施例(卡片平台升级方法-插入新卡片):
[0127] 在第一实施例的基础上,本实施例还包括在卡片平台中插入新卡片,具体包括:
[0128] 执行步骤a至步骤c进行新卡片的创建,得到新的卡片单页文件;
[0129] 步骤d1.识别卡片平台中已有的业务项目,并确定新的卡片单页文件待集成的业务项目,将新的卡片单页文件与待集成的业务项目进行绑定和发布,并更新待集成的业务项目的配置文件;
[0130] 步骤e1.将新的卡片单页文件部署到对应的域名服务器,并更新卡片平台的路由配置;
[0131] 步骤f1.通过输入新的卡片单页文件的URL地址及其参数,加载并展示对应的卡片页面,并对卡片平台的布局进行适应性调整。
[0132] 本实施例的其余内容与第一实施例基本相似,在此不进行赘述。
[0133] 第三实施例(卡片平台升级方法-替换原卡片):
[0134] 在第一实施例的基础上,本实施例还包括在卡片平台中进行卡片替换,具体包括:
[0135] 执行步骤a至步骤c进行待替换的新卡片的创建,得到新的卡片单页文件;
[0136] 步骤d2.确认待替换的原卡片,并将原卡片单页文件与卡片平台中的业务项目解除绑定,将新的卡片单页文件与所述业务项目进行绑定和发布,并更新业务项目的配置文件;
[0137] 步骤e2.将新的卡片单页文件部署到对应的域名服务器,并更新卡片平台的路由配置;
[0138] 步骤f2.通过输入新的卡片单页文件的URL地址及其参数,加载并展示对应的卡片页面,并将原卡片中的缓存数据迁移到新卡片中或者进行清理。
[0139] 本实施例的其余内容与第一实施例基本相似,在此不进行赘述
[0140] 第四实施例(一种终端):
[0141] 本实施例还提供一种终端,所述终端包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的基于单文件页面的前端卡片平台架构程序,所述基于单文件页面的前端卡片平台架构程序被所述处理器执行时实现如上文所述的基于单文件页面的前端卡片平台架构方法的步骤,详细可以参见上述实施例中的相关记载,此处不再赘述。
[0142] 所述终端包括:手机、数码相机或平板电脑等具有拍照功能的终端,或者具有基于单文件页面的前端卡片平台架构功能的终端,或者具有图文显示功能的终端。所述终端可包括存储器、处理器、输入单元、显示单元、电源等部件。
[0143] 其中,存储器可用于存储软件程序以及模块,处理器通过运行存储在存储器的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作终端、至少一个功能所需的应用程序(例如图像播放功能等)等;存储数据区可存储根据终端的使用所创建的数据等。此外,存储器可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器还可以包括存储器控制器,以提供处理器和输入单元对存储器的访问。
[0144] 输入单元可用于接收输入的数字或字符或图像信息,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。具体地,本实施例的输入单元除了包括摄像头,还可包括触敏表面(例如触摸显示屏)以及其他输入终端。
[0145] 显示单元可用于显示由用户输入的信息或提供给用户的信息以及终端的各种图形用户接口,这些图形用户接口可以由图形、文本、图标、视频和其任意组合来构成。显示单元可包括显示面板,可选的,可以采用LCD(Liquid Crystal Display,液晶显示器)、OLED(Organic Light-Emitting Diode,有机发光二极管)等形式来配置显示面板。进一步的,触敏表面可覆盖显示面板,当触敏表面检测到在其上或附近的触摸操作后,传送给处理器以确定触摸事件的类型,随后处理器根据触摸事件的类型在显示面板上提供相应的视觉输出。
[0146] 第五实施例(一种计算机可读存储介质):
[0147] 本实施例还提供了一种计算机可读存储介质,该计算机可读存储介质可以是上述实施例中的存储器中所包含的计算机可读存储介质;也可以是单独存在,未装配入终端中的计算机可读存储介质。该计算机可读存储介质中存储有至少一条指令,所述指令由处理器加载并执行以实现基于单文件页面的前端卡片平台架构方法。所述计算机可读存储介质可以是只读存储器,磁盘或光盘等。
[0148] 需要说明的是,本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。对于终端实施例及存储介质实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
[0149] 并且,在本文中,术语"包括”、"包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端所固有的要素。在没有更多限制的情况下,由语句"包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端中还存在另外的相同要素。
[0150] 上述说明示出并描述了本发明的优选实施例,应当理解本发明并非局限于本文所披露的形式,不应看作是对其他实施例的排除,而可用于各种其他组合、修改和环境,并能够在本文发明构想范围内,通过上述教导或相关领域的技术或知识进行改动。而本领域人员所进行的改动和变化不脱离本发明的精神和范围,则都应在本发明所附权利要求的保护范围内。< / style>
Claims
1. A front-end card platform architecture method based on a single file page, It is characterized in that The following steps are involved: Step a. For the card page of the card platform, by setting the page structure and business functions of each card page, and encapsulating it in an HTML single-file page, a card single-page file is obtained; Step b. For the initialization data of the card single page file, use the local storage mechanism of the Web browser to cache the data; Step c. For third-party resources in the card single page file, use CDN services and image servers for hosting and introduce them in the form of external links; Step d. Binding and publishing the card single page file with the business project, or uniformly managing the card single page file through domain name address deployment; Step e. Deploy the published card single page file to the corresponding domain name server; Step f. By inputting the URL address and parameters of the published card single page file, the configuration of the card in the card platform can be completed, so that the card platform can load and display the corresponding card page.
2. According to claim 1, a front-end card platform architecture method based on a single file page, It is characterized in that The step a further comprises: Create a card HTML file as a template for the card page and define the basic structure and style of the card HTML file; Write or optimize the corresponding business code according to the business functions of the card page, and integrate the business code into the card HTML file; Reference or embed the cached data in step b and the third-party resources in step c into the card HTML file; Add an iframe tag to the card HTML file.
3. According to the front-end card platform architecture method based on a single file page according to claim 1, It is characterized in that In the step b, localStorage is used to cache the initialization data, specifically including: Define the query conditions for the data and record a timestamp to track the cache time of the data; When the page is first loaded or the user makes a new query, request the data from the server and save the data, query conditions and timestamp to localStorage; When the user queries again, the current query conditions are matched with the cached data in localStorage, and the timestamp difference between the current query time and the cache time is calculated based on the timestamp; Determine whether the timestamp difference exceeds a preset threshold; If the query conditions are consistent and the timestamp difference does not exceed the preset threshold, the localStorage data is used directly; If the query condition is inconsistent with the preset query condition, or the timestamp difference exceeds the preset threshold, new data is requested from the server again and the cached data in localStorage is updated.
4. According to the front-end card platform architecture method based on a single file page according to claim 1, It is characterized in that In step c, the third-party resources include JS, CSS file resources and image resources, and the introduction in the form of external links specifically includes: For JS and CSS file resources, replace the file path with the URL after CDN acceleration; For image resources, replace the src attribute of the image tag with the URL on the CDN or image hosting server; The third-party resource is a core library or a core module in a third-party library.
5. According to the front-end card platform architecture method based on a single file page according to claim 1, It is characterized in that The step d further comprises: Create a Webpack configuration file in the root directory of the business project to perform Webpack packaging operations on the card single page files; Add the Webpack packaged files to the dist static file directory of the business project; Upload the files in the dist static file directory to the server or static file hosting service through a deployment tool or script.
6. A front-end card platform architecture method based on a single file page according to claim 1, It is characterized in that The step f further comprises: Obtain the URL address of the card single page file input by the user, and identify the actual location of the card single page file by parsing the URL address; Extract the parameters contained in the URL address, parse the parameters, and customize the display mode and content of the card according to the parameter values; Use the parsed URL address to send an HTTP request to the server to obtain the content of the card single page file; Parse the server's response content and insert it into the card platform's DOM model.
7. A front-end card platform architecture method based on a single file page according to any one of claims 1 to 6, It is characterized in that It also includes inserting new cards into the card platform, including: Execute steps a to c to create a new card and obtain a new card single-page file; Step d1. Identify the existing business projects in the card platform, and determine the business projects to be integrated with the new card single-page file, bind and publish the new card single-page file with the business project to be integrated, and update the configuration file of the business project to be integrated; Step e1. Deploy the new card single page file to the corresponding domain name server and update the routing configuration of the card platform; Step f1. By inputting the URL address and parameters of the new card single page file, the corresponding card page is loaded and displayed, and the layout of the card platform is adaptively adjusted.
8. A front-end card platform architecture method based on a single file page according to any one of claims 1 to 6, It is characterized in that It also includes card replacement in the card platform, including: Execute steps a to c to create a new card to be replaced, and obtain a new card single-page file; Step d2. Confirm the original card to be replaced, unbind the original card single-page file from the business project in the card platform, bind and publish the new card single-page file with the business project, and update the configuration file of the business project; Step e2. Deploy the new card single page file to the corresponding domain name server and update the routing configuration of the card platform; Step f2. By inputting the URL address and parameters of the new card single page file, the corresponding card page is loaded and displayed, and the cached data in the original card is migrated to the new card or cleared.
9. A terminal, It is characterized in that The terminal includes a memory, a processor, and a front-end card platform architecture program based on a single file page stored in the memory and executable on the processor. When the front-end card platform architecture program based on a single file page is executed by the processor, the steps of the front-end card platform architecture method based on a single file page are implemented as described in any one of claims 1 to 8.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a front-end card platform architecture program based on a single file page, and when the front-end card platform architecture program based on a single file page is executed by a processor, the steps of the front-end card platform architecture method based on a single file page as described in any one of claims 1 to 8 are implemented.
