CN111625239B - Method and device for updating virtual page instance state in SPA - Google Patents

Method and device for updating virtual page instance state in SPA Download PDF

Info

Publication number
CN111625239B
CN111625239B CN202010388536.0A CN202010388536A CN111625239B CN 111625239 B CN111625239 B CN 111625239B CN 202010388536 A CN202010388536 A CN 202010388536A CN 111625239 B CN111625239 B CN 111625239B
Authority
CN
China
Prior art keywords
instance
virtual page
spa
memory
page instance
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010388536.0A
Other languages
Chinese (zh)
Other versions
CN111625239A (en
Inventor
唐溢泓
崔伟毅
傅腾
徐啸
胡鹏
彭茜
杨雯雯
王俊龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Renke Interactive Network Technology Co Ltd
Original Assignee
Beijing Renke Interactive Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Renke Interactive Network Technology Co Ltd filed Critical Beijing Renke Interactive Network Technology Co Ltd
Priority to CN202010388536.0A priority Critical patent/CN111625239B/en
Publication of CN111625239A publication Critical patent/CN111625239A/en
Application granted granted Critical
Publication of CN111625239B publication Critical patent/CN111625239B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The embodiment of the invention provides a method and a device for updating a virtual page instance state in an SPA, wherein the method comprises the following steps: receiving a page request of a user, and creating a virtual page instance of the SPA; receiving a real-time detection result of a memory monitor device in the SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; if the intermediate input of the user is received, the notification service device in the command SPA issues a state update message to the virtual page instance of the subscription notification service, and the state of the virtual page instance of the subscription notification service is updated according to the storage mode of the virtual page instance of the subscription notification service. The method and the device provided by the embodiment of the invention realize that the states of all the virtual page instances in the SPA are updated no matter the storage mode of the virtual page instances, and the storage of the virtual page instances in the SPA reasonably utilizes the memory.

Description

Method and device for updating virtual page instance state in SPA
Technical Field
The invention relates to the technical field of single-page application programs, in particular to a method and a device for updating virtual page instance states in an SPA.
Background
In modern business single page applications, complex situations cannot be avoided, and more user interactions will result in more memory usage. In particular, all resources of the mobile device are limited and memory is shared with all running applications/Operating Systems (OS).
In a Single Page Application (SPA), where all UIs are in one browser window, there is no benefit from OS memory management, if there is insufficient system memory to support SPA to remain in the correct state, the SPA may crash and the end user may not get a better user experience. From the perspective of the browser, it can only trigger garbage collection when the memory is insufficient, but there is no help to the fact that the SPA must use more memory but cannot perform garbage collection.
One problem with the current SPA is that the pages that can be stored in the memory are limited, so some pages need to be stored in other locations except the memory, and when the content of a certain page needs to be updated due to the user operation, the corresponding content of all pages associated with the page needs to be updated, but the existing SPA only supports updating the pages that are stored in the memory and associated with the page, and the state of the pages stored in other memories that are not memory cannot be updated in real time.
Therefore, how to avoid the situation that the update of the state of all the virtual page instances in the existing SPA is limited by the storage location and the storage of the virtual page instances in the SPA does not reasonably utilize the memory is still a problem to be solved by those skilled in the art.
Disclosure of Invention
The embodiment of the invention provides a method and a device for updating the state of a virtual page instance in an SPA, which are used for updating the state of all virtual page instances in the SPA no matter what the storage mode of the virtual page instance is, and the storage of the virtual page instance in the SPA reasonably utilizes the memory.
In a first aspect, an embodiment of the present invention provides a method for updating a virtual page instance state in an SPA, including:
receiving a page request of a user, and creating a virtual page instance of the SPA;
receiving a real-time detection result of a memory monitor device in the SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage;
if the intermediate input of the user is received, the notification service device in the command SPA issues a state update message to the virtual page instance of the subscription notification service, and the state of the virtual page instance of the subscription notification service is updated according to the storage mode of the virtual page instance of the subscription notification service.
Preferably, in the method, the creating a virtual page instance of the SPA specifically includes:
if the page request is not instantiated, a first UI style instance and a first UI domain instance are created by a download resource, a first state data instance matched with the first UI style instance and the first UI domain instance is constructed, a virtual page instance is created based on the first UI style instance, the first UI domain instance and the first state data instance, and the resource comprises a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in an external memory, recovering UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in the background internal memory, the virtual page instance is directly switched to.
Preferably, in the method, the receiving the real-time detection result of the memory monitor device in the SPA determines a storage mode of the virtual page instance, where the storage mode includes foreground internal memory storage, background internal memory storage and external memory storage, and specifically includes:
if the virtual page instance is the instance being used by the user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor device in the SPA is that the system has an internal memory shortage warning or the number of virtual page instances in the internal memory exceeds a preset threshold.
Preferably, in the method, the storing the virtual page instance by using an external memory specifically includes:
determining an external memory type based on the application platform;
splitting the virtual page instance into UI domain data and state data;
storing the UI domain data and state data into the external memory;
clearing the associated information of the virtual page instance from an internal memory;
the determining the type of the external memory based on the application platform specifically comprises the following steps:
if the application platform is a browser, the type of the external memory is a local memory or an index database;
if the application platform is a hybrid mobile application, the external memory is a local memory.
Preferably, in the method, if the intermediate input of the user is received, the command SPA instructs the notification service device to issue a status update message to the virtual page instance subscribed to the notification service, and updates the status of the virtual page instance subscribed to the notification service according to the storage mode of the virtual page instance subscribed to the notification service, including:
if the virtual page instance of the subscription notification service is stored in the foreground internal memory, updating UI domain data, state data and UI rendering of the virtual page instance of the subscription notification service based on the intermediate input;
If the virtual page instance subscribed to the notification service is stored in the background internal memory or the external memory, the UI domain data and the state data of the virtual page instance are updated based on the intermediate input, and UI rendering update is not needed.
In a second aspect, an embodiment of the present invention provides an apparatus for updating a state of a virtual page instance in an SPA, where the apparatus is characterized by including:
the receiving unit is used for creating a virtual page instance of the SPA;
the allocation unit is used for receiving the real-time detection result of the memory monitor device in the SPA and determining the storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage;
and the updating unit is used for commanding the notification service device in the SPA to issue a state update message to the virtual page instance of the subscription notification service if the intermediate input of the user is received, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
Preferably, in the apparatus, the creating a virtual page instance of the SPA specifically includes:
if the page request is not instantiated, a first UI style instance and a first UI domain instance are created by a download resource, a first state data instance matched with the first UI style instance and the first UI domain instance is constructed, a virtual page instance is created based on the first UI style instance, the first UI domain instance and the first state data instance, and the resource comprises a UI domain model, a virtual page js and a virtual page style;
If the page request is instantiated and the virtual page instance corresponding to the page request is stored in an external memory, recovering UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in the background internal memory, the virtual page instance is directly switched to.
Preferably, in the device, the blending unit is specifically configured to:
if the virtual page instance is the instance being used by the user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
If the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor device in the SPA is that the system has an internal memory shortage warning or the number of virtual page instances in the internal memory exceeds a preset threshold.
In a third aspect, an embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the steps of the method for updating a virtual page instance state in an SPA as provided in the first aspect when the program is executed.
In a fourth aspect, embodiments of the present invention provide a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a method for updating virtual page instance states in an SPA as provided in the first aspect.
The method and the device provided by the embodiment of the invention establish the virtual page instance of the SPA when receiving the page request of the user; then determining a storage mode of the virtual page instance according to a real-time detection result of the memory monitor device in the SPA, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; when the intermediate input of the user is received, the notification service device in the SPA is instructed to issue a state update message to the virtual page instance of the subscription notification service, and the state of the virtual page instance of the subscription notification service is updated according to the storage mode of the virtual page instance of the subscription notification service. Therefore, the purpose of allocating the virtual page instance stored in the internal memory or the external memory and updating the virtual page of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service can be achieved. Therefore, the method and the device provided by the embodiment of the invention realize that the states of all the virtual page instances in the SPA are updated no matter how the virtual page instances are stored, and the memory is reasonably utilized by the storage of the virtual page instances in the SPA.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description will be given below of the drawings required for the embodiments or the prior art descriptions, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart illustrating a method for updating a virtual page instance state in an SPA according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of creating a virtual page instance according to an embodiment of the present invention;
FIG. 3 is a storage state transition diagram of a virtual page instance according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus for updating a virtual page instance state in an SPA according to an embodiment of the present invention;
fig. 5 is a schematic diagram of an entity structure of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without any inventive effort, are intended to be within the scope of the invention.
The update of the state of all virtual page instances in the existing SPA is limited by the storage position, and the storage of the virtual page instances in the SPA has no problem of reasonably utilizing the memory. In this regard, the embodiment of the invention provides a method for updating the state of a virtual page instance in an SPA. Fig. 1 is a flow chart of a method for updating a virtual page instance state in an SPA according to an embodiment of the present invention, as shown in fig. 1, an execution body of the method is a device in the SPA, and the method includes:
step 110, receiving a page request of a user, and creating a virtual page instance of the SPA.
Specifically, when a device (which may be referred to as a navigation container device) in the SPA that updates the status of a virtual page instance receives a user's page request, the device first creates a virtual page instance corresponding to the page request. For virtual page instances in the SPA, three types are classified: the first type of virtual page instance is stored in the foreground internal memory, i.e. the virtual page instance is visible on the application of the current screen; the second type of virtual page instance is stored in the background internal memory, is invisible in the current application state, but is usually closely related to the page displayed by the current application, such as the previous page or the next page of the current page, and also exists in the internal memory for fast switching with the current page; the third type of virtual page instance is stored in external memory, belonging to the type of virtual page instance that is not always requested by the user. When a page request of a user occurs, the device for updating the state of the virtual page instance in the SPA creates a corresponding virtual page instance according to the condition whether the page request is instantiated or not, and if the page request is not instantiated, the download resource creates the virtual page instance; if the page request is instantiated, the virtual page instance is restored from the stored data content of the instantiated virtual page instance.
And 120, receiving a real-time detection result of the memory monitor device in the SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage.
Specifically, to determine the storage mode of the virtual page instance, the state of the internal memory needs to be considered, the state of the internal memory is monitored in real time by the memory monitor device in the SPA, if the virtual page instance is an instance being used by a user, the storage mode of the virtual page instance is foreground internal memory storage, if the virtual page instance is not an instance being used by a user but the internal memory space is sufficient, the storage mode of the virtual page instance is background internal memory storage, and if the virtual page instance is not an instance being used by a user and the internal memory space is insufficient, the storage mode of the virtual page instance is external memory storage. Therefore, the device for updating the state of the virtual page instance in the SPA allocates the virtual page instance among the storage locations according to the real-time occupied state of the memory.
Step 130, if the intermediate input of the user is received, the notification service device in the SPA is instructed to issue a status update message to the virtual page instance subscribed to the notification service, and update the status of the virtual page instance subscribed to the notification service according to the storage mode of the virtual page instance subscribed to the notification service.
Specifically, when an intermediate input of the user is received, where the intermediate input includes the user inputting in a certain input box of the current page or clicking a certain link of the current page, the device for updating the state of the virtual page instance in the SPA instructs the notification service device in the SPA to issue a state update message to the virtual page instance subscribed to the notification service. It should be noted that, at present, all virtual page instances are subscribed to the notification service when initially created by default, and the subscription state of the virtual page instance does not change with the transition of its storage mode. Then, the device for updating the state of the virtual page instance in the SPA updates the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service, and the storage contents of the virtual page instances stored in different storage modes are different, so that when the state of the virtual page instance is updated, different contents of the virtual page instance can be updated due to the storage mode of the different virtual page instances, for example, the virtual page instance stored in the foreground internal memory is necessarily rendered due to the fact that the virtual page instance is being displayed, and the UI rendering needs to be updated when the virtual page instance stored in the background internal memory and the external memory is not displayed and therefore does not need to be updated.
According to the method provided by the embodiment of the invention, when the page request of the user is received, the virtual page instance of the SPA is created; then determining a storage mode of the virtual page instance according to a real-time detection result of the memory monitor device in the SPA, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; when the intermediate input of the user is received, the notification service device in the SPA is instructed to issue a state update message to the virtual page instance of the subscription notification service, and the state of the virtual page instance of the subscription notification service is updated according to the storage mode of the virtual page instance of the subscription notification service. Therefore, the purpose of allocating the virtual page instance stored in the internal memory or the external memory and updating the virtual page of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service can be achieved. Therefore, the method provided by the embodiment of the invention realizes that the states of all the virtual page instances in the SPA are updated no matter how the virtual page instances are stored, and the memory is reasonably utilized by the storage of the virtual page instances in the SPA.
Based on the foregoing embodiment, in the method, the creating a virtual page instance of the SPA specifically includes:
if the page request is not instantiated, a first UI style instance and a first UI domain instance are created by a download resource, a first state data instance matched with the first UI style instance and the first UI domain instance is constructed, a virtual page instance is created based on the first UI style instance, the first UI domain instance and the first state data instance, and the resource comprises a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in an external memory, recovering UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in the background internal memory, the virtual page instance is directly switched to.
Specifically, fig. 2 is a schematic flow chart of creating a virtual page instance, as shown in fig. 2, firstly creating a virtual page corresponding to a page request, if the virtual page is instantiated, that is, if the page request is instantiated, downloading a resource, creating a first UI style instance and a first UI domain instance by using the resource, constructing a first state data instance matched with the first UI style instance and the first UI domain instance, and finally creating a virtual page instance based on the first UI style instance, the first UI domain instance and the first state data instance, wherein the resource includes a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in an external memory, restoring the page from the external memory, namely replying to UI domain data and state data in page content, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and finally creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
If the page request is instantiated and the virtual page instance corresponding to the page request is stored in the background internal memory, the virtual page instance is directly switched to.
Here, the constitution of a virtual page is described, and a virtual page can be split into a UI domain model, a virtual page model, a data model and a style, wherein the UI domain model is used for HTML rendering domain language, the main functions of which are serializable, and the data and event listener can be set through a binding mechanism; the virtual page model is UI logic of a virtual page level, comprises a UI interaction processing program and data binding, and finally updates the UI by changing the UI domain model; a data model, which is a JSON object in service response, that can be used in a virtual page model; the style is a CSS of a virtual page range, which can be added and deleted by page status.
Based on any one of the foregoing embodiments, in the method, the receiving a real-time detection result of the memory monitor device in the SPA determines a storage manner of the virtual page instance, where the storage manner includes foreground internal memory storage, background internal memory storage, and external memory storage, and specifically includes:
If the virtual page instance is the instance being used by the user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor device in the SPA is that the system has an internal memory shortage warning or the number of virtual page instances in the internal memory exceeds a preset threshold.
Specifically, fig. 3 is a storage state transition diagram of a virtual page instance provided in an embodiment of the present invention, as shown in fig. 3, where three states of visible (visible state), invisible (invisible state), and persistent (persistent state) in fig. 3 correspond to states of the virtual page instance stored in three storage modes of a foreground internal memory, a background internal memory, and an external memory, respectively. The arrows in fig. 3 also indicate the direction of transition between the states. When the state of a virtual page instance needs to be changed, the situation that whether the virtual page instance is being used by a user and the current memory need to be considered is combined, and if the virtual page instance is the use instance of the user, the storage mode of the virtual page instance is that the foreground internal memory stores the virtual page instance; if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage; if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage. The method for determining the real-time monitoring result of the memory monitor device in the SPA is to monitor whether the number of virtual page instances in the memory exceeds the maximum value or not by monitoring the memory shortage warning of the system, and if one of the conditions occurs, for example, whether the number of the virtual page instances in the memory exceeds the preset maximum value or not by generating the memory shortage warning of the system, then the real-time monitoring result of the memory is judged to need to be reported to the device for updating the state of the virtual page instance in the SPA so as to make the device determine the storage mode of the virtual page instance.
Based on any one of the foregoing embodiments, in the method, the storing the virtual page instance with an external memory specifically includes:
determining an external memory type based on the application platform;
splitting the virtual page instance into UI domain data and state data;
storing the UI domain data and state data into the external memory;
clearing the associated information of the virtual page instance from an internal memory;
the determining the type of the external memory based on the application platform specifically comprises the following steps:
if the application platform is a browser, the type of the external memory is a local memory or an index database;
if the application platform is a hybrid mobile application, the external memory is a local memory.
Specifically, after determining that the virtual page instance needs to be stored by adopting an external memory, the external memory type needs to be selected based on the application platform of the current SPA. The types of external memories corresponding to different application platforms are different, and for a browser application platform, the external memory adopted is a local memory (local storage) or an index database (index DB), while for a hybrid mobile application platform, the external memory adopted is a local memory (active storage). Then, splitting the virtual page instance into content data which can be stored in an external memory, wherein the content data is UI domain data and state data; and taking the UI domain data and the state data as contents, taking the name or ID of the virtual page instance or other identification capable of uniquely identifying the virtual page instance as an index to store the content into an external memory, and clearing the associated information of the virtual page instance from the internal memory after the external memory is stored, so that the occupied memory space is thoroughly released.
Based on any one of the foregoing embodiments, in the method, the updating the state of the virtual page instance of the subscription notification service according to the storage manner of the virtual page instance of the subscription notification service specifically includes:
if the virtual page instance of the subscription notification service is stored in the foreground internal memory, updating UI domain data, state data and UI rendering of the virtual page instance of the subscription notification service based on the intermediate input;
if the virtual page instance subscribed to the notification service is stored in the background internal memory or the external memory, the UI domain data and the state data of the virtual page instance are updated based on the intermediate input, and UI rendering update is not needed.
Specifically, the storage modes of different virtual page instances are different in content stored in the virtual page instances, for example, if the virtual page instance subscribed to the notification service is stored in the foreground internal memory, the UI domain data, the state data and the UI rendering of the virtual page instance subscribed to the notification service are updated based on the intermediate input; if the virtual page instance subscribed to the notification service is stored in the background internal memory or the external memory, the UI domain data and the state data of the virtual page instance are updated based on the intermediate input, and UI rendering update is not needed.
Based on any one of the foregoing embodiments, an embodiment of the present invention provides a device for updating a virtual page instance state in an SPA, and fig. 4 is a schematic structural diagram of the device for updating a virtual page instance state in the SPA provided by the embodiment of the present invention. As shown in fig. 4, the apparatus includes a receiving unit 410, a deployment unit 420, and an updating unit 430, wherein,
the receiving unit 410 is configured to create a virtual page instance of the SPA;
the allocating unit 420 is configured to receive a real-time detection result of the memory monitor device in the SPA, and determine a storage manner of the virtual page instance, where the storage manner includes foreground internal memory storage, background internal memory storage, and external memory storage;
the updating unit 430 is configured to instruct the notification service device in the SPA to issue a status update message to the virtual page instance subscribed to the notification service if the intermediate input of the user is received, and update the status of the virtual page instance subscribed to the notification service according to the storage manner of the virtual page instance subscribed to the notification service.
The device provided by the embodiment of the invention creates the virtual page instance of the SPA when receiving the page request of the user; then determining a storage mode of the virtual page instance according to a real-time detection result of the memory monitor device in the SPA, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; when the intermediate input of the user is received, the notification service device in the SPA is instructed to issue a state update message to the virtual page instance of the subscription notification service, and the state of the virtual page instance of the subscription notification service is updated according to the storage mode of the virtual page instance of the subscription notification service. Therefore, the purpose of allocating the virtual page instance stored in the internal memory or the external memory and updating the virtual page of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service can be achieved. Therefore, the device provided by the embodiment of the invention realizes that the states of all the virtual page instances in the SPA are updated no matter how the virtual page instances are stored, and the memory is reasonably utilized by the storage of the virtual page instances in the SPA.
Based on any one of the foregoing embodiments, in the apparatus, the creating a virtual page instance of an SPA specifically includes:
if the page request is not instantiated, a first UI style instance and a first UI domain instance are created by a download resource, a first state data instance matched with the first UI style instance and the first UI domain instance is constructed, a virtual page instance is created based on the first UI style instance, the first UI domain instance and the first state data instance, and the resource comprises a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in an external memory, recovering UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in the background internal memory, the virtual page instance is directly switched to.
In accordance with any of the above embodiments, in the apparatus, the deployment unit is specifically configured to,
if the virtual page instance is the instance being used by the user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor device in the SPA is that the system has an internal memory shortage warning or the number of virtual page instances in the internal memory exceeds a preset threshold.
Based on any of the above embodiments, in the device,
the external memory is adopted to store the virtual page instance, which specifically comprises the following steps:
determining an external memory type based on the application platform;
Splitting the virtual page instance into UI domain data and state data;
storing the UI domain data and state data into the external memory;
clearing the associated information of the virtual page instance from an internal memory;
the determining the type of the external memory based on the application platform specifically comprises the following steps:
if the application platform is a browser, the type of the external memory is a local memory or an index database;
if the application platform is a hybrid mobile application, the external memory is a local memory.
Based on any one of the foregoing embodiments, in the apparatus, the updating the state of the virtual page instance of the subscription notification service according to the storage manner of the virtual page instance of the subscription notification service specifically includes:
if the virtual page instance of the subscription notification service is stored in the foreground internal memory, updating UI domain data, state data and UI rendering of the virtual page instance of the subscription notification service based on the intermediate input;
if the virtual page instance subscribed to the notification service is stored in the background internal memory or the external memory, the UI domain data and the state data of the virtual page instance are updated based on the intermediate input, and UI rendering update is not needed.
Fig. 5 is a schematic entity structure diagram of an electronic device according to an embodiment of the present invention, where, as shown in fig. 5, the electronic device may include: a processor (processor) 501, a communication interface (Communications Interface) 502, a memory (memory) 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other via the communication bus 504. The processor 501 may invoke a computer program stored in the memory 503 and executable on the processor 501 to perform the method for updating the state of a virtual page instance in the SPA provided in the above embodiments, including, for example: receiving a page request of a user, and creating a virtual page instance of the SPA; receiving a real-time detection result of a memory monitor device in the SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; if the intermediate input of the user is received, the notification service device in the command SPA issues a state update message to the virtual page instance of the subscription notification service, and the state of the virtual page instance of the subscription notification service is updated according to the storage mode of the virtual page instance of the subscription notification service.
Further, the logic instructions in the memory 503 described above may be implemented in the form of software functional units and may be stored in a computer readable storage medium when sold or used as a stand alone product. Based on such understanding, the technical solution of the embodiments of the present invention may be embodied in essence or a part contributing to the prior art or a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Embodiments of the present invention also provide a non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor, is implemented to perform a method for updating a virtual page instance state in an SPA provided in the foregoing embodiments, for example, including: receiving a page request of a user, and creating a virtual page instance of the SPA; receiving a real-time detection result of a memory monitor device in the SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage; if the intermediate input of the user is received, the notification service device in the command SPA issues a state update message to the virtual page instance of the subscription notification service, and the state of the virtual page instance of the subscription notification service is updated according to the storage mode of the virtual page instance of the subscription notification service.
The system embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and are not limiting; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims (8)

1. A method for updating a virtual page instance state in a SPA, comprising:
receiving a page request of a user, and creating a virtual page instance of the SPA;
receiving a real-time detection result of a memory monitor device in the SPA, and determining a storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage;
if the intermediate input of the user is received, the notification service device in the SPA is instructed to issue a state update message to the virtual page instance subscribing to the notification service, and the state of the virtual page instance subscribing to the notification service is updated according to the storage mode of the virtual page instance subscribing to the notification service;
The creating the virtual page instance of the SPA specifically comprises the following steps:
if the page request is not instantiated, a first UI style instance and a first UI domain instance are created by a download resource, a first state data instance matched with the first UI style instance and the first UI domain instance is constructed, a virtual page instance is created based on the first UI style instance, the first UI domain instance and the first state data instance, and the resource comprises a UI domain model, a virtual page js and a virtual page style;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in an external memory, recovering UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance;
if the page request is instantiated and the virtual page instance corresponding to the page request is stored in the background internal memory, the virtual page instance is directly switched to.
2. The method for updating a virtual page instance state in an SPA according to claim 1, wherein the receiving a real-time detection result of a memory monitor device in the SPA determines a storage mode of the virtual page instance, where the storage mode includes foreground internal memory storage, background internal memory storage and external memory storage, and specifically includes:
if the virtual page instance is the instance being used by the user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor device in the SPA is that the system has an internal memory shortage warning or the number of virtual page instances in the internal memory exceeds a preset threshold.
3. The method for updating the state of the virtual page instance in the SPA according to claim 2, wherein the virtual page instance is stored by using an external memory, specifically comprising:
determining an external memory type based on the application platform;
splitting the virtual page instance into UI domain data and state data;
storing the UI domain data and state data into the external memory;
clearing the associated information of the virtual page instance from an internal memory;
the determining the type of the external memory based on the application platform specifically comprises the following steps:
if the application platform is a browser, the type of the external memory is a local memory or an index database;
if the application platform is a hybrid mobile application, the external memory is a local memory.
4. The method for updating the state of the virtual page instance in the SPA according to claim 1, wherein the updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service specifically comprises:
if the virtual page instance of the subscription notification service is stored in the foreground internal memory, updating UI domain data, state data and UI rendering of the virtual page instance of the subscription notification service based on the intermediate input;
If the virtual page instance subscribed to the notification service is stored in the background internal memory or the external memory, the UI domain data and the state data of the virtual page instance are updated based on the intermediate input, and UI rendering update is not needed.
5. An apparatus for updating a virtual page instance state in an SPA, comprising:
a receiving unit, configured to, if a received page request of a user is not instantiated, download a resource to create a first UI style instance and a first UI domain instance, construct a first state data instance that matches the first UI style instance and the first UI domain instance, and create a virtual page instance based on the first UI style instance, the first UI domain instance, and the first state data instance, where the resource includes a UI domain model, a virtual page js, and a virtual page style; if the page request is instantiated and the virtual page instance corresponding to the page request is stored in an external memory, recovering UI domain data and state data of the virtual page from the external memory, constructing a second UI domain instance and a second state data instance based on the UI domain data and the state data, constructing a second UI style instance matched with the second UI domain instance and the second state data instance, and creating a virtual page instance based on the second UI style instance, the second UI domain instance and the second state data instance; if the page request is instantiated and the virtual page instance corresponding to the page request is stored in the background internal memory, directly switching to the virtual page instance;
The allocation unit is used for receiving the real-time detection result of the memory monitor device in the SPA and determining the storage mode of the virtual page instance, wherein the storage mode comprises foreground internal memory storage, background internal memory storage and external memory storage;
and the updating unit is used for commanding the notification service device in the SPA to issue a state update message to the virtual page instance of the subscription notification service if the intermediate input of the user is received, and updating the state of the virtual page instance of the subscription notification service according to the storage mode of the virtual page instance of the subscription notification service.
6. The apparatus for updating virtual page instance state in SPA according to claim 5, wherein the allocating unit is specifically configured to:
if the virtual page instance is the instance being used by the user, the storage mode of the virtual page instance is foreground internal memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, the storage mode of the virtual page instance is external memory storage;
if the virtual page instance is not a user using instance and the real-time detection result of the memory monitor device in the SPA is that the current memory is sufficient, the storage mode of the virtual page instance is background internal memory storage;
The real-time detection result of the memory monitor device in the SPA is that the current memory is insufficient, and the method specifically comprises the following steps:
the real-time detection result of the memory monitor device in the SPA is that the system has an internal memory shortage warning or the number of virtual page instances in the internal memory exceeds a preset threshold.
7. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the program, performs the steps of the method of updating virtual page instance state in the SPA of any of claims 1-4.
8. A non-transitory computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of the method of updating virtual page instance state in SPA as claimed in any of claims 1-4.
CN202010388536.0A 2020-05-09 2020-05-09 Method and device for updating virtual page instance state in SPA Active CN111625239B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010388536.0A CN111625239B (en) 2020-05-09 2020-05-09 Method and device for updating virtual page instance state in SPA

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010388536.0A CN111625239B (en) 2020-05-09 2020-05-09 Method and device for updating virtual page instance state in SPA

Publications (2)

Publication Number Publication Date
CN111625239A CN111625239A (en) 2020-09-04
CN111625239B true CN111625239B (en) 2023-05-02

Family

ID=72259895

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010388536.0A Active CN111625239B (en) 2020-05-09 2020-05-09 Method and device for updating virtual page instance state in SPA

Country Status (1)

Country Link
CN (1) CN111625239B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107291449A (en) * 2017-05-22 2017-10-24 北京奇艺世纪科技有限公司 A kind of page rendering method, device and equipment

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104283920A (en) * 2013-07-05 2015-01-14 腾讯科技(深圳)有限公司 Use method, server, terminal and system for Webapp router
CN106294365A (en) * 2015-05-15 2017-01-04 阿里巴巴集团控股有限公司 The page data processing method of a kind of single page web application and equipment
US10846060B2 (en) * 2018-01-29 2020-11-24 Q2 Software, Inc. Single-page web application builder system and method based on a finite-state machine
CN109739604B (en) * 2018-12-28 2022-04-15 北京城市网邻信息技术有限公司 Page rendering method, device, server and storage medium
CN110457024B (en) * 2019-07-29 2020-09-22 南京控维通信科技有限公司 VUE-based front-end request and update data plug-in iwebData implementation method
CN110928545B (en) * 2019-12-04 2024-03-12 北京小米移动软件有限公司 Component distribution method, development method and device of single-page application and storage medium
CN111090823B (en) * 2019-12-23 2024-02-09 广州市百果园信息技术有限公司 Page application integration system, application access method, device and equipment

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107291449A (en) * 2017-05-22 2017-10-24 北京奇艺世纪科技有限公司 A kind of page rendering method, device and equipment

Also Published As

Publication number Publication date
CN111625239A (en) 2020-09-04

Similar Documents

Publication Publication Date Title
CN104808952B (en) data cache method and device
CN110808857B (en) Network intercommunication method, device, equipment and storage medium for realizing Kubernetes cluster
CN111190673B (en) Page display method and device based on operation monitoring and electronic equipment
CN106817388A (en) The system that virtual machine, host obtain the method, device and access data of data
CN107211003A (en) Distributed memory system and the method for managing metadata
CN111090495A (en) Node management method, device, equipment, storage medium and system
CN112333289A (en) Reverse proxy access method, device, electronic equipment and storage medium
CN114826749A (en) Interface access control method, device and medium
EP2256633A2 (en) Service provider management device, service provider management program, and service provider management method
CN111176577B (en) Distributed block storage service command processing method, device, equipment and medium
CN113536168B (en) Component processing method and device
CN111625239B (en) Method and device for updating virtual page instance state in SPA
CN112926002A (en) Service request processing method and device
CN103118248A (en) Monitoring method, monitoring agency, monitoring server and monitoring system
CN115390897B (en) Micro front end management method, micro front end management device, electronic equipment and storage medium
CN116974465A (en) Data loading method, device, equipment and computer storage medium
CN113961298A (en) Page switching method, device, equipment and medium
CN112163178A (en) Page data display method and device, storage medium and electronic device
CN113326052A (en) Method and device for upgrading service component, computer equipment and storage medium
CN107704491B (en) Message processing method and device
CN113747423A (en) Cloud mobile phone state synchronization method, device, equipment, storage medium and program product
CN112799558A (en) Information processing method, information processing device, electronic equipment and storage medium
CN106934555B (en) Workflow organization method and device, computer equipment and storage medium
CN111400060A (en) Equipment linkage method, device, server and medium
CN114996605A (en) Page loading method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant