Data processing method and device for document picture resources and server

By automatically detecting and processing image resources in web page development, the problem of low manual processing efficiency of users is solved, and efficient image resource management and browsing experience are achieved.

CN119105756APending Publication Date: 2024-12-10CHINA CONSTRUCTION BANK +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411158136.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-22
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

During the development of web pages, users need to manually sort out and upload a large number of local image resources, resulting in low processing efficiency and cumbersome operations, which affects the browsing experience.

Method used

Automatically detect and distinguish image resource types through preset target plug-ins, establish map object data, and apply matching processing rules to automatically process image resources, including uploading local images and storage optimization of unused images.

Benefits of technology

It simplifies user operations, improves data processing efficiency, reduces customer waiting time, and improves browsing experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119105756A_ABST
    Figure CN119105756A_ABST
Patent Text Reader

Abstract

The invention provides a document picture resource data processing method, a document picture resource data processing device and a server, which can be used in the technical field of Internet. Based on the method, a preset target plug-in can be deployed and utilized to scan a target working area, and a target document and picture resources are determined; according to the target document, establishing first map object data about the picture resource; determining a resource type of the picture resource according to the first map object data; wherein the resource type comprises at least one of the following: a local picture resource used by the target project, a picture resource not used by the target project, and an internet picture resource used by the target project; and determining a target processing rule matched with the resource type of the picture resource, and processing the corresponding picture resource according to the target processing rule. Therefore, different types of picture resources related to the target document can be automatically detected and distinguished, matched processing can be efficiently, accurately and automatically completed for the different types of picture resources, and the workload of a user is relieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification belongs to the field of Internet technology, and in particular, relates to a data processing method, device and server for document image resources. Background Art

[0002] In some Internet application scenarios, users (eg, developers) often use source code editors such as VS Code (Visual Studio Code) to edit and develop related codes.

[0003] Taking web page development and production as an example, most users will use VS Code to edit and develop the page code of related web pages by writing corresponding code documents (for example, markdown documents). Since web pages usually need to display corresponding images, many related image resources will be involved in the above code documents. Some of the above image resources are stored locally. For such image resources, when customers (or viewers) want to browse and view related web pages, the browser needs to pull the corresponding image resources from the developer's local to render and display them on the page, resulting in low processing efficiency when displaying web pages, and long waiting time for customers, which in turn affects the customer's browsing experience.

[0004] In view of the above situation, based on the existing methods, developers need to manually sort through the code documents with huge data volume and complex structure to find the image resources stored locally, and then upload the above image resources to the Internet. There are problems such as cumbersome user operation process, heavy workload for developers, and relatively low overall processing efficiency.

[0005] To address the above problems, no effective solution has been proposed yet. Summary of the invention

[0006] The present application provides a method, device and server for data processing of document image resources, which can automatically detect and distinguish different types of image resources related to a target document, and automatically complete matching data processing for different types of image resources efficiently and accurately.

[0007] The present application embodiment provides a method for processing document image resource data, including:

[0008] Using a preset target plug-in, scanning a target workspace, and determining a target document and image resources; wherein the preset target plug-in matches the target document;

[0009] According to the target document, create the first map object data about the image resource;

[0010] Determine the resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: a local image resource used by the target project, an image resource not used by the target project, and an Internet image resource used by the target project;

[0011] According to the resource type of the image resource, determine the matching target processing rule;

[0012] Process the corresponding image resources according to the matching target processing rules;

[0013] Among them, determining the resource type of the image resource according to the first map object data includes: determining the element corresponding to the image resource in the first map object data; obtaining the value of the element and the first storage path in the key value of the element; determining the resource type of the image resource according to the value of the element and the first storage path in the key value of the element.

[0014] In one embodiment, the target document includes: a markdown document;

[0015] Correspondingly, the target projects include: markdown projects, and the preset target plug-ins include: VS Code plug-ins.

[0016] In one embodiment, a preset target plug-in is used to scan a target workspace to determine a target document and image resources related to the target document, including:

[0017] The first interface is called to scan the target work area to determine the target document and image resources; wherein the first interface includes: vscode.workspace.findFiles API.

[0018] In one embodiment, first map object data about a picture resource is established according to a target document, including:

[0019] Initialize first map object data according to the image resource; wherein the first map object data includes multiple elements, each element corresponds to an image resource, and each element further includes a corresponding key value and a value value, wherein the key value is used to indicate whether the corresponding image resource is used by the target project, and the value value is used to store the storage path of the corresponding image resource;

[0020] Traversing each target document; and calling a preset program to obtain the text content of the target document through a second interface;

[0021] By using the corresponding regular expression and processing the text content of the target document, the image resource referenced by the target document is determined as the image resource used by the target project; and the value of the corresponding element in the first map object data is set to the first data value;

[0022] According to the text content of the target document, the storage path of the image resource used by the target project is obtained as the first storage path; and the first storage path is written into the key value of the corresponding element in the first map object data.

[0023] In one embodiment, determining the resource type of the image resource according to the first map object data includes:

[0024] Check whether the value of the element is the first data value and whether the first storage path in the key value of the element has a key character segment;

[0025] When it is determined that the value of the element is the first data value and the first storage path in the key value of the element does not have a key character, it is determined that the resource type of the image resource corresponding to the element is a local image resource used by the target project.

[0026] In one embodiment, after detecting whether the value of the element is the first data value and whether the first storage path in the key value of the element has a key character segment, the method further includes:

[0027] When it is determined that the value of the element is the second data value, determining that the resource type of the image resource corresponding to the element is an image resource not used by the target project;

[0028] Or, when it is determined that the value of the element is the first data value and there are key characters in the first storage path in the key value of the element, it is determined that the resource type of the image resource corresponding to the element is an Internet image resource used by the target project.

[0029] In one embodiment, when the resource type of the image resource is an image resource not used by the target project, the corresponding image resource is processed according to the matching target processing rule, including:

[0030] According to the matching target processing rules, a new spare folder is created in the target project using the third interface;

[0031] Query the key value of the element corresponding to the image resource in the first map object data to obtain the first storage path of the image resource; obtain the storage path of the target document as the second storage path;

[0032] Concatenate the first storage path and the second storage path to obtain a joint storage path for the image resource;

[0033] According to the joint storage path of the image resource, the image resource is moved to the backup folder for storage.

[0034] In one embodiment, when the resource type of the image resource is a local image resource used by the target project, the corresponding image resource is processed according to the matching target processing rule, including:

[0035] According to the first map object data, second map object data corresponding to the local image resource used by the target project is established;

[0036] Determine a matching target static resource storage server; and obtain a target security credential corresponding to the target static resource storage server;

[0037] Generate a target storage request that carries the image resource and the target security credential; and send the target storage request to the target static resource storage server; wherein, when determining that the target security credential verification has passed and the image resource storage has succeeded, the target static resource storage server feeds back the network storage path of the image resource;

[0038] Receive the network storage path of the image resource; and update the relevant information about the image resource in the target document according to the network storage path of the image resource.

[0039] In one embodiment, generating a target storage request carrying an image resource and a target security credential includes:

[0040] According to the first map object data, obtain the joint storage path of the image resource;

[0041] According to the joint storage path of the image resource, the corresponding image resource in the target document is read using the fourth interface and converted into corresponding binary data;

[0042] Buffer the binary data to generate a corresponding intermediate data object; and use the target security credentials to configure the specified field in the request header;

[0043] The intermediate data object and the request header are combined to generate the corresponding POST request as the target storage request.

[0044] In one embodiment, sending the target storage request to the target static resource storage server includes:

[0045] The target storage request is sent to the target static resource storage server by using the fifth interface; wherein the fifth interface includes the Upload Image API.

[0046] In one embodiment, when the resource type of the image resource is an Internet image resource used by the target project, the corresponding image resource is processed according to the matching target processing rule, including:

[0047] According to the matching target processing rules, the relevant information about the image resource in the target document is kept unchanged.

[0048] The embodiment of the present application also provides a data processing device for document image resources, including:

[0049] A scanning module, used to scan a target workspace using a preset target plug-in to determine a target document and image resources; wherein the preset target plug-in matches the target document;

[0050] A creation module, used for creating first map object data about the image resource according to the target document;

[0051] A first determination module is used to determine a resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: a local image resource used by the target project, an image resource not used by the target project, and an Internet image resource used by the target project;

[0052] The second determination module is used to determine a matching target processing rule according to the resource type of the image resource;

[0053] A processing module is used to process corresponding image resources according to the matching target processing rules;

[0054] Among them, the first determination module is specifically used to: determine the element corresponding to the image resource in the first map object data; obtain the value of the element and the first storage path in the key value of the element; determine the resource type of the image resource based on the value of the element and the first storage path in the key value of the element.

[0055] An embodiment of the present application also provides a server, including a processor and a memory for storing processor executable instructions, wherein the processor implements the steps of the document image resource data processing method when executing the instructions.

[0056] The embodiment of the present application also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the steps of the data processing method of the document image resource are implemented.

[0057] The embodiment of the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the data processing method of the document image resource are implemented.

[0058] Based on the data processing method, device and server of document image resources provided by the present application, before specific implementation, a preset target plug-in matching the target document can be deployed first. During specific implementation, the preset target plug-in can be used to scan the target workspace in response to user instructions to determine the target document and image resources; establish the first map object data about the image resource according to the target document; determine the resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: local image resources used by the target project, image resources not used by the target project, and Internet image resources used by the target project; when specifically determining the resource type of the image resource, the element corresponding to the image resource in the first map object data can be determined, and then the value of the element and the first storage path in the key value of the element can be obtained and the feature information of multiple dimensions can be integrated to accurately and efficiently determine the resource type of the image resource; then, according to the resource type of the image resource, a matching target processing rule can be determined; and the corresponding image resource can be processed according to the matching target processing rule. It can automatically detect and distinguish different types of image resources involved in the target document, and adopt differentiated processing rules for different types of image resources to automatically and efficiently and accurately complete the matching data processing, so that the corresponding business processing can be completed efficiently and accurately based on the processed image resources, thereby simplifying user operations, reducing the user's workload, and improving overall data processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the embodiments of this specification, the drawings required for use in the embodiments will be briefly introduced below. The drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0060] Figure 1 It is a flowchart of a method for processing data of document image resources provided by an embodiment of this specification;

[0061] Figure 2 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0062] Figure 3 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0063] Figure 4 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0064] Figure 5 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0065] Figure 6 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0066] Figure 7 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0067] Figure 8 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0068] Fig. 9 It is a schematic diagram of the structure of a server provided by an embodiment of this specification;

[0069] Fig.10 It is a schematic diagram of the structure of a data processing device for document image resources provided by an embodiment of this specification;

[0070] Fig.11 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0071] Fig.12 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0072] Fig.13 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0073] Fig.14 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example;

[0074] Fig.15 It is a schematic diagram of an embodiment of a data processing method for document image resources provided by an embodiment of this specification, in a scenario example. DETAILED DESCRIPTION

[0075] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0076] It should be noted that the user-related information and data involved in the embodiments of this specification are all information and data authorized by the user or fully authorized by relevant parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users or relevant parties to choose to authorize or refuse.

[0077] It should also be noted that in the embodiments of this specification, certain software, components, models and other existing solutions in the industry may be mentioned. They should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of this application, but it does not mean that the applicant has or will necessarily use the solution.

[0078] See also Figure 1 As shown, the embodiment of this specification provides a method for processing data of document image resources. Among them, the method is specifically applied to the server side. When implemented specifically, the method may include the following contents:

[0079] S101: Scanning a target workspace using a preset target plug-in to determine a target document and image resources; wherein the preset target plug-in matches the target document;

[0080] S102: creating first map object data about the image resource according to the target document;

[0081] S103: Determine a resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: a local image resource used by the target project, an image resource not used by the target project, and an Internet image resource used by the target project;

[0082] S104: Determine a matching target processing rule according to the resource type of the image resource;

[0083] S105: Processing corresponding image resources according to the matched target processing rules;

[0084] Among them, determining the resource type of the image resource according to the first map object data includes: determining the element corresponding to the image resource in the first map object data; obtaining the value of the element and the first storage path in the key value of the element; determining the resource type of the image resource according to the value of the element and the first storage path in the key value of the element.

[0085] Based on the above embodiment, by calling the preset target plug-in that matches the target document to describe and analyze the target document and image resources in the target work area of ​​the target project, it is possible to simultaneously integrate feature information of multiple dimensions, automatically and accurately determine the resource type of the image resources related to the target document in the target work area; and then by distinguishing different types, determining and using the matching target processing rules, it is possible to automatically and accurately perform targeted and differentiated processing on different types of image resources. This can effectively simplify user operations, reduce the user's workload, and improve overall data processing efficiency.

[0086] In some embodiments, the data processing method of the document image resource can be specifically applied to a server side, wherein the server can be connected to a user terminal.

[0087] In this embodiment, the server may specifically include a background server applied to one side of the network service platform, capable of realizing functions such as data transmission and data processing. Specifically, the server may be, for example, an electronic device having data calculation, storage and network interaction functions. Alternatively, the server may also be a software program running in the electronic device to provide support for data processing, storage and network interaction. In this embodiment, the number of the servers is not specifically limited. The server may specifically be one server, or several servers, or a server cluster formed by several servers.

[0088] The user terminal may specifically include a front end applied to the user side and capable of realizing functions such as data collection and data transmission. Specifically, the user terminal may be, for example, an electronic device such as a desktop computer, a tablet computer, a laptop computer, a smart phone, etc. Alternatively, the user terminal may also be a software application that can run in the above electronic devices.

[0089] The above-mentioned users may specifically be developers of the network service platform.

[0090] In specific implementation, after the user develops and edits a target document (eg, a markdown document) about a web page of a network service platform using a user terminal, the target document is uploaded and saved in a target project directory of the network service platform.

[0091] When the server detects that the target document under the target project directory is updated, it can trigger the data processing method for document image resources provided by the embodiment of the present application, first determine the preset target plug-in (for example, VS Code plug-in) corresponding to the target document; and call the preset target plug-in to automatically scan the target workspace (for example, workspace) corresponding to the target project, and obtain the target document and image resources in the target workspace; and establish the first map object data about the image resource according to the target document; and then determine the target processing rule that matches the resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: local image resources used by the target project, image resources not used by the target project, and Internet image resources used by the target project; and thus different types of image resources can be effectively distinguished, and different image resources can be automatically processed in a matching manner according to the matching target processing rules. Specifically, for local image resources used by the target project, the image resources can be uploaded and stored in a static resource storage server, and the relevant information of the image resources in the target document can be updated according to the storage path fed back by the static resource storage server; for Internet image resources used by the target project, no additional processing is performed; for image resources not used by the target project, a new backup folder can be created, and the image resources can be moved to the backup folder for storage.

[0092] In this way, when a client (or viewer) opens a web page of the network service platform through a browser, the browser will automatically execute the corresponding target document. At this time, the browser can efficiently obtain the image resources related to the web page through the corresponding static resource storage server based on the target document; and based on the image resources, quickly display the web page containing the corresponding image to the client.

[0093] This can effectively shorten the page refresh time, reduce the customer's waiting time, and enable customers to have a better user experience.

[0094] In some embodiments, the target workspace may be specifically understood as a file storage area corresponding to a target project directory. The target project may be specifically understood as a project developed for a target business, such as a code project for a web page.

[0095] The target workspace may store target documents and image resources related to the target project.

[0096] The target document can be specifically understood as a structured document containing specific codes for a target project, and the target document often involves and refers to related image resources.

[0097] The above map object can be specifically understood as a data object based on the Java language that maps a key (eg, key) to a value (eg, value).

[0098] The local image resources used by the above target project can be specifically understood as image resources that are referenced by at least one target document in the target project and stored locally. The Internet image resources used by the above target project can be specifically understood as image resources that are referenced by at least one target document in the target project and stored on the network. The image resources not used by the above target project can be specifically understood as image resources scanned in the target workspace and not referenced by any target document of the target project.

[0099] In some embodiments, in application scenarios such as web page production and development scenarios, VS Code is often used to develop and edit related codes.

[0100] Among them, the above-mentioned VS Code (Visual Studio Code) can be specifically understood as a free, open source, and cross-platform source code editor that can provide an efficient and flexible development environment.

[0101] For the above application scenarios such as web page production and development scenarios, the target document may specifically include: a markdown document;

[0102] Accordingly, the target project may include: a markdown project, and the preset target plug-in may include: a VS Code plug-in.

[0103] Specifically, the above-mentioned markdown can be understood as a lightweight markup language that can provide a concise, easy-to-read and easy-to-write plain text format suitable for writing structured documents; it can also be easily converted into structured HTML (HyperText Markup Language) or other formats to achieve beautiful web page display or further formatting. In addition, markdown is also popular for its focus on content creation, simplified typesetting process and good portability, especially in technical communities, blog writing, online notes, knowledge sharing, project documentation and academic exchanges.

[0104] The above markdown project can be specifically understood as a project written based on markdown. The above markdown document can be specifically understood as a structured document written based on markdown and containing specific codes.

[0105] The above-mentioned VS Code plug-in can be specifically understood as a plug-in customized and developed based on Visual Studio Code, which can realize the automatic processing function of image resources involved in markdown documents.

[0106] Based on the above embodiments, combined with the characteristics of application scenarios such as web page production and development scenarios, by using markdown documents as target documents and using VS Code plug-ins as preset target plug-ins, it is possible to better adapt to relevant application scenarios and obtain relatively better application effects.

[0107] In some embodiments, when implementing Figure 2 As shown, for the web page production and development scenario, in order to be able to render and display the corresponding image resources in the markdown-based web page, the path link of the required image resource can be inserted in the corresponding markdown document using a specific grammatical structure according to the preset grammatical rules.

[0108] For details, see Figure 2 As shown in the figure, the symbol "![" indicates the start mark for inserting an image resource into a markdown document. The exclamation mark "!" before the square bracket "[" is used to indicate that this is a path link to an image resource rather than a path link to a normal text.

[0109] The "alternative text" in the symbols "[]" is used to briefly describe the image content. It is an alternative text description when the image resource cannot be displayed normally. It plays an important role for assistive technologies (for example, screen readers) and SEO optimization (Search Engine Optimization).

[0110] The image path (link) after the symbol "](" can be the local storage path of the image resource. Figure 3 As shown, the above local storage path ". / images / example.jpg" can indicate that the image resource is stored in a subdirectory named "image" under the local target project directory (root directory).

[0111] It can also be a network storage path of the image resource (for example, a URL address). Figure 4 As shown, the network storage path is a URL address. In specific implementation, the image resource can be obtained through the Internet according to the URL address.

[0112] Specifically, an optional title field "image title" can be set in the double quotes after the storage path. When the corresponding markdown document is executed, the corresponding web page is displayed to the customer through the browser or markdown parser. If the customer hovers the mouse over the page image corresponding to the image resource, the image title will be automatically displayed.

[0113] For details, please refer to Figure 5 As shown. Based on the code snippet in the above markdown document, the first image uses the local path (the images subdirectory under the target project directory) as the storage path, and the second image uses the network link as the storage path. When the markdown document is parsed correctly, the above syntax structure will be converted to the corresponding HTML Tag, and display the corresponding image on the web page according to the tag. If the image cannot be loaded successfully during execution (for example, the local image does not exist or the network image link is invalid), the alternative text in the markdown document will be displayed.

[0114] In some embodiments, the above-mentioned use of a preset target plug-in to scan the target workspace and determine the target document and the image resources related to the target document may include the following contents during specific implementation:

[0115] The first interface is called to scan the target work area to determine the target document and image resources; wherein the first interface includes: vscode.workspace.findFiles API.

[0116] Specifically, the scanned target document can be recorded in markdownFiles, and the scanned image resources can be recorded in imageFiles.

[0117] Based on the above embodiment, the target documents and image resources in the target workspace can be automatically scanned and determined through the first interface to avoid omissions.

[0118] In some embodiments, see Figure 6 As shown, the first map object data about the image resource is established according to the target document. When implemented specifically, the following contents may be included:

[0119] S1: Initialize first map object data according to the image resource; wherein the first map object data includes multiple elements, each element corresponds to an image resource, and each element further includes a corresponding key value and a value value, wherein the key value is used to indicate whether the corresponding image resource is used by the target project, and the value value is used to store the storage path of the corresponding image resource;

[0120] S2: traverse each target document; and call a preset program to obtain the text content of the target document through the second interface;

[0121] S3: using a corresponding regular expression, by processing the text content of the target document, determining the image resource referenced by the target document as the image resource used by the target project; and setting the value of the corresponding element in the first map object data to the first data value;

[0122] S4: According to the text content of the target document, obtain the storage path of the image resource used by the target project as the first storage path; and write the first storage path into the key value of the corresponding element in the first map object data.

[0123] In specific implementation, the initialization operation of the first map object data (which can be recorded as imagesFileMap) can be implemented by initializing and creating elements corresponding to the image resources one by one according to the image resources contained in imageFiles.

[0124] During specific implementation, the preset program may specifically be vscode.workspace.openTextDocument; and the second interface may specifically be getText API.

[0125] Specifically, each target document in markdownFiles can be traversed, and each target document can be opened by calling a preset program first; then, the second interface can be used to obtain the text content of each target document (which can be recorded as markdownFileContent) through the opened target document; then, the corresponding regular expression (for example, ( / !\[.*\]\((.*)\) / g) can be used to retrieve the text content of the target document to determine whether the target document has referenced image resources, and when it is determined that there are referenced image resources, the storage path of the image resource is extracted based on the text content of the target document as the first storage path.

[0126] The regular expression may be determined based on a preset grammar rule and a specific grammar structure used in the markdown document.

[0127] In specific implementation, when traversing the text content of the current target document and determining that the current target document does not reference image resources, the processing of the current target document can be directly ended, and the processing of the next target document can be directly jumped.

[0128] When the text content of the current target document is traversed and it is determined that the current target document has a referenced image resource, the identification information of the image resource can be obtained according to the text content of the current target document; and according to the representation information, the element corresponding to the image resource is determined in the first map object data; and the value of the element is set to the first data value (for example, a numerical value 1, or a character true); at the same time, according to the text content, the first storage path of the image resource is extracted, and the first storage path is written into the key value of the corresponding element. Thus, the processing of the current target document is completed, and then the next target document can be processed.

[0129] According to the above method, after traversing each target document, it is also possible to traverse each element in the first map object to determine the elements whose value is empty; it can be determined that the image resources corresponding to such elements are image resources not used by the target project; further, the value of such elements in the first map object can be set to a second data value (for example, a numerical value of 0, or the character false); at the same time, based on the scanned image resources, the local storage path of the image resources corresponding to such elements is obtained as the first storage path; and the above first storage path is written into the key value of the corresponding element.

[0130] Finally, the first map object data about the image resource that can reflect the resource type of the image resource can be established.

[0131] Subsequently, by querying the key value and value value of the element in the first map object data, the data value (including the first data value, or the second data value) used to characterize whether the image resource corresponding to the element is used by the target project, as well as the first storage path, can be obtained; and then, based on the above data value and the first storage path, the specific resource type of the image resource corresponding to the element can be determined.

[0132] Based on the above embodiment, the first map object data about the picture resource can be accurately and automatically established according to the target document.

[0133] In some embodiments, the above-mentioned determining the resource type of the picture resource according to the first map object data may include:

[0134] S1: Detect whether the value of the element is the first data value, and whether the first storage path in the key value of the element has a key character segment;

[0135] S2: When it is determined that the value of the element is the first data value and the first storage path in the key value of the element does not contain a key character, it is determined that the resource type of the image resource corresponding to the element is a local image resource used by the target project.

[0136] The above key characters may specifically be: http.

[0137] Based on the above embodiment, the resource type of the picture resource can be accurately detected and determined by using the first map object data.

[0138] In some embodiments, after detecting whether the value of the element is the first data value and whether the first storage path in the key value of the element has a key character segment, the method may further include:

[0139] When it is determined that the value of the element is the second data value, determining that the resource type of the image resource corresponding to the element is an image resource not used by the target project;

[0140] Or, when it is determined that the value of the element is the first data value and there are key characters in the first storage path in the key value of the element, it is determined that the resource type of the image resource corresponding to the element is an Internet image resource used by the target project.

[0141] Based on the above embodiment, the first map object data can be used to more comprehensively and accurately detect and determine the resource type of the image resource.

[0142] In some embodiments, during specific implementation, a matching preset processing rule can be determined from a preset processing rule set according to the resource type of the image resource as a matching target processing rule. The preset processing rule set can store multiple preset processing rules, each of which corresponds to a resource type of an image resource.

[0143] In some embodiments, when the resource type of the image resource is an image resource not used by the target project, refer to Figure 7 As shown, the above processing of corresponding image resources according to the matching target processing rules may include the following contents during specific implementation:

[0144] S1: according to the matching target processing rule, using the third interface, a new spare folder (which can be recorded as image-unused) is created in the target project;

[0145] S2: query the key value of the element corresponding to the image resource in the first map object data to obtain the first storage path of the image resource; obtain the storage path of the target document as the second storage path;

[0146] S3: concatenate the first storage path and the second storage path to obtain a joint storage path for the image resource;

[0147] S4: According to the joint storage path of the image resource, the image resource is moved to a backup folder for storage.

[0148] The third interface may specifically be a mkdirSync API.

[0149] Based on the above embodiment, the unused image resources of the target project can be accurately and efficiently processed automatically according to the matching target processing rules. Specifically, the unused image resources of the target project can be automatically collected and uniformly moved to a spare folder for storage for subsequent use.

[0150] In some embodiments, before creating a new standby folder for the target project using the third interface, the method further includes: detecting whether a standby folder already exists in the target project directory. If it is determined that there is no standby folder, creating a new standby folder using the third interface. If it is determined that there is already a standby folder, moving the image resource to the standby folder for storage.

[0151] In some embodiments, after the image resources are moved to a backup folder, a image resource directory for the backup folder can be generated; and the image resource directory can be displayed to the user so that the user can flexibly and conveniently call the image resources in the backup folder when modifying old target documents or creating new target documents according to specific needs.

[0152] In some embodiments, while moving the picture resource to the backup folder, the moving time of the picture resource can also be recorded. Accordingly, in specific implementation, the moving time of the picture resources stored in the backup folder can be queried at intervals of a specified time period (for example, at intervals of one week) to detect whether there is a picture resource whose difference between the moving time and the current time is greater than or equal to a preset time threshold (for example, 1 month). In the case where the existence of the above-mentioned picture resource is detected, the picture resource can be marked as an overdue picture resource, and a deletion request for the overdue picture resource is generated; the deletion request is sent to the user. After receiving the user's confirmation instruction for the deletion request, the overdue picture resource is deleted in a timely manner.

[0153] In some embodiments, when the resource type of the image resource is a local image resource used by the target project, refer to Figure 8 As shown, the above processing of corresponding image resources according to the matching target processing rules may include the following contents during specific implementation:

[0154] S1: According to the first map object data, create the second map object data (which can be recorded as imagesUploadFilesMap) corresponding to the local image resources used by the target project;

[0155] S2: Determine a matching target static resource storage server; and obtain a target security credential corresponding to the target static resource storage server;

[0156] S3: Generate a target storage request that carries the image resource and the target security credential; and send the target storage request to the target static resource storage server; wherein, when the target static resource storage server determines that the target security credential verification has passed and the image resource storage has succeeded, it feeds back the network storage path of the image resource;

[0157] S4: receiving a network storage path of the image resource; and updating relevant information about the image resource in the target document according to the network storage path of the image resource.

[0158] The above-mentioned static resource storage server (or static resource storage device) can be specifically understood as a storage server used for static resource storage, and related distribution and processing.

[0159] The above-mentioned static resource storage may specifically refer to storing those file resources in a Web application or website that do not change during operation and are directly requested and used by a client (e.g., a Web browser) in a specific location or service based on the Internet. The above-mentioned file resources may specifically include one or more of the following: pictures (e.g., JPEG, PNG, SVG, etc.), audio and video files (MP3, MP4, WebM, etc.), CSS styles, JavaScript scripts, font files, HTML templates (in some static site generators or static web page applications), etc.

[0160] By introducing a static resource storage server in the target project for static resource storage, the following benefits can be obtained: Accelerate content distribution. Static resources are usually distributed through CDN (content distribution network), allowing customers to quickly obtain resources from the nearest edge node, reduce latency, and increase page loading speed; separate dynamic resources from static resources. By storing and processing static resources separately from dynamically generated content resources (such as database query results), it helps to improve server performance and reduce server pressure, especially for high-traffic websites; simplify deployment and management. Static resource storage services (such as the static website hosting function provided by object storage services) can simplify the upload, version management, access control, and invalidation refresh of static content, and are especially suitable for serverless architecture and continuous integration / continuous deployment (CI / CD) processes; security and access control. Static resource storage services usually provide security measures such as anti-hotlinking, IP blacklist / whitelist, and access frequency limiting to protect resources from illegal access or abuse and improve the security of static resources.

[0161] In this embodiment, the static resource storage server may specifically include XXX Cloud Storage, YYY Cloud OSS, etc. The static resource storage server has the characteristics of large scale, low cost, and high availability; and can also provide tools and APIs that are closely integrated with the Web application development and deployment process, so that developers can efficiently manage static resources.

[0162] Based on the above embodiments, the local image resources used by the target project can be automatically processed accurately and efficiently according to the matching target processing rules.

[0163] In some embodiments, when the resource type of the image resource is a local image resource used by the target project, the method may also include the following contents when implemented: querying and judging whether the image resource is a fixed static resource based on the text content of the target document; when it is determined that the image resource is a non-fixed dynamic resource, subsequent processing of the image resource may not be performed.

[0164] In addition, during the specific implementation, you can also query and determine the data volume and security level of the image resource based on the text content of the target document; then, based on the data volume and security level, determine a static resource storage server that meets the requirements as the target static resource storage server; then upload the image resource to the target static resource storage server for storage.

[0165] In some embodiments, the above-mentioned generation of a target storage request carrying an image resource and a target security credential may include the following contents during specific implementation:

[0166] S1: Obtain the joint storage path of the image resource according to the first map object data;

[0167] S2: According to the joint storage path of the image resource, use the fourth interface to read the corresponding image resource in the target document and convert it into corresponding binary data;

[0168] S3: Buffer the binary data to generate a corresponding intermediate data object; and use the target security credentials to configure the specified field in the request header;

[0169] S4: Combine the intermediate data object and the request header to generate the corresponding POST request as the target storage request.

[0170] The fourth interface may be a readFileSync API, the intermediate data object may be a FormData object, and the designated field may be an Authorization field.

[0171] In specific implementation, the binary data may be encoded accordingly according to a preset encoding rule to implement Buffer processing.

[0172] Based on the above embodiment, a target storage request that meets the requirements can be generated efficiently and accurately, so that the corresponding image resources can be uploaded and stored in the static resource storage server safely and stably based on the target storage request.

[0173] In some embodiments, the sending of the target storage request to the target static resource storage server may include:

[0174] The target storage request is sent to the target static resource storage server by using the fifth interface; wherein the fifth interface includes the Upload Image API.

[0175] Based on the above embodiments, image resources can be uploaded and stored in the corresponding target static resource storage server more efficiently and reliably.

[0176] In some embodiments, the above-mentioned target security credentials may specifically include: imgToken.

[0177] The above-mentioned acquisition of the target security credentials corresponding to the target static resource storage server may include the following contents during specific implementation:

[0178] S1: Obtain the user's account ID and login credentials;

[0179] S2: Based on the user's account identification and login credentials, simulate and generate a target application request for the target business service platform to which the target static resource storage server belongs;

[0180] S3: Send the target application request to the target business service platform to receive the target security credentials fed back by the target business service platform.

[0181] Based on the above embodiments, the corresponding target security credentials can be automatically obtained by simulating user operations.

[0182] In some embodiments, after sending the target storage request to the target static resource storage server, if the network storage path of the image resource fed back by the target static resource storage server is not received within the preset tolerance time, it can be determined that the image resource has failed to be stored on the target static resource storage server. At this time, the local image resource will not be deleted; at the same time, the collection of relevant feedback information can be triggered to establish a storage failure record.

[0183] Furthermore, the storage failure cause can be determined based on the storage failure record. The storage failure cause includes: network reasons, and / or target static resource storage server reasons, etc. For different storage failure causes, matching processing solutions can be determined; and corresponding processing can be performed according to the matching processing solutions.

[0184] Specifically, for network reasons, the target storage request may be resent to the target static resource storage server after a reference time period according to a matching processing solution.

[0185] According to the cause of the target static resource storage server, the error information of the target static resource storage server can be collected according to the matching processing scheme; and the target security credentials can be re-acquired according to the error information of the target static resource storage server. Alternatively, according to the matching processing scheme, the prompt information about the reason for the failure of the image resource storage can be fed back to the user; wherein, the prompt information also carries the error information of the target static resource storage server, waiting for the user to instruct the next step of processing.

[0186] In some embodiments, the image resources stored in the target static resource storage server can be set to only support calls based on the target document file, thereby effectively preventing the image resources from being stolen and having relatively high security and reliability.

[0187] In some embodiments, when the resource type of the image resource is an Internet image resource used by the target project, the above processing of the corresponding image resource according to the matching target processing rule may include:

[0188] According to the matching target processing rules, the relevant information about the image resource in the target document is kept unchanged.

[0189] Specifically, for the Internet image resources used in the target project, no additional processing is required because they have been previously uploaded and saved on the Internet.

[0190] Based on the above embodiments, the Internet image resources used by the target project can be automatically processed accurately and efficiently according to the matching target processing rules.

[0191] In some embodiments, when it is determined that the resource type of the image resource corresponding to the element is an Internet image resource used by the target project, the method may further include the following contents when implemented:

[0192] S1: According to the preset static resource storage server information table, by detecting the storage path character string in the first storage path in the key value of the element, it is determined whether the network server currently storing the image resource corresponding to the element is a static resource storage server that meets the requirements;

[0193] S2: if it is determined that the network server is not a static resource storage server that meets the requirements, generate a test request for the network server;

[0194] S3: Send a test request to the network server; and receive test feedback data from the network server in response to the test request;

[0195] S4: Determine whether the security, stability, health, and download speed of the network server meet the requirements based on the test feedback data;

[0196] S5: If it is determined that the security, stability, health, and download speed of the network server meet the requirements, no additional processing is required.

[0197] On the contrary, if it is determined that the security, stability, health, and download speed of the network server do not meet the requirements, the image resource is downloaded from the network server; and the image resource is re-uploaded and stored in the corresponding target static resource storage server; and then the relevant information about the image resource in the target document is updated according to the network storage path of the image resource fed back by the target static resource storage server.

[0198] In specific implementation, after downloading the image resource, the image resource may be stored locally and the local storage path of the image resource may be obtained; then the local storage path of the image resource may be used to update the relevant information about the image resource in the target document.

[0199] In some embodiments, after receiving the test feedback data from the network server for the test request, the method may further include:

[0200] S1: Detect whether the image resources are invalid based on the test feedback data;

[0201] S2: When it is determined that the image resource is invalid, query the historical document record to determine the data source of the image resource; and send a retransmission request for the image resource to the data source;

[0202] S3: When it is determined that the image resource cannot be re-transmitted, the storage path of the image resource in the target document is updated, and the text description field of the image resource in the target document is updated.

[0203] For example, set the alternative text field for the image resource in the target document to "Image is missing".

[0204] After sending a request for retransmission of the image resource to the data source, the method further includes: obtaining the image resource retransmitted by the data source; re-uploading and storing the image resource in the corresponding target static resource storage server; and then updating the relevant information about the image resource in the target document according to the network storage path of the image resource fed back by the target static resource storage server.

[0205] In some embodiments, before the method is implemented, the following contents may also be included:

[0206] S1: Initialize the preset target plug-in and configure the corresponding plug-in dependencies;

[0207] S2: define the contribution points about the preset target plug-in;

[0208] S3: Perform plugin dependency detection on the preset target plugin;

[0209] S4: When the plug-in dependency detection passes, the preset target plug-in is packaged and published, so that the server or user calls the preset target plug-in to complete the data processing method of the corresponding document image resource.

[0210] The above plug-in dependencies may specifically include: TypeScript and @types / vscode, etc., which are used to support writing plug-ins in TypeScript.

[0211] The above contribution point can specifically refer to the extension or custom functionality provided by the plugin to the editor through a specific configuration section in its package.json file. Usually, the plugin can be automatically activated when the user (developer) executes a specific command (for example, an image resource update processing instruction for the target document) in the contributions field in package.json.

[0212] Based on the above embodiments, a preset target plug-in with better effect and higher reliability can be automatically generated and deployed.

[0213] As can be seen from the above, based on the data processing method of document image resources provided in the embodiment of this specification, before specific implementation, a preset target plug-in matching the target document can be deployed first. During specific implementation, the preset target plug-in can be used to scan the target workspace in response to user instructions to determine the target document and image resources; establish the first map object data about the image resource according to the target document; determine the resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: local image resources used by the target project, image resources not used by the target project, and Internet image resources used by the target project; determine the matching target processing rules according to the resource type of the image resource; and process the corresponding image resource according to the matching target processing rules. Thus, it is possible to automatically detect and distinguish different types of image resources involving the target document, and automatically and efficiently and accurately complete the matching data processing for different types of image resources, so that the corresponding business processing can be better completed based on the processed image resources in the future, simplifying user operations, reducing the user's workload, and improving the overall data processing efficiency.

[0214] This specification embodiment provides a server, referring to Fig. 9 The server includes a network communication port 901, a processor 902 and a memory 903, and the above structures are connected through internal cables so that each structure can perform specific data interaction.

[0215] The network communication port 901 can be specifically used to receive a trigger instruction.

[0216] The processor 902 can be specifically used to respond to a trigger instruction, use a preset target plug-in, scan a target workspace, determine a target document, and image resources; wherein the preset target plug-in matches the target document; according to the target document, establish a first map object data about the image resource; according to the first map object data, determine the resource type of the image resource; wherein the resource type includes at least one of the following: local image resources used by the target project, image resources not used by the target project, and Internet image resources used by the target project; according to the resource type of the image resource, determine a matching target processing rule; according to the matching target processing rule, process the corresponding image resource.

[0217] The memory 903 may be specifically used to store corresponding instruction programs, as well as intermediate data such as first map object data and matching target processing rules.

[0218] Based on the above method, the relevant structural performance of the server can be effectively utilized, the data processing speed of the electronic device can be improved, and the data processing of document image resources can be efficiently realized.

[0219] In this embodiment, the network communication port 701 can be a virtual port that is bound to different communication protocols so that different data can be sent or received. For example, the network communication port can be a port responsible for web data communication, a port responsible for FTP data communication, or a port responsible for email data communication. In addition, the network communication port can also be a physical communication interface or communication chip. For example, it can be a wireless mobile network communication chip, such as GSM, CDMA, etc.; it can also be a Wifi chip; it can also be a Bluetooth chip.

[0220] In this embodiment, the processor 702 may be implemented in any appropriate manner. For example, the processor may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) executable by the (micro)processor, a logic gate, a switch, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, etc. This specification does not limit this.

[0221] In this embodiment, the memory 703 may include multiple levels. In a digital system, anything that can store binary data can be a memory; in an integrated circuit, a circuit with a storage function that has no physical form is also called a memory, such as RAM, FIFO, etc.; in a system, a storage device with a physical form is also called a memory, such as a memory stick, TF card, etc.

[0222] The embodiment of this specification also provides a computer-readable storage medium based on the data processing method of the above-mentioned document image resources, and the computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed, the following steps are implemented: using a preset target plug-in, scanning the target workspace, determining the target document, and the image resource; wherein the preset target plug-in matches the target document; according to the target document, establishing the first map object data about the image resource; according to the first map object data, determining the resource type of the image resource; wherein the resource type includes at least one of the following: local image resources used by the target project, image resources not used by the target project, and Internet image resources used by the target project; according to the resource type of the image resource, determining a matching target processing rule; according to the matching target processing rule, processing the corresponding image resource.

[0223] In this embodiment, the storage medium includes, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a cache, a hard disk (HDD), or a memory card. The memory may be used to store computer program instructions. The network communication unit may be an interface for network connection communication set in accordance with the standard specified by the communication protocol.

[0224] In this embodiment, the functions and effects specifically implemented by the program instructions stored in the computer-readable storage medium can be explained in comparison with other implementations and will not be described in detail here.

[0225] The embodiments of the present specification also provide a computer program product, which at least includes a computer program, and when the computer program is executed by a processor, the following method steps are implemented: using a preset target plug-in, scanning a target workspace, determining a target document, and image resources; wherein the preset target plug-in matches the target document; establishing first map object data about the image resource based on the target document; determining a resource type of the image resource based on the first map object data; wherein the resource type includes at least one of the following: local image resources used by the target project, image resources not used by the target project, and Internet image resources used by the target project; determining a matching target processing rule based on the resource type of the image resource; and processing the corresponding image resource based on the matching target processing rule.

[0226] See also Fig.10 As shown, the embodiment of this specification also provides a data processing device for document image resources, which may specifically include the following structural modules:

[0227] The scanning module 1001 may be specifically used to scan a target workspace using a preset target plug-in to determine a target document and a picture resource; wherein the preset target plug-in matches the target document;

[0228] The establishment module 1002 may be specifically used to establish first map object data about the image resource according to the target document;

[0229] The first determination module 1003 may be specifically configured to determine a resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: a local image resource used by the target project, an image resource not used by the target project, and an Internet image resource used by the target project;

[0230] The second determination module 1004 may be specifically used to determine a matching target processing rule according to a resource type of the image resource;

[0231] The processing module 1005 may be specifically used to process corresponding image resources according to the matched target processing rules;

[0232] Among them, the first determination module 1003 can be specifically used to determine the element corresponding to the image resource in the first map object data; obtain the value of the element and the first storage path in the key value of the element; determine the resource type of the image resource based on the value of the element and the first storage path in the key value of the element.

[0233] In some embodiments, the target document may specifically include: a markdown document;

[0234] Accordingly, the target project may include: a markdown project, and the preset target plug-in may include: a VS Code plug-in.

[0235] In some embodiments, when the above-mentioned scanning module 1001 is implemented, the preset target plug-in can be used in the following manner to scan the target workspace, determine the target document, and image resources related to the target document: call the first interface, scan the target workspace, determine the target document, and image resources; wherein the first interface includes: vscode.workspace.findFiles API.

[0236] In some embodiments, when the above-mentioned establishment module 1002 is implemented, the first map object data about the image resource can be established according to the target document in the following manner: initialize the first map object data according to the image resource; wherein the first map object data includes multiple elements, each element corresponds to an image resource, and the element also includes a corresponding key value and a value value, the key value is used to indicate whether the corresponding image resource is used by the target project, and the value value is used to store the storage path of the corresponding image resource; traverse each target document; and call a preset program to obtain the text content of the target document through the second interface; use the corresponding regular expression to process the text content of the target document to determine the image resource referenced by the target document as the image resource used by the target project; and set the value value of the corresponding element in the first map object data to the first data value; according to the text content of the target document, obtain the storage path of the image resource used by the target project as the first storage path; and write the first storage path into the key value of the corresponding element in the first map object data.

[0237] In some embodiments, when the above-mentioned first determination module 1003 is implemented, the resource type of the image resource can be determined according to the first map object data in the following manner: detect whether the value of the element is the first data value, and whether there is a key character segment in the first storage path in the key value of the element; when it is determined that the value of the element is the first data value and there is no key character in the first storage path in the key value of the element, determine that the resource type of the image resource corresponding to the element is the local image resource used by the target project.

[0238] In some embodiments, after detecting whether the value of the element is the first data value and whether there is a keyword character segment in the first storage path in the key value of the element, the device, when implemented specifically, can also be used to: when it is determined that the value of the element is the second data value, determine that the resource type of the image resource corresponding to the element is an image resource not used by the target project; or, when it is determined that the value of the element is the first data value and there are keyword characters in the first storage path in the key value of the element, determine that the resource type of the image resource corresponding to the element is an Internet image resource used by the target project.

[0239] In some embodiments, when the resource type of the image resource is an image resource that is not used in the target project, when the above-mentioned processing module 1005 is specifically implemented, the corresponding image resource can be processed in the following manner according to the matching target processing rules: according to the matching target processing rules, using the third interface, a new spare folder is created in the target project; the key value of the element corresponding to the image resource in the first map object data is queried to obtain the first storage path of the image resource; the storage path of the target document is obtained as the second storage path; the first storage path and the second storage path are concatenated to obtain a joint storage path for the image resource; according to the joint storage path of the image resource, the image resource is moved to the spare folder for storage.

[0240] In some embodiments, when the resource type of the image resource is a local image resource used by the target project, when the above-mentioned processing module 1005 is specifically implemented, the corresponding image resource can be processed in the following manner according to the matching target processing rules: based on the first map object data, a second map object data corresponding to the local image resource used by the target project is established; a matching target static resource storage server is determined; and a target security credential corresponding to the target static resource storage server is obtained; a target storage request carrying the image resource and the target security credential is generated; and the target storage request is sent to the target static resource storage server; wherein, the target static resource storage server, upon determining that the target security credential verification has passed and the image resource storage has been successful, feeds back the network storage path of the image resource; receives the network storage path of the image resource; and updates the relevant information about the image resource in the target document according to the network storage path of the image resource.

[0241] In some embodiments, when the above-mentioned processing module 1005 is implemented, a target storage request carrying image resources and target security credentials can be generated in the following manner: according to the first map object data, the joint storage path of the image resources is obtained; according to the joint storage path of the image resources, the corresponding image resources in the target document are read using the fourth interface, and converted into corresponding binary data; the binary data is buffered to generate a corresponding intermediate data object; and the target security credentials are used to configure the specified fields in the request header; the intermediate data object and the request header are combined to generate a corresponding POST request as a target storage request.

[0242] In some embodiments, when the processing module 1005 is implemented, the target storage request may be sent to the target static resource storage server in the following manner: the target storage request is sent to the target static resource storage server using the fifth interface; wherein the fifth interface includes an Upload Image API.

[0243] In some embodiments, when the resource type of the image resource is an Internet image resource used by the target project, when the above-mentioned processing module 1005 is implemented, the corresponding image resource can be processed in the following manner according to the matching target processing rules: according to the matching target processing rules, the relevant information about the image resource in the target document is kept unchanged.

[0244] It should be noted that the units, devices or modules described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. For the convenience of description, the above devices are described separately by functions divided into various modules. Of course, when implementing this specification, the functions of each module can be implemented in the same or more software and / or hardware, or the modules that implement the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0245] As can be seen from the above, the data processing device for document image resources provided in the embodiment of this specification can automatically detect and distinguish different types of image resources related to the target document, and automatically complete matching data processing for different types of image resources efficiently and accurately, so that the corresponding business processing can be better completed based on the processed image resources in the future, which simplifies user operations, reduces the user's workload, and improves the overall data processing efficiency.

[0246] In a specific scenario example, the document image resource data processing method provided in this specification can be applied to realize the automatic processing of the image resources of the markdown file (for example, the target document) based on VS Code. The specific implementation process may include the following contents.

[0247] In this scenario example, before specific implementation, refer to Fig.11 As shown, you can deploy a VS Code plugin (e.g., a preset target plugin) in the following ways.

[0248] S1: Initialize the plug-in project.

[0249] Specifically, you can set the project's name, description, publisher and other information.

[0250] S2: Install plugin dependencies.

[0251] Specifically, you can install necessary development dependencies such as TypeScript and @types / vscode to support writing plugins in TypeScript.

[0252] S3: Define the plugin contributions point.

[0253] Specifically, in Visual Studio Code (VS Code) plugin development, "contributes points" refer to the extensions or custom features that a plugin provides to the editor through a specific configuration section in its package.json file. The contributions field in package.json declares that the plugin is activated when the developer executes a specific command.

[0254] S4: Implement plugin logic.

[0255] Specifically, it can quickly and accurately scan the dependencies in the front-end project and provide feedback on the dependencies with security vulnerabilities.

[0256] S5: Package and publish the plugin.

[0257] In this scenario example, the above plug-in will register a command (such as mdImgUpload). The developer (for example, the user) presses Cmd+Shift+P on a Mac computer or Ctrl+Shift+P on a Windows computer to open the command panel, and the developer enters mdImgUpload to start the dependency analysis process.

[0258] For specific implementation, see Fig.12 As shown, the following contents may be included.

[0259] S1: Obtain local image resources (eg, local image resources used by the target project) used by a markdown project (eg, a target project).

[0260] S2: Move image resources not used by the markdown project (for example, image resources not used by the target project) to other folders.

[0261] S3: Upload the local image resources used by the markdown project to the static resource object storage server.

[0262] S4: Replace the local image resources used in the markdown project with Internet resources.

[0263] When the above S1 is implemented, refer to Fig.13 As shown, the following contents may be included.

[0264] (1) Use the vscode.workspace.findFiles API to search for markdown files in the current workspace and record the found files as markdownFiles.

[0265] (2) Common image formats include BMP, GIF, JPEG, PNG, TIFF, PSD, PSB, WEBP, SVG, HEIC / HEIF, ICO, CUR, RAW (as well as camera brand-specific CR2, NEF, ARW, etc.), DNG, etc. These formats are suitable for different application scenarios, such as BMP and TIFF for lossless storage, JPEG and WEBP for compressed photos, PNG for web graphics and transparency requirements, SVG for vector graphics, RAW for professional photography post-processing, ICO and CUR for operating system icons and cursors, and DNG as an open cross-vendor RAW standard. In addition, there are image formats for specific fields such as DICOM, TIFF-F, OME-TIFF, etc.

[0266] Use vscode.workspace.findFiles API to find all image files in the current workspace (workspace), recorded as imageFiles (type is array). Initialize a Map object (recorded as imagesFileMap), this object stores whether the image resources in the markdown project are actually used, loop through each imageFiles (recorded as imageFileItem), the key of each element of the Map object stores the actual path of the imageFileItem (can be obtained through the fsPath property of imageFileItem), and the value is assigned to false (the mark is initialized as not being used).

[0267] (3) In specific implementation, you can traverse each markdown file (denoted as markdownFileItem), use vscode.workspace.openTextDocument to open the markdown file, and use the getText API to obtain the markdown file content, namely markdownFileContent. According to the image resource reference format in markdown, use regular expressions to find image resources in the markdown project. The regular expression for image resource reference in markdown is: ( / !\[.*\]\((.*)\) / g. Use regular expressions to find the introduced image resources in markdownFileContent, denoted as imageFilesPath. imageFilesPath is an array because it may include the use of multiple images. When the length of imageFilesPath is not 0 (that is, imageFilesPath is not an empty array), it means that this markdown file has referenced images.

[0268] Loop through each imageFilesPath, record it as imageFileItemPath, if imageFileItemPath contains http string, such as the example picture! [This is a network picture] (http: / / example.com / images / example.jpg "Picture title"), it means that an image resource on the Internet is introduced, and the image resource on the Internet does not need to be processed (that is, it has been uploaded to the Internet). If imageFileItemPath does not contain http string, it means that a local image is introduced, such as '! [This is a local picture] (. / images / example.jpg "Picture title")', get the image address (recorded as imageLocalPath) (i.e. . / images / example.jpg) through regular expression, get the actual address of the image (recorded as imageAbsolutePath) by splicing the address of the markdown file (markdownFileItem) and the address of the introduced image (imageLocalPath), and assign the value of the imageAbsolutePath property of the imagesFileMap object (the property of this actual address already exists in the imagesFileMap property) to true, which indicates that this image resource has been used.

[0269] When implementing S2 above, please refer to Fig.14 As shown, the following contents may be included.

[0270] (1) Create a new directory in the markdown project directory to store unused image resources, and use the fs mkdirSync API to create an image-unused folder (if the folder already exists, you do not need to create it).

[0271] (2) Traverse the imagesFileMap in Section 1.3.1. If the attribute value (i.e., value) is false, it means that the image has not been referenced. Get the key (i.e., the path of the image resource) whose value is false and save it to unusedImageFiles (type is an array).

[0272] (3) Traverse unusedImageFiles and use the renameSync API of fs to move unreferenced image resources to the image-unused folder.

[0273] For the specific implementation of the above S3, please refer to Fig.15 As shown, the following contents may be included.

[0274] (1) Create a new Map object (referred to as imagesUploadFilesMap) to save all the image resources to be uploaded to the object storage server. Traverse the imagesFileMap. If the attribute value (i.e., value) is true, it means that this image is the image required for the markdown project. Get the element with value true and save it in imagesUploadFilesMap (type is array).

[0275] (2) As described in the background technology, static resource object storage has many advantages. In this section, we upload the image resources used in the markdown project to the static resource object storage server.

[0276] Common static resource object storages such as XXX Cloud Storage, YYY Cloud OSS, etc. are suitable for storing and efficiently distributing static resources such as images.

[0277] In this scenario example, you can upload to the static resource object storage by default. The static resource object storage provides the function of uploading and hosting pictures. When uploading pictures, a token is required. The token refers to a security credential obtained by the user when registering or creating an application on the static resource object storage platform. It is used for identity authentication and authorization to access the API interface of the static resource object storage. Among them, the plug-in user needs to log in to the corresponding static resource object storage, register as a platform user, and apply for a token (referred to as imgToken) online.

[0278] Loop through the properties (recorded as imagesUploadFileItemPath) of each element (recorded as imagesUploadFileItem) of imagesUploadFilesMap (i.e., the path of each image resource to be uploaded), use fs's readFileSync API to read the file content (recorded as imageData), and create a FormData object (recorded as formData). FormData is a browser native JavaScript object that can easily encapsulate the data of form fields (including file input fields) and allow these data to be sent to the server in multipart / form-data encoding format when making asynchronous POST requests through XMLHttpRequest or Fetch API. Buffer imageData and add it to formData. Configure the Authorization field in the request header with a value of imgToken. According to the Upload Image API (https: / / doc.sm.ms / #api-Image-Upload) interface, use axios's POST request to upload the image resources to the static resource object storage server through the https: / / sm.ms / api / v2 / upload interface. If the upload is successful, the Internet address of the image will be returned, and the value of imagesUploadFileItem will be updated to the Internet address. If the upload is unsuccessful, it will be returned without processing. After this step, imagesUploadFilesMap records the mapping relationship between the actual path and the Internet address of each image.

[0279] Through the above scenario examples, the data processing method of document image resources provided in this manual has been verified. (1) The image resources of the markdown project can be quickly found through the plug-in, and the image resources can be automatically uploaded. The useless images can be deleted after being summarized. The processing efficiency is high, accurate, and there is no omission, and no manual processing is required. At the same time, the object storage of local image resources is realized, the loading speed of markdown file images is improved, and security and access control are improved.

[0280] Although the present specification provides method operation steps as described in the embodiments or flow charts, more or less operation steps may be included based on conventional or non-creative means. The order of steps listed in the embodiments is only one way of executing the order of many steps, and does not represent a unique execution order. When the device or client product in practice is executed, it can be executed in sequence or in parallel according to the method shown in the embodiments or the drawings (for example, a parallel processor or a multi-threaded processing environment, or even a distributed data processing environment). The term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, product or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such a process, method, product or device. In the absence of more restrictions, it is not excluded that there are other identical or equivalent elements in the process, method, product or device including the elements. The first, second, etc. words are used to represent the name, and do not represent any particular order.

[0281] Those skilled in the art also know that, in addition to implementing the controller in a purely computer-readable program code, the controller can be made to implement the same function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, such a controller can be considered as a hardware component, and the devices for implementing various functions included therein can also be considered as structures within the hardware component. Or even, the devices for implementing various functions can be considered as both software modules for implementing the method and structures within the hardware component.

[0282] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, classes, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer-readable storage media including storage devices.

[0283] Through the description of the above embodiments, it can be known that those skilled in the art can clearly understand that the present specification can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present specification can essentially be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a mobile terminal, a server, or a network device, etc.) to execute the methods described in each embodiment of the present specification or some parts of the embodiments.

[0284] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. This specification can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor systems, microprocessor-based systems, set-top boxes, programmable electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc.

[0285] Although the present specification is described through embodiments, those skilled in the art will appreciate that there are many modifications and changes to the present specification without departing from the spirit of the present specification, and it is intended that the appended claims include these modifications and changes without departing from the spirit of the present specification.

Claims

1. A data processing method for document image resources, characterized in that: include: Using a preset target plug-in, scanning a target workspace, and determining a target document and image resources; wherein the preset target plug-in matches the target document; According to the target document, create the first map object data about the image resource; Determine the resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: a local image resource used by the target project, an image resource not used by the target project, and an Internet image resource used by the target project; According to the resource type of the image resource, determine the matching target processing rule; Process the corresponding image resources according to the matching target processing rules; Among them, determining the resource type of the image resource according to the first map object data includes: determining the element corresponding to the image resource in the first map object data; obtaining the value of the element and the first storage path in the key value of the element; determining the resource type of the image resource according to the value of the element and the first storage path in the key value of the element.

2. The method according to claim 1, characterized in that The target document includes: a markdown document; Correspondingly, the target projects include: markdown projects, and the preset target plug-ins include: VS Code plug-ins.

3. The method according to claim 2, characterized in that Use the preset target plug-in to scan the target workspace and identify the target documents and image resources, including: The first interface is called to scan the target work area to determine the target document and image resources; wherein the first interface includes: vscode.workspace.findFiles API.

4. The method according to claim 2, characterized in that: According to the target document, create the first map object data about the image resource, including: Initialize first map object data according to the image resource; wherein the first map object data includes multiple elements, each element corresponds to an image resource, and each element further includes a corresponding key value and a value value, wherein the key value is used to indicate whether the corresponding image resource is used by the target project, and the value value is used to store the storage path of the corresponding image resource; Traversing each target document; and calling a preset program to obtain the text content of the target document through a second interface; By using the corresponding regular expression and processing the text content of the target document, the image resource referenced by the target document is determined as the image resource used by the target project; and the value of the corresponding element in the first map object data is set to the first data value; According to the text content of the target document, the storage path of the image resource used by the target project is obtained as the first storage path; and the first storage path is written into the key value of the corresponding element in the first map object data.

5. The method according to claim 4, characterized in that According to the first map object data, the resource type of the image resource is determined, including: Check whether the value of the element is the first data value and whether the first storage path in the key value of the element has a key character segment; When it is determined that the value of the element is the first data value and the first storage path in the key value of the element does not have a key character, it is determined that the resource type of the image resource corresponding to the element is a local image resource used by the target project.

6. The method according to claim 5, characterized in that After detecting whether the value of the element is the first data value and whether the first storage path in the key value of the element has a key character segment, the method further includes: When it is determined that the value of the element is the second data value, determining that the resource type of the image resource corresponding to the element is an image resource not used by the target project; Or, when it is determined that the value of the element is the first data value and there are key characters in the first storage path in the key value of the element, it is determined that the resource type of the image resource corresponding to the element is an Internet image resource used by the target project.

7. The method according to claim 2, characterized in that When the resource type of the image resource is an image resource that is not used by the target project, the corresponding image resource is processed according to the matching target processing rule, including: According to the matching target processing rules, a new spare folder is created in the target project using the third interface; Query the key value of the element corresponding to the image resource in the first map object data to obtain the first storage path of the image resource; obtain the storage path of the target document as the second storage path; Concatenate the first storage path and the second storage path to obtain a joint storage path for the image resource; According to the joint storage path of the image resource, the image resource is moved to the backup folder for storage.

8. The method according to claim 2, characterized in that: When the resource type of the image resource is a local image resource used by the target project, the corresponding image resource is processed according to the matching target processing rule, including: According to the first map object data, second map object data corresponding to the local image resource used by the target project is established; Determine a matching target static resource storage server; and obtain a target security credential corresponding to the target static resource storage server; Generate a target storage request that carries the image resource and the target security credential; and send the target storage request to the target static resource storage server; wherein, when determining that the target security credential verification has passed and the image resource storage has succeeded, the target static resource storage server feeds back the network storage path of the image resource; Receive the network storage path of the image resource; and update the relevant information about the image resource in the target document according to the network storage path of the image resource.

9. The method according to claim 8, characterized in that Generate a target storage request that carries the image resource and target security credentials, including: According to the first map object data, obtain the joint storage path of the image resource; According to the joint storage path of the image resource, the corresponding image resource in the target document is read using the fourth interface and converted into corresponding binary data; Buffer the binary data to generate a corresponding intermediate data object; and use the target security credentials to configure the specified field in the request header; The intermediate data object and the request header are combined to generate the corresponding POST request as the target storage request.

10. The method according to claim 8, characterized in that Sending the target storage request to the target static resource storage server includes: The target storage request is sent to the target static resource storage server by using the fifth interface; wherein the fifth interface includes the Upload Image API.

11. The method according to claim 1, characterized in that: When the resource type of the image resource is an Internet image resource used by the target project, the corresponding image resource is processed according to the matching target processing rule, including: According to the matching target processing rules, the relevant information about the image resource in the target document is kept unchanged.

12. A data processing device for document image resources, characterized in that: include: A scanning module, used to scan a target workspace using a preset target plug-in to determine a target document and image resources; wherein the preset target plug-in matches the target document; A creation module, used for creating first map object data about the image resource according to the target document; A first determination module is used to determine a resource type of the image resource according to the first map object data; wherein the resource type includes at least one of the following: a local image resource used by the target project, an image resource not used by the target project, and an Internet image resource used by the target project; The second determination module is used to determine a matching target processing rule according to the resource type of the image resource; A processing module is used to process corresponding image resources according to the matching target processing rules; Among them, the first determination module is specifically used to determine the element corresponding to the image resource in the first map object data; obtain the value of the element and the first storage path in the key value of the element; determine the resource type of the image resource based on the value of the element and the first storage path in the key value of the element.

13. A server, characterized in that: The method comprises a processor and a memory for storing processor-executable instructions, wherein the processor implements the steps of the method according to any one of claims 1 to 11 when executing the instructions.

14. A computer-readable storage medium, characterized in that: Computer instructions are stored thereon, and when the instructions are executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.

15. A computer program product, characterized in that The invention comprises a computer program, which implements the steps of the method according to any one of claims 1 to 11 when being executed by a processor.