A file preview method and device, electronic equipment, computer readable storage medium and computer program product
By employing a layered selection of first and second previewers during the file preview process, the problem of preview failures was resolved, improving the success rate and stability of file previews.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2024-12-17
- Publication Date
- 2026-06-19
AI Technical Summary
In existing technologies, file previews often fail, affecting the success rate and stability of file previews.
By pre-dividing the first and second previewers during file preview, the system first searches for the first previewer corresponding to the target file type. If the first previewer fails, the second previewer is searched for and previewed, thus achieving hierarchical selection of previewers.
The success rate and stability of file preview have been improved, ensuring that files can still be successfully previewed through a second previewer even if the first previewer fails.
Smart Images

Figure CN122240572A_ABST
Abstract
Description
Technical Field
[0001] This application relates to document processing technology in the field of computer applications, and more particularly to a document preview method, apparatus, electronic device, computer-readable storage medium, and computer program product. Background Technology
[0002] File preview refers to the function of displaying file content directly in a specified interface without opening specific software; file preview can improve file processing efficiency, for example, it allows you to quickly view the contents of a file before processing it.
[0003] Generally, file previewing is achieved through a previewer that corresponds to the file type of the file to be previewed; however, when previewing a file through a previewer that corresponds to the file type of the file to be previewed, preview failures often occur, affecting the success rate and stability of file previewing. Summary of the Invention
[0004] This application provides a file preview method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can improve the success rate and stability of file preview.
[0005] The technical solution of this application embodiment is implemented as follows:
[0006] This application provides a file preview method, the method including:
[0007] In response to a file preview request for a file to be previewed, obtain the target file type of the file to be previewed;
[0008] Find the first previewer corresponding to the target file type and obtain the previewer search results;
[0009] When it is determined that the preview of the file to be previewed has failed based on the previewer search results, a second previewer corresponding to the target file type is searched to obtain the target second previewer. The first previewer and the second previewer are implemented in different ways.
[0010] The target second previewer is used to preview the file to be previewed.
[0011] This application provides a file preview device, the file preview device comprising:
[0012] The type acquisition module is used to obtain the target file type of the file to be previewed in response to a file preview request.
[0013] The preview search module is used to find the first previewer corresponding to the target file type and obtain the previewer search results.
[0014] The preview search module is also used to search for a second previewer corresponding to the target file type when the preview of the file to be previewed fails to be previewed based on the previewer search result, and to obtain the target second previewer. The first previewer and the second previewer are implemented in different ways.
[0015] The file preview module is used to preview the file to be previewed based on the target second previewer.
[0016] In this embodiment of the application, the file preview device further includes a result determination module, which is used to determine that the preview of the file to be previewed has failed when the previewer search result indicates that the first previewer search corresponding to the target file type has failed.
[0017] In this embodiment of the application, the result determination module is further configured to preview the file to be previewed based on the target first previewer when the previewer search result indicates that a target first previewer has been found; and to determine that the preview of the file to be previewed has failed based on the previewer search result when the preview of the file to be previewed fails through the target first previewer.
[0018] In this embodiment of the application, the file preview module is further configured to instantiate the target second previewer to obtain an instantiated previewer; and to preview the file to be previewed based on the instantiated previewer.
[0019] In this embodiment of the application, the file preview module is further configured to: destroy the instantiated previewer when the preview of the file to be previewed is completed; obtain a new second previewer corresponding to the new preview file in response to a new file preview request; instantiate the new second previewer to obtain a new instantiated previewer; and preview the new preview file based on the new instantiated previewer.
[0020] In this embodiment of the application, the file preview module is further configured to determine whether the target file type is a portable file type when the preview of the file to be previewed is completed; and to destroy the instantiated previewer when the target file type is different from the portable file type.
[0021] In this embodiment of the application, the file preview module is further configured to retain the instantiated previewer when the target file type is the portable file type.
[0022] In this embodiment of the application, the file preview module is further configured to, upon completion of the preview of the file to be previewed, respond to a new file preview request for a new file and obtain the new file type of the new file; when the new file type is the target file type, preview the new file using the instantiated previewer; when the new file type is different from the target file type, preview the new file based on the first previewer corresponding to the new file type, and destroy the instantiated previewer after a specified time has elapsed since the preview of the file to be previewed is completed.
[0023] In this embodiment of the application, the file preview module is further configured to construct an instantiated preview handle based on the target second previewer when the second previewer is a preview interface corresponding to an installed application, wherein the installed application refers to an installed application used to process the corresponding file type; and to determine the instantiated preview handle as the instantiated previewer.
[0024] In this embodiment of the application, the file preview module is further configured to obtain the first file size of the file to be previewed when the target file type is a document type; when the first file size is greater than the document size threshold, the target second previewer reads the file stream of the file to be previewed through a first thread and previews the read file stream through a second thread, wherein the first thread and the second thread are asynchronous threads.
[0025] In this embodiment of the application, the file preview module is further configured to, when the target file type is compressed, obtain the number of files to be previewed before a specified level in the file to be previewed based on the target second previewer; when the number of files to be previewed is greater than a file number threshold, determine the highest level where the total number of files is less than the file number threshold, and preview the file to be previewed by performing the following process: displaying the names of each file before the highest level and the level where each file name is located.
[0026] In this embodiment of the application, the file preview module is further configured to: when the target file type is an image type, obtain the second file size of the file to be previewed based on the target second previewer; when the second file size is greater than the image size threshold, obtain a compressed image of the file to be previewed; and preview the file to be previewed by displaying the compressed image.
[0027] In this embodiment of the application, the file preview module is further configured to display a file details control of the file to be previewed; in response to a trigger operation on the file details control, obtain file details information of the file to be previewed, the file details information including at least one of the following: file name, file path, target file type, file size, creation time, modification time, access time, and extended information corresponding to the target file type; and display the file details information.
[0028] In this embodiment of the application, the file preview module is further configured to obtain the file icon of the file to be previewed when the preview of the file to be previewed fails; and display the file icon of the file to be previewed in the file content preview area.
[0029] In this embodiment of the application, the preview search module is further configured to search for the first previewer corresponding to the target file type based on the first correspondence between the file type and the first previewer, and obtain the previewer search result.
[0030] In this embodiment of the application, the file preview device further includes a relationship determination module, which is used to generate a corresponding custom previewer for each of the file types when the first previewer is a custom previewer; obtain each custom previewer corresponding to each file type from the custom previewer corresponding to each file type; and determine the first correspondence relationship between the file type and the first previewer based on each custom previewer corresponding to each file type.
[0031] In this embodiment of the application, the relationship determination module is further configured to, in response to the installation of the file processing application, obtain the preview interface of the installed application when the first previewer is a preview interface corresponding to an installed application; determine the file type corresponding to the installed application; and determine the first correspondence relationship between the file type and the first previewer based on the preview interface and the file type.
[0032] In this embodiment of the application, the preview search module is further configured to search for a second previewer corresponding to the target file type based on a second correspondence between file type and second previewer, thereby obtaining the target second previewer.
[0033] In this embodiment of the application, the file preview module is further configured to, when the preview of the file to be previewed fails and the second previewer is a preview interface corresponding to an installed application, update the second correspondence based on a specified second correspondence to obtain an updated second correspondence; determine a new preview interface corresponding to the target file type based on the updated second correspondence; and preview the file to be previewed based on the new preview interface.
[0034] This application provides an electronic device for file preview, the electronic device comprising:
[0035] Memory is used to store executable instructions or computer programs.
[0036] The processor, when executing computer-executable instructions or computer programs stored in the memory, implements the file preview method provided in the embodiments of this application.
[0037] This application provides a computer-readable storage medium storing computer-executable instructions or computer programs, which, when executed by a processor, implement the file preview method provided in this application.
[0038] This application provides a computer program product, including computer-executable instructions or a computer program, which, when executed by a processor, implements the file preview method provided in this application.
[0039] The embodiments of this application have at least the following beneficial effects: Since a first previewer and a second previewer are pre-defined based on the implementation method of the previewer before file preview, when responding to a file preview request, the system first searches for the first previewer corresponding to the target file type of the file to be previewed. If previewing the file using the first previewer fails, the file can still be previewed using the second previewer corresponding to the target file type. Thus, the first previewer is selected as the first layer for file previewing, and the second previewer is selected as the second layer, achieving a layered previewer system. This ensures that even if the first previewer fails to preview the file, the file can still be previewed using the second previewer. Therefore, the success rate and stability of file previewing can be improved. Attached Figure Description
[0040] Figure 1 This is a schematic diagram of the architecture of the file preview system provided in the embodiments of this application;
[0041] Figure 2This is one of the embodiments provided in this application. Figure 1 A schematic diagram of the terminal structure in the diagram;
[0042] Figure 3 This is a flowchart illustrating the file preview method provided in the embodiments of this application. Figure 1 ;
[0043] Figure 4 This is a flowchart illustrating the process of previewing a file to be previewed, provided in an embodiment of this application.
[0044] Figure 5 This is an exemplary file preview logic flowchart provided in an embodiment of this application;
[0045] Figure 6 This is a flowchart illustrating the file preview method provided in the embodiments of this application. Figure 2 ;
[0046] Figure 7 This is a flowchart illustrating the file preview method provided in the embodiments of this application. Figure 3 ;
[0047] Figure 8 This is an exemplary file preview architecture diagram provided in an embodiment of this application;
[0048] Figure 9 This is an exemplary file preview logic flowchart provided in an embodiment of this application;
[0049] Figure 10 This is a schematic diagram of an exemplary file search tool provided in an embodiment of this application;
[0050] Figure 11 This is a schematic diagram of an exemplary search result interface provided in an embodiment of this application;
[0051] Figure 12 This is a schematic diagram of an exemplary file preview interface provided in an embodiment of this application;
[0052] Figure 13 This is another exemplary file preview interface diagram provided in the embodiments of this application. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0054] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0055] In the following description, the terms “first”, “second”, etc. are used to distinguish similar objects and do not represent a specific ordering of objects. It is understood that “first”, “second”, etc., may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0056] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0057] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.
[0058] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.
[0059] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0060] 1) A file is a collection of data stored on a computer or related device, which can be text, images, audio, video, or other forms of data. Structurally, a file consists of a filename and an extension (also known as a file extension). The filename identifies the file, and the extension indicates the file type or format. Files can be stored on storage media such as hard drives, solid-state drives, optical discs, and flash drives, and their content can be program code, document text, multimedia data, etc. Files can be created, edited, deleted, copied, and moved using electronic devices. This application describes a preview of a file before it is processed.
[0061] 2) File preview refers to the function of displaying part or all of the content of a file directly in a specified interface without opening specific software. This is different from viewing a file by opening it. File preview allows users to quickly view the content of a file before processing it, thereby determining whether to proceed with further processing and improving file processing efficiency.
[0062] 3) File type, also known as file format, is determined by different encoding methods. For example, image files and text files are encoded into different data formats to facilitate identification and processing by electronic devices. The file type can be determined by the file extension or by a combination of the file extension and the file content. The file extension is located after the dot (.) in the file name and is used to quickly identify the file type. For example, ".txt" indicates a text file, and ".jpg" indicates an image file.
[0063] 4) Previewer, used to preview files of the corresponding file type, including program code library and preview logic for previewing files of the corresponding file type; different previewers are used to preview different text types, for example, text previewer is used to preview text type files, and audio previewer is used to preview audio type files.
[0064] 5) Preview breadth, also known as preview coverage, represents the percentage of the total number of files that can be previewed.
[0065] 6) In response to, used to indicate the conditions or states on which the operation performed depends. When the conditions or states on which it depends are met, one or more operations performed may be performed in real time or with a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations are performed.
[0066] The following explains the relevant technologies for file preview.
[0067] It should be noted that because electronic devices contain various file types, products that support file preview typically use different previewers for different file types. However, when previewing a file using a previewer corresponding to the file type of the file being previewed, preview failures often occur, affecting the success rate and stability of file previews.
[0068] Based on this, embodiments of this application provide a file preview method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can improve the success rate and stability of file preview. The following describes exemplary applications of the electronic device for file preview (hereinafter referred to as the file preview device) provided in embodiments of this application. The file preview device provided in embodiments of this application can be implemented as various types of terminals such as robots, smartphones, smartwatches, laptops, tablets, desktop computers, smart home appliances, set-top boxes, smart in-vehicle devices, portable music players, personal digital assistants, dedicated messaging devices, intelligent voice interaction devices, portable gaming devices, and smart speakers, or it can be implemented as a server. The following will describe exemplary applications when the file preview device is implemented as a terminal.
[0069] See Figure 1 , Figure 1 This is a schematic diagram of the architecture of the file preview system provided in the embodiments of this application; as shown Figure 1 As shown, to support a file preview application, in the file preview system 100, a terminal 400 (terminals 400-1 and 400-2 are shown as examples) connects to a server 200 via a network 300; wherein, the network 300 can be a wide area network (WAN), a local area network (LAN), or a combination of both; the server 200 is used to provide computing services to the terminal 400 via the network 300, for example, providing the terminal 400 with a first mapping relationship and a second mapping relationship. In addition, the file preview system 100 also includes a database 500 for providing data support to the server 200; and... Figure 1 The example shown illustrates a scenario where the database 500 is independent of the server 200. However, the database 500 can also be integrated into the server 200, and this embodiment does not limit this to any particular case.
[0070] Terminal 400 is configured to respond to a file preview request for a file to be previewed (graphical interface 400-11 is shown as an example), obtain the target file type of the file to be previewed; based on the first correspondence between the file type and the first previewer, search for the first previewer corresponding to the target file type and obtain the previewer search result; when it is determined that the preview of the file to be previewed fails based on the previewer search result, based on the second correspondence between the file type and the second previewer, search for the target second previewer corresponding to the target file type; and preview the file to be previewed based on the target second previewer (graphical interface 400-21 is shown as an example).
[0071] In some embodiments, server 200 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Terminals and servers can be connected directly or indirectly via wired or wireless communication, which is not limited in this embodiment.
[0072] See Figure 2 , Figure 2 This is one of the embodiments provided in this application. Figure 1 A schematic diagram of the terminal structure in the diagram; such as Figure 2 As shown, terminal 400 includes at least one processor 410, memory 450, at least one network interface 420, and user interface 430. The various components in terminal 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to implement communication between these components. In addition to a data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in… Figure 2 The general labeled all buses as Bus System 440.
[0073] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0074] User interface 430 includes one or more output devices 431 that enable the presentation of media content, including one or more speakers and / or one or more visual displays. User interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
[0075] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices physically located away from the processor 410.
[0076] The memory 450 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 450 described in this application embodiment is intended to include any suitable type of memory.
[0077] In some embodiments, memory 450 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.
[0078] Operating system 451 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;
[0079] The network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 including: Bluetooth, Wi-Fi, and Universal Serial Bus (USB), etc.
[0080] Presentation module 453 is configured to enable the presentation of information (e.g., a user interface for operating peripheral devices and displaying content and information) via one or more output devices 431 (e.g., a display screen, a speaker, etc.) associated with user interface 430;
[0081] The input processing module 454 is used to detect and translate one or more user inputs or interactions from one or more input devices 432.
[0082] In some embodiments, the file preview device provided in this application can be implemented in software. Figure 2 A file preview device 455 stored in memory 450 is shown. This device can be software in the form of programs or plug-ins, and includes the following software modules: a type acquisition module 4551, a preview search module 4552, a file preview module 4553, a result determination module 4554, and a relationship determination module 4555. These modules are logically connected and can therefore be arbitrarily combined or further separated according to their implemented functions. The functions of each module will be described below.
[0083] In some embodiments, the file preview device provided in this application can be implemented in hardware. As an example, the file preview device provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the file preview method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.
[0084] In some embodiments, the terminal or server can implement the file preview method provided in this application by running various computer-executable instructions or computer programs. For example, computer-executable instructions can be microprogram-level commands, machine instructions, or software instructions. Computer programs can be native programs or software modules in an operating system; they can be native applications (APPs), i.e., programs that need to be installed in the operating system to run, such as file search APPs or device security APPs; or they can be applets that can be embedded in any APP, i.e., programs that only need to be downloaded to a browser environment to run. In summary, the aforementioned computer-executable instructions can be any form of instruction, and the aforementioned computer programs can be any form of application, module, or plugin.
[0085] The file preview method provided in this application will be described below with reference to exemplary applications and implementations of the file preview device provided in the embodiments of this application. Furthermore, the file preview method provided in the embodiments of this application is applicable to various file preview scenarios such as cloud technology, artificial intelligence, smart transportation, and in-vehicle systems.
[0086] See Figure 3 , Figure 3 This is a flowchart illustrating the file preview method provided in the embodiments of this application. Figure 1 ,in, Figure 3 The main entity executing each step is the file preview device; the following will combine... Figure 3 The steps shown are explained.
[0087] Step 101: In response to the file preview request of the file to be previewed, obtain the target file type of the file to be previewed.
[0088] In this embodiment of the application, when a file to be previewed is previewed through a file preview device, the file preview device also receives a file preview request for the file to be previewed; at this time, the file preview device responds to the file preview request, obtains the file type of the file to be previewed, and refers to the obtained file type of the file to be previewed as the target file type.
[0089] It should be noted that a file preview request refers to a request to preview a file. For example, when a preview control for a file to be previewed is triggered, or when a file preview instruction is received from another device (or another application of the file preview device), the file preview device receives a file preview request for the file to be previewed. The file to be previewed can be any type of file, such as a text file, binary file, image file, audio file, video file, executable file, compressed file, etc. Here, the file preview device can determine the target file type by the file extension, or by the file extension and the file content; this embodiment does not limit this.
[0090] Step 102: Locate the first previewer corresponding to the target file type and obtain the previewer search results.
[0091] In this embodiment of the application, the file preview device pre-obtains a first correspondence relationship representing the first previewer corresponding to each file type. The first correspondence relationship represents the correspondence between the file type and the first previewer. Therefore, after obtaining the target file type, the file preview device searches for the same file type as the target file type among the various file types included in the first correspondence relationship, so as to find the first previewer corresponding to the same file type as the target file type, that is, to obtain the previewer search result.
[0092] It should be noted that the first previewer is a previewer used to preview files of the corresponding file type. It can be a custom previewer, a preview interface of an installed application, etc., and this application embodiment does not limit this. Among them, the custom previewer refers to a file preview tool developed for a specific file type, such as a tool for previewing images for image types, or a tool for previewing videos for video types. The installed application refers to an installed application used to process (e.g., create, edit, delete, copy, and move) the corresponding file type. The installed application not only includes the function of processing the specified file type, but also the function of previewing the specified file type. The interface that calls the preview function in the installed application is the preview interface. Therefore, the custom previewer and the preview interface of the installed application are previewers obtained by different implementation methods. The custom previewer is an independent tool or component for implementing file preview, and the preview interface of the installed application is the interface that calls the preview function of the installed application. The previewer search result indicates whether a first previewer corresponding to the target file type was found. Therefore, the previewer search result can be either a first previewer corresponding to the target file type that was found, or a first previewer corresponding to the target file type that was not found.
[0093] Step 103: When it is determined from the previewer search results that the file to be previewed has failed to be previewed, find the second previewer corresponding to the target file type and obtain the target second previewer.
[0094] In this embodiment, since the previewer search result may be that no first previewer corresponding to the target file type was found, it can be determined that the preview of the file to be previewed using the first previewer has failed, i.e., the preview of the file to be previewed has failed based on the previewer search result. However, since the previewer search result may also be that a first previewer corresponding to the target file type was found, and the file preview device may also fail to preview the file to be previewed using the first previewer corresponding to the target file type, when the file preview device fails to preview the file to be previewed using the first previewer corresponding to the target file type, the preview of the file to be previewed has failed based on the previewer search result. The file preview device has pre-obtained a second correspondence representing the second previewer corresponding to each file type. This second correspondence represents the correspondence between file types and second previewers. Therefore, when the preview of the file to be previewed is determined to have failed based on the previewer search result, the file preview device continues to search for a second previewer for previewing the file to be previewed based on the second correspondence, and the found second previewer corresponding to the target file type is called the target second previewer.
[0095] It should be noted that the file preview device searches for the same file type as the target file type among the various file types included in the second correspondence, and then searches for the second previewer corresponding to the same file type as the target file type, thus finding the target second previewer. The second previewer is a previewer used to preview files of the corresponding file type. It can be a custom previewer, or it can be a preview interface of an installed application, etc. This application embodiment does not limit this, but the first previewer and the second previewer adopt different implementation methods, that is, the first previewer and the second previewer are obtained in different ways, which also indicates that the first previewer and the second previewer are different previewers. It is easy to know that this implementation method can be a custom method, that is, a method of developing a file preview tool or component for a specified file type. This implementation method can also be a method of calling the preview interface of an installed application, that is, implementing it through interface calls. Therefore, when the first previewer is a custom previewer, the second previewer is a preview interface of an installed application; and when the second previewer is a custom previewer, the first previewer is a preview interface of an installed application.
[0096] It should also be noted that when the preview of a file fails to preview based on the previewer search results, if it is because a first previewer corresponding to the target file type was found, but that first previewer failed to preview the file, then the file types in the first correspondence must be at least partially the same as the file types in the second correspondence, and the target file type must be a common file type in both the first and second correspondences. Only in this way can a second previewer corresponding to the target file type be found in the second correspondence. Here, "partially the same" means that there are common file types between the file types in the first and second correspondences. Furthermore, when the preview of a file fails to preview based on the previewer search results, if it is because no first previewer corresponding to the target file type was found, then the file types in the first and second correspondences can be completely different or partially the same, and the target file type must not belong to any of the file types in the first correspondence but belongs to any of the file types in the second correspondence. Only in this way can a second previewer corresponding to the target file type be found in the second correspondence.
[0097] Step 104: Preview the file to be previewed using the target second previewer.
[0098] In this embodiment, after obtaining the target second previewer, the file preview device begins to preview the file to be previewed based on the target second previewer. Here, the file preview device previewing the file to be previewed based on the target second previewer includes: the file preview device first instantiates the target second previewer to obtain an instantiated previewer; and then previews the file to be previewed based on the instantiated previewer.
[0099] It should be noted that instantiation refers to the process of creating a file previewer object corresponding to the target file type. When the file preview device instantiates the target second previewer, it constructs the target second previewer into a file previewer object used to preview the target file type, so as to realize the preview of the file to be previewed through the file previewer object. Instantiating the previewer is the instantiation result of the target second previewer, which is a file previewer object used to implement the preview of the file to be previewed. Here, the file previewer object represents the software component used to display the file content, such as the file previewer object's attributes (path of the file to be previewed, target file type, preview interface elements, content of the file to be previewed, and preview status indicators, etc.), executable operations (loading the file to be previewed, displaying the file to be previewed, and zooming in or out of the preview content, etc.), and triggered or responded events (interactive events such as click and scroll, and preview close events, etc.). Instantiation also includes the processing of allocating space and other resources for the file preview object. The allocated space and other resources are used to store the loaded file to be previewed.
[0100] Understandably, by instantiating the target second previewer to preview the file, the preview logic can be encapsulated in different previewer instances, improving code modularity. In addition, instantiation ensures that the correct file type is passed to the corresponding previewer instance, improving preview fault tolerance.
[0101] In this embodiment of the application, when the second previewer is the preview interface corresponding to an installed application, the file preview device instantiates the target second previewer to obtain an instantiated previewer, including: the file preview device first constructs an instantiated preview handle based on the target second previewer; and then determines the instantiated preview handle as the instantiated previewer.
[0102] It should be noted that when the second previewer is the preview interface corresponding to an installed application, the target second previewer is the target preview interface of the target installed application. The file preview device constructs an instantiated preview handle based on the target preview interface; therefore, this instantiated preview handle is the instantiated previewer, which is the instantiation result of the second previewer and is different from the second previewer. The preview interface of the installed application can be represented by a preview identifier (e.g., a class identifier CLSID), which is used to identify the module providing preview functionality within the installed application. The instantiated preview handle is used to point to a data structure or resource for temporarily storing and displaying file content for the target file type. Furthermore, the file preview device constructs the instantiated preview handle by passing the target preview interface to a function used to create component objects (e.g., the CoCreateInstance interface).
[0103] In this embodiment, when the second previewer is a custom previewer, the target second previewer is the target custom previewer. In this case, the file preview device instantiates the target second previewer using an object instance creation method (e.g., using the keyword `new` followed by an object), resulting in an object instance, which is the instantiated previewer. The object instance creation method refers to allocating internal parameters and calling the constructor for the object (i.e., the target custom previewer) using the object instance creation keyword. The constructor is used to initialize the state of the newly created object.
[0104] See Figure 4 , Figure 4 This is a flowchart illustrating the process of previewing a file to be previewed, provided in an embodiment of this application. Figure 4 The execution entity for each step is the file preview device; such as Figure 4 As shown in the embodiment of this application, step 104 can be implemented through steps 1041A and 1042A; that is, the file preview device previews the file to be previewed based on the target second previewer, including steps 1041A and 1042A. Each step will be described below.
[0105] Step 1041A: When the target file type is document, obtain the first file size of the file to be previewed.
[0106] It should be noted that the file preview device determines whether the target file type is a document type. If so, it indicates that the file to be previewed is a document to be previewed. The size of the document to be previewed is then obtained and referred to as the first file size.
[0107] Step 1042A: When the size of the first file is greater than the document size threshold, the target second previewer reads the file stream of the file to be previewed through the first thread, and previews the read file stream through the second thread.
[0108] It should be noted that the file preview device has a pre-set document size threshold, or can obtain the document size threshold. This document size threshold represents the maximum document size of the file to be previewed using a single thread; for example, it is 100 MB. This threshold can be manually set or determined based on statistical data, and this application embodiment does not limit this. Therefore, the file preview device compares the first file size with the document size threshold. When the first file size is greater than the document size threshold, it indicates that the file to be previewed is a large document file, and thus an asynchronous thread is used to preview the file. Therefore, the target second previewer reads the file stream of the file to be previewed through the first thread and previews the read file stream through the second thread. The first thread and the second thread are asynchronous threads. When the first file size is less than or equal to the document size threshold, it indicates that the file to be previewed is a small document file, and thus a single thread (such as the second thread) is used to preview the file, that is, to read the file stream of the file to be previewed and preview the file stream through a single thread.
[0109] Understandably, for large document files whose file size exceeds the document size threshold, asynchronous threads are used to read and preview the file stream of the file to be previewed. This allows the preview interface to respond through the second thread while the file stream is being read by the first thread, thus improving the smoothness of the preview interface.
[0110] See also Figure 4 In this embodiment of the application, step 104 can be implemented by steps 1041B and 1042B; that is, the file preview device previews the file to be previewed based on the target second previewer, including steps 1041B and 1042B. Each step is described below.
[0111] Step 1041B: When the target file type is compressed, obtain the number of files to be previewed before the specified level in the target second previewer.
[0112] It should be noted that the file preview device determines whether the target file type is compressed. If so, since the file preview device has pre-set a specified level for compressed files, it obtains the number of files before the specified level in the target second previewer, thus obtaining the number of files to be previewed. Here, "level" refers to the nesting depth of the files in the compressed file, and "specified level" refers to the pre-set deepest nesting depth of previewable files, such as 4. This can be manually set or determined based on statistical data; this embodiment does not limit this. The number of files to be previewed before the specified level is the total number of files from the first level to the specified level. For example, when the specified level is 4, the number of files to be previewed before the specified level is the total number of files from the first level to the fourth level. If the number of files in the first level is 20, the number of files in the second level is 30, the number of files in the third level is 10, and the number of files in the fourth level is 50, then the number of files to be previewed before the specified level is 20 + 30 + 10 + 50 = 110.
[0113] In this embodiment of the application, when the file preview device previews a compressed file, it does so by constructing a tree directory corresponding to the hierarchical structure of the compressed file. Each level of the constructed tree directory corresponds to all the files in one level of the file to be previewed. For example, the root directory of the tree directory contains all the files in the first level of the file to be previewed, the subdirectories of the root directory contain all the files in the second level of the file to be previewed, and so on.
[0114] Step 1042B: When the number of files to be previewed is greater than the file number threshold, determine the highest level where the total number of files is less than the file number threshold, and preview the files to be previewed by performing the following process: display the names of each file before the highest level and the level in which each file name is located.
[0115] It should be noted that the file preview device has a preset file number threshold for the compression type. This file number threshold represents the maximum number of files that can be previewed, such as 3000. It can be manually set or determined based on statistical data, and this application embodiment does not limit this. Here, the file preview device compares the number of files to be previewed with the file number threshold. When the number of files to be previewed is greater than the file number threshold, it indicates that there are too many files before the specified level in the files to be previewed, and previewing cannot be achieved. At this time, the file preview device can either end the preview or determine the highest level from the files to be previewed where the total number of files is less than the file number threshold, and display the file names and the level of each file before the highest level, thereby achieving the previewing of the files to be previewed. The highest level refers to the highest level where the cumulative number of files across all levels is less than the file count threshold. For example, when the file count threshold is 200, the number of files in level 1 is 50, the number of files in level 2 is 130, and the number of files in level 3 is 60. Although the number of files in level 1 is 50 < 200, it is not the highest level. However, the total number of files in levels 1 and 2 is 180 < 200, and the total number of files from level 1 to level 3 is 240 > 200. Therefore, level 2 is the highest level.
[0116] In this embodiment of the application, when the number of files to be previewed is less than or equal to the file number threshold, the file preview device previews the files by performing the following process: displaying the names of each file before the specified level and the level in which each file name is located.
[0117] It should be noted that when the file preview device determines that the number of files to be previewed is less than or equal to the file number threshold, it indicates that the number of files before the specified level is small, and it is possible to preview each file before the specified level. Therefore, the file preview device previews the files to be previewed by displaying the names of each file before the specified level and the level in which each file name belongs.
[0118] It is understandable that, since file previewing for compressed files is achieved by constructing a tree-like directory based on the hierarchical structure of the compressed files, the number of files before a specified level affects file preview performance. This embodiment of the application, when the number of files before a specified level exceeds a file count threshold, reduces the specified level to allow previewing of the file to be previewed, thereby improving the success rate of previewing compressed files while ensuring preview performance.
[0119] See also Figure 4 In this embodiment of the application, step 104 can be implemented by steps 1041C and 1042C; that is, the file preview device previews the file to be previewed based on the target second previewer, including steps 1041C and 1042C. Each step is described below.
[0120] Step 1041C: When the target file type is an image, obtain the second file size of the file to be previewed based on the target second previewer.
[0121] It should be noted that the file preview device determines whether the target file type is an image. If so, it indicates that the file to be previewed is an image, and the size of the image to be previewed is obtained. The obtained size of the image to be previewed should be referred to as the second file size.
[0122] Step 1042C: When the size of the second file is greater than the image size threshold, obtain the compressed image of the file to be previewed, and preview the file by displaying the compressed image.
[0123] It should be noted that the file preview device has a pre-set image size threshold, or can obtain an image size threshold. This image size threshold represents the maximum image size used for file previewing; for example, it is 25 MB. This threshold can be manually set or determined based on statistical data, and this embodiment does not limit this. Therefore, the file preview device compares the second file size with the image size threshold. When the second file size is greater than the image size threshold, it indicates that the image to be previewed is large, and a compressed image of the file to be previewed is obtained. The compressed image is then displayed to preview the file. Conversely, when the second file size is less than or equal to the image size threshold, it indicates that the image to be previewed is small, and the image is displayed to preview the file. Here, the file preview device can obtain the compressed image of the file to be previewed by obtaining an existing compressed image corresponding to the file to be previewed, or it can obtain the compressed image by real-time compression of the image to be previewed. This embodiment does not limit this.
[0124] It is understandable that when the image size to be previewed is larger than the image size threshold, it indicates that the image to be previewed is large. In this case, displaying a compressed image of the image to be previewed can reduce the memory usage of the preview data. Also, since the image size to be previewed is larger than the image size threshold, the image precision is higher. By compressing the image to be previewed, the preview quality can still be guaranteed.
[0125] For example, see Figure 5 , Figure 5 This is an exemplary file preview logic flowchart provided in an embodiment of this application; as shown... Figure 5As shown, a file preview application runs on the file preview device. When the file preview application is opened, in response to the file preview request 5-2 of the file to be previewed 5-1, the target file type 5-3 of the file to be previewed 5-1 is obtained; based on the first correspondence between the file type and the first previewer 5-4, the first previewer corresponding to the target file type 5-3 is searched, and the previewer search result 5-5 is obtained; it is determined whether the previewer search result 5-5 indicates that the preview has failed; if it is determined that the preview of the file to be previewed 5-1 has failed based on the previewer search result 5-5, the target second previewer 5-7 corresponding to the target file type 5-3 is searched based on the second correspondence between the file type and the second previewer 5-6; the file to be previewed 5-1 is previewed based on the target second previewer 5-7.
[0126] Understandably, because a first previewer and a second previewer are pre-defined based on the implementation method of the previewer before file previewing, when responding to a file preview request, the system first searches for the first previewer corresponding to the target file type of the file to be previewed. If the first previewer fails to preview the file, the second previewer can still be used to preview the file. Thus, the first previewer is selected as the first level of file previewing, and the second previewer is selected as the second level of file previewing, achieving a layered previewer system. This ensures that if the first previewer fails to preview the file, the second previewer can still be used to preview the file. Therefore, the success rate and stability of file previewing can be improved.
[0127] In this embodiment, the file preview device searches for a first previewer corresponding to the target file type based on a first correspondence between file types and first previewers. After obtaining the previewer search result, the file preview method further includes a process of determining that the preview of the file to be previewed has failed based on the previewer search result. This process may include: when the previewer search result indicates that the first previewer corresponding to the target file type has failed to be found, the file preview device determines that the preview of the file to be previewed has failed based on the previewer search result. This process may also include: when the previewer search result indicates that a target first previewer has been found, the file preview device previews the file to be previewed based on the target first previewer; when the preview of the file to be previewed fails using the target first previewer, the file preview determines that the preview of the file to be previewed has failed based on the previewer search result.
[0128] It should be noted that when the previewer search result indicates that the first previewer corresponding to the target file type failed to find, it means that no first previewer corresponding to the target file type was found based on the first correspondence. Therefore, the file preview device determines that the preview of the file to be previewed has failed based on the previewer search result. When the previewer search result indicates that a target first previewer has been found, the file to be previewed is previewed based on the target first previewer. In this case, the preview of the file to be previewed will fail due to at least one of the following reasons: the memory space of the file preview device is less than the memory required for previewing, the preview logic of the target first previewer is incorrect (e.g., file stream reading logic error), or the size of the file to be previewed is greater than the specified size. Therefore, determining that the preview of the file to be previewed has failed based on the previewer search result is equivalent to determining that the preview of the file to be previewed based on the first previewer has failed based on the previewer search result.
[0129] In this embodiment, the file preview device previews the file to be previewed based on the first target previewer, which is similar to the process described in step 104 of previewing the file to be previewed based on the second target previewer, including instantiation and processing of various target file types, etc., which will not be repeated here. Furthermore, if the preview is successful when the file preview device previews the file to be previewed based on the first target previewer, the preview process ends, that is, the execution of steps 103 and 104 ends.
[0130] Understandably, by creating a preview layer using first and second previewers implemented with different methods, if a preview based on the first-layer previewer fails due to the inability to find a corresponding first previewer, the preview layer allows for continued previewing using the second-layer previewer. This expands the previewer pool and increases the diversity of preview file types, thereby enhancing the breadth of previews. Furthermore, if the preview fails due to the target first previewer, the preview layer allows for continued previewing using the second-layer previewer, improving the success rate and stability of previews.
[0131] In this embodiment of the application, after the file preview device previews the file to be previewed based on the instantiated previewer, the file preview method further includes: when the preview of the file to be previewed is completed, the file preview device destroys the instantiated previewer; and in response to a new file preview request for a new preview file, obtains a new second previewer corresponding to the new preview file; instantiates the new second previewer to obtain a new instantiated previewer; and previews the new preview file based on the new instantiated previewer.
[0132] It should be noted that destroying the instantiated previewer is used to release the resources occupied by the instantiated previewer. A new file preview request refers to a request received after a file preview request has been received. This request is used to request a preview of a new file. The new file can be the same as or different from the file to be previewed; this embodiment does not limit this. Here, the instantiation process of the new second previewer is similar to the instantiation process of the target second previewer, and the process of previewing the new file based on the new instantiated previewer is similar to the process of previewing the file to be previewed based on the target second previewer; therefore, this embodiment will not repeat the description here.
[0133] It should also be noted that when the target first previewer previews the file to be previewed, if the preview is successful, the processing after the preview is completed can be similar to the processing when the target second previewer completes the preview. This embodiment of the application will not be described again here.
[0134] Understandably, the file preview device destroys and releases the instantiated previewer when the preview of the file to be previewed is completed; and instantiates the corresponding previewer again when there is a preview request to realize a new file preview. This realizes the processing of releasing the previewer after use, which can reduce the consumption of space and other resources by idle previewers and reduce the resource consumption of file preview.
[0135] In this embodiment, the file preview device destroys the instantiated previewer when the preview of the file to be previewed is completed. This includes: when the preview of the file to be previewed is completed, the file preview device determines whether the target file type is a Portable Document Format (PDF); if the target file type is different from a portable file type, the instantiated previewer is destroyed. Furthermore, after determining whether the target file type is a portable file type, the file preview method further includes: if the target file type is a portable file type, the file preview device retains the instantiated previewer.
[0136] It should be noted that when the second previewer is a custom previewer implemented through an embedded browser, the file preview device will retain the instantiated previewer if the target file type is a browser-supported type (such as PDF, XML, HTML, etc.); otherwise, the instantiated previewer will be destroyed.
[0137] Understandably, since the resources consumed in destroying the instantiation result of the previewer corresponding to the portable file type and in instantiating the previewer corresponding to the portable file type are greater than the resources consumed in continuously running the instantiation result of the previewer corresponding to the portable file type, the file preview device continues to run the instantiated previewer when the target file type is determined to be a portable file type, until all file previews are completed. However, when the target file type is not a portable file type, the instantiated previewer is still destroyed when the preview of the file to be previewed is completed. This reduces the resource consumption of file previewing.
[0138] In this embodiment of the application, after the file preview device previews the file to be previewed based on the instantiated previewer, the file preview method further includes: when the preview of the file to be previewed is completed, in response to the new file preview request of the new preview file, obtaining the new file type of the new preview file; when the new file type is the target file type, previewing the new preview file through the instantiated previewer; when the new file type is different from the target file type, previewing the new preview file based on the first previewer corresponding to the new file type, and destroying the instantiated previewer after a specified time has elapsed since the preview of the file to be previewed is completed.
[0139] It is understood that a file preview device can either destroy the instantiated previewer directly upon completion of the preview of the file to be previewed, or it can destroy the instantiated previewer after a specified period of time following the completion of the preview. This application embodiment does not limit this. Furthermore, the file preview device can destroy the instantiated previewer after a specified period of time following the completion of the preview if no new file preview request has been received, or if the file type corresponding to the received new file preview request is different from the target file type. This application embodiment does not limit this. In addition, if, within a specified period of time following the completion of the preview, the file preview device receives a new file preview request whose file type is still the target file type, it can reuse the previewer to respond to the new file preview request and preview the new file requested by the new file preview request. This reduces the resource consumption of instantiating and destroying the previewer, and also improves the reusability of the instantiated previewer.
[0140] See Figure 6 , Figure 6 This is a flowchart illustrating the file preview method provided in the embodiments of this application. Figure 2 ,in, Figure 6 The execution entity for each step is the file preview device; such as Figure 6As shown in the embodiment of this application, steps 105 to 107 are included after step 104; that is, after the file preview device previews the file to be previewed based on the target second previewer, the file preview method further includes steps 105 to 107. Each step is described below.
[0141] Step 105: Display the file details control for the file to be previewed.
[0142] In this embodiment, the file preview device can display a file details control when the preview of the file to be previewed is successful based on the target second previewer, or it can display a file details control when the preview of the file to be previewed fails based on the target second previewer. This embodiment does not limit this. In addition, the file details control can be displayed synchronously with the preview screen of the file to be previewed. The preview screen of the file to be previewed can display the content of the file to be previewed, the file icon of the file to be previewed, or a file preview failure prompt, etc.
[0143] It should be noted that the file details control is used to trigger the display of details information of the file to be previewed, and can be any of the following: icon, button, area, link, etc.
[0144] Step 106: In response to the trigger operation of the file details control, obtain the file details information of the file to be previewed.
[0145] It should be noted that when the file details control triggers the display of details information for the file to be previewed, a trigger operation is received for the file details control. At this time, the file preview device responds to the trigger operation, obtains the details information of the file to be previewed, and thus obtains the file details information. Here, the file details information includes at least one of the following: file name, file path, target file type, file size, creation time, modification time, access time, and extended information corresponding to the target file type. Among them, the extended information varies depending on the target file type. For example, when the target file type is an image, the extended information is resolution information, etc.; when the target file type is an audio file, the extended information is duration and bitrate, etc.; when the target file type is a software application, the extended information is software size, installation time, publisher, version number, etc.
[0146] Step 107: Display file details.
[0147] It should be noted that the file preview device can synchronously display file details information and the preview screen of the file to be previewed, and can also replace the display of the preview screen of the file to be previewed with the display of file details information. This application embodiment does not limit this. When the file preview device synchronously displays file details information and the preview screen of the file to be previewed, it can also display a control for displaying only the preview screen of the file to be previewed, so as to display both the preview screen of the file to be previewed and the file details control through this control. When the file preview device replaces the display of the preview screen of the file to be previewed with the display of file details information, it displays a control for switching to the preview screen of the file to be previewed, so as to switch back to the preview screen of the file to be previewed through this control.
[0148] Understandably, after displaying the preview screen of the file to be previewed, regardless of whether the preview screen displays the content of the file to be previewed or the file icon, file details can also be displayed, thus increasing the diversity of the file preview content.
[0149] In this embodiment of the application, after the file preview device previews the file to be previewed based on the target second previewer, the file preview method further includes: when the preview of the file to be previewed fails, the file preview device obtains the file icon of the file to be previewed; and displays the file icon of the file to be previewed in the file content preview area.
[0150] It should be noted that when the file preview device previews the file to be previewed based on the target second previewer, if the content of the file to be previewed cannot be previewed, it is determined that the target second previewer has failed to preview the file to be previewed. At this time, the file preview device displays the file icon of the file to be previewed to preview the file to be previewed. Accordingly, the preview screen of the file preview device is the file icon of the file to be previewed.
[0151] Understandably, when the target second previewer fails to preview the file to be previewed, displaying the file icon of the file to be previewed in the file content preview area enables the display of the relevant content of the file to be previewed; displaying the relevant content of the file to be previewed improves the success rate of file preview.
[0152] In this embodiment of the application, the file preview device may also additionally display the file icon of the file to be previewed when the target second previewer successfully previews the file to be previewed.
[0153] In this embodiment, before the file preview device searches for the first previewer corresponding to the target file type based on the first correspondence between file types and the first previewer, and obtains the previewer search result, the file preview method further includes a process of determining the first correspondence. This process includes: when the first previewer is a custom previewer, the file preview device generates a corresponding custom previewer for each file type; from the custom previewers corresponding to each file type, obtains each custom previewer corresponding to each file type; and based on each custom previewer corresponding to each file type, determines the first correspondence between the file type and the first previewer. This process may further include: when the first previewer is a preview interface corresponding to an installed application, the file preview device, in response to the installation of the file processing application, obtains the preview interface of the installed application; determines the file type corresponding to the installed application; and based on the preview interface and the file type, determines the first correspondence between the file type and the first previewer.
[0154] It should be noted that when the first previewer is a custom previewer, the file preview device obtains the initial correspondence by implementing a custom previewer for each file type. When the first previewer is a preview interface corresponding to an installed application, the installed application refers to an installed file processing application; for each file processing application installed, the file preview device obtains a correspondence between a preview interface and a file type, and ultimately obtains the initial correspondence.
[0155] In the embodiments of this application, the process of obtaining the second correspondence is similar to the process of obtaining the first correspondence, and will not be described again here.
[0156] In this application, the file preview device can count the preview frequencies corresponding to the preview interfaces of the custom previewer and the installed application, and take the one with the highest preview frequency among the custom previewer and the installed application preview interfaces as the first layer to form a first correspondence, so as to improve the success rate of file preview.
[0157] See Figure 7 , Figure 7 This is a flowchart illustrating the file preview method provided in the embodiments of this application. Figure 3 ,in, Figure 7 The execution entity for each step is the file preview device; such as Figure 7 As shown in the embodiment of this application, steps 108 to 110 are included after step 104; that is, after the file preview device previews the file to be previewed based on the target second previewer, the file preview method further includes steps 108 to 110. Each step is described below.
[0158] Step 108: When the preview of the file to be previewed fails and the second previewer is the preview interface corresponding to the installed application, update the second correspondence based on the specified second correspondence to obtain the updated second correspondence.
[0159] It should be noted that since the preview interface of an installed application is registered in the operating system of the file preview device after the file processing application is installed, and the preview interface of a fixed file processing application is fixed, the file preview device can obtain the fixed preview interface of a fixed file processing application. Each preview interface in the specified second correspondence refers to the preview interface corresponding to the most popular file processing application among multiple different file processing applications of the same file type. Here, when the second previewer is the preview interface corresponding to an installed application, the preview of the file to be previewed by the second previewer may fail because the preview interfaces of different file processing applications of the same file type have been overwritten in the second correspondence, and the file processing application corresponding to the overwritten preview interface has been uninstalled, making the target second previewer invalid. Therefore, the file preview device updates the second correspondence based on the specified second correspondence to repair the second correspondence, thus obtaining the updated second correspondence. It is easy to see that updating the second correspondence means updating the preview interface of the same file type in the second correspondence as in the specified second correspondence.
[0160] Step 109: Based on the updated second correspondence, determine the new preview interface corresponding to the target file type.
[0161] It should be noted that the file preview device uses the updated second correspondence to find the second previewer corresponding to the target file type, and the second previewer found based on the updated second correspondence is called the new preview interface.
[0162] Step 110: Preview the file to be previewed based on the new preview interface.
[0163] It should be noted that the process of the file preview device previewing the file to be previewed based on the new preview interface is similar to the process of previewing the file to be previewed based on the target preview interface, and will not be described again in this application embodiment.
[0164] It is understandable that by specifying and updating the second correspondence, a valid new preview interface can be determined through the updated second correspondence when the target second previewer is invalid. This allows for file previewing through the valid new preview interface, thereby improving the success rate and stability of file previewing.
[0165] The following describes an exemplary application of the embodiments of this application in a real-world application scenario. This exemplary application describes the process of previewing a file in a file search tool. It is readily apparent that the file preview method provided by the embodiments of this application is applicable to any file preview scenario; here, file previewing in a file search tool is used as an example for illustration.
[0166] For example, see Figure 8 , Figure 8 This is an exemplary file preview architecture diagram provided in an embodiment of this application; as shown Figure 8 As shown, this exemplary file preview architecture includes three layers: a custom preview technology layer (8-1), a system preview interface layer (8-2), and a basic information layer (8-3). The custom preview technology layer (8-1) is the first layer for file previewing, implementing file previewing through a custom previewer. The system preview interface layer (8-2) is the second layer for file previewing, implementing file previewing by calling the system preview interface. The basic information layer (8-3) is the third layer for file previewing, implementing file previewing through file icons and file details. In other words, file previewing is preferentially performed through the custom previewer, with file previewing via the system preview interface and file previewing via file icons and file details serving as fallback methods.
[0167] The following sections will explain the custom preview technology layer, the system preview interface layer, and the basic information layer.
[0168] A custom preview technology layer is used to implement a custom previewer for different file types. When the file type is an image, since the user interface (UI) framework of the file preview application is implemented through a graphical user interface application framework (such as the QT framework), the preview of image files (called image previews) can be implemented using image controls provided by the graphical user interface application framework. For example, for basic image types such as single images, the preview can be implemented using the image processing class (QPixmap); for GraphicsInterchange Format (GIF) files, the preview can be implemented dynamically using the image player (QMovie). In other words, the custom previewer for image types is an image control provided by the graphical user interface application framework.
[0169] When the file type is PDF, the portable file type preview (called portable file preview) is implemented through the built-in browser, which can improve the versatility of PDF processing functions. In other words, the custom previewer for PDF is the built-in browser.
[0170] When the file type is compressed, the compressed file preview (called a compressed file preview) uses a third-party compressed file parsing library (such as Bit7z, 7-zip, etc.) to parse the compressed file, obtain the paths of all files in the compressed file, and construct a tree-like directory based on the file paths. In other words, the custom previewer for compressed files is implemented based on the construction logic of the third-party compressed file parsing library and the tree-like target.
[0171] When the file type is audio or video, the file preview (called audio / video preview) is performed using an audio / video stream processing library (such as the ffmpeg audio / video stream processing library). In other words, a custom previewer for audio / video files is implemented based on an audio / video stream processing library.
[0172] It should be noted that the various custom previewers are parallel to each other and all use the same base class interface for derivation; that is, if a new custom previewer is to be implemented, or an old custom previewer is to be deprecated, the integration of the new custom previewer and the removal of the old custom previewer can be compatiblely implemented.
[0173] The system preview interface layer is used to preview the file when a custom previewer fails to preview the file, or when a custom previewer for the file type corresponding to the file to be previewed does not exist in the custom preview technology layer. When the system preview interface is called, the system preview registry is searched for the system preview interface (e.g., CLASSID) corresponding to the file type of the file to be previewed. A preview handle (e.g., IPreviewHandler preview handle) is constructed based on the system preview interface. The file stream of the file to be previewed is then read based on the preview handle, and the read file stream is displayed in a specified window.
[0174] It should be noted that some document types, text types, and other file types in the system have fixed system preview interfaces, and electronic devices usually have applications installed to handle these file types. Therefore, a fixed system preview interface corresponding to this file type can be built-in to repair the system preview interface; for example, if an electronic device originally supports file previewing of this file type, but the file preview fails due to an incorrect setting of the system preview interface for that file type, repairing the system preview interface can restore the preview function to normal.
[0175] The basic information layer is used to retrieve the default icon corresponding to the file type of the file to be previewed when the system preview interface layer fails to preview the file, and then display it. For file type preview requests, the default icon is the file icon; for file path or disk drive preview requests, the default icon is the folder icon; for software preview requests, the default icon is the software's main process icon; and for system tool preview requests, the default icon is the corresponding tool icon or system settings icon. On one hand, this effectively compensates for the lack of a preview of the file content using the default icon. On the other hand, when the file to be previewed is a folder, software, or system tool, and the corresponding content cannot be previewed, using the default icon improves the file preview effect.
[0176] The basic information layer is also used to obtain file details, which includes both basic file information and extended file information. Basic file information includes filename, file location (file path), file type, file size, creation time, modification time, and access time. Information other than basic file information is called extended file information, which varies depending on the file type. For example, image files have extended information such as resolution; video files have extended information such as duration, frame rate, bitrate, and resolution; audio files have extended information such as duration and bitrate. Software preview information includes software size, installation time, publisher, version number, and software location.
[0177] It is understood that the embodiments of this application provide rich file details through the basic information layer, which enhances the preview dimension of the information of the previewed file, thereby improving the accuracy of the judgment on file processing.
[0178] In this embodiment, file preview is implemented by instantiating a previewer (which can be a custom previewer or a system preview interface). The instantiated previewer is used to read the file content into memory and then display it. Here, targeted optimizations can be made to the file preview, including targeted optimizations to previewer instantiation, document reading, image preview, and compressed file preview. The specific optimizations to the file preview are described below.
[0179] It's important to note that each previewer instantiates itself upon receiving a file preview request, and destroys and releases the previewer instance once the file preview is complete. However, since the PDF previewer uses an embedded browser, the overhead and time required for browser initialization and destruction are relatively large compared to the continuous operation of the previewer instance. Therefore, for the PDF previewer, when the first request to preview using the embedded browser is received, the PDF previewer is instantiated, and the PDF previewer instance is kept alive until the preview function is exited, at which point it is destroyed.
[0180] It's also worth noting that when the file is a small document (size less than or equal to the document size threshold), reading it into memory takes less than the specified time. However, when the file is a large document (size greater than the threshold), reading it into memory takes longer than the specified time, causing lag in the preview interface. Therefore, the preview of large documents is moved to another thread for asynchronous processing. Thus, the file stream reading and file stream preview steps for large documents are separated. Upon receiving a document preview request, the file stream reading is executed in an asynchronous thread. After reading, the file stream data is passed to the UI thread, and the UI thread is notified to preview the document. This reduces UI lag during the file stream reading of large documents.
[0181] It should also be noted that for image file previews, when the image size is smaller than the specified real-image preview threshold (e.g., 25MB), the file can be previewed using the actual image; while when the image size is larger than the specified real-image preview threshold, the file can be previewed using the image thumbnail.
[0182] Understandably, although using image thumbnails for file previews results in a loss of image precision, the images are larger than the specified real-image preview threshold, resulting in higher precision. Therefore, using image thumbnails for file previews can reduce memory usage while ensuring the file preview effect.
[0183] It's also worth noting that compressed file previewing is achieved by constructing and displaying a tree-like directory structure of the first four levels of files within the compressed archive. Therefore, the larger the number of compressed files in the first four levels, the more items will be in the tree-like directory structure. By limiting the number of items in the tree-like directory to a threshold of 3000, a compressed file is previewed only if the number of files in the first four levels is less than 3000; otherwise, it indicates that the number of files in the first four levels is too large, and previewing the compressed file is not supported. This approach maximizes the support for compressed file previewing within resource constraints.
[0184] The following describes the logical flow of the file preview provided in the embodiments of this application.
[0185] See Figure 9 , Figure 9 This is an exemplary file preview logic flowchart provided in an embodiment of this application; as shown... Figure 9 As shown, upon receiving a file preview request 9-1, the file preview begins. First, the previewer selection management class 9-2, based on the file format 9-11 requested in the file preview request 9-1, allocates a corresponding previewer from among the various custom previewers in the custom preview technology layer (e.g., image previewer 9-31, portable file type previewer 9-32, compressed file previewer 9-33, etc.). When allocation is successful, it indicates the existence of a custom previewer corresponding to the requested file type. The allocated previewer is then instantiated, and file previewing is performed based on the instantiated previewer. Here, the previewer selection management class 9-2 is also used to manage the lifecycle of each previewer.
[0186] Next, it determines whether the instantiated previewer was successful. If so, it retrieves file details using the file details previewer 9-4 in the basic information layer and previews the file details. Otherwise, based on file format 9-11, it calls the system preview interface 9-5 through the system preview interface layer to preview the file. Additionally, when allocation fails, it calls the system preview interface 9-5 through the system preview interface layer to preview the file.
[0187] Finally, determine whether the preview was successful via the system preview interface; if so, preview the file details using the file details previewer 9-4. Otherwise, retrieve the icon of the file requested in the file preview request 9-1 using the file icon previewer 9-6 in the basic information layer, display the icon, and retrieve and preview the file details using the file details previewer 9-4 in the basic information layer.
[0188] The following describes the process of applying the file preview method provided in the embodiments of this application to a file search tool.
[0189] See Figure 10 , Figure 10 This is a schematic diagram of an exemplary file search tool interface provided in an embodiment of this application; as shown... Figure 10 As shown, the interface 10-1 includes a text input box 10-11 and a preview function switch button 10-12, which are used to turn the file preview function on and off.
[0190] See Figure 11 , Figure 11 This is a schematic diagram of an exemplary search result interface provided in an embodiment of this application; as shown below. Figure 11As shown in interface 11-1, when a keyword (such as "file") is entered into the text input box 11-11 to perform a file search, the search results 11-12 are displayed in a list below the text input box 11-11. At this time, when the mouse hovers over a record in the search results 11-12 (record 11-13 is shown as an example), a preview icon 11-14 is displayed, which is used to open the file preview window.
[0191] See Figure 12 , Figure 12 This is a schematic diagram of an exemplary file preview interface provided in an embodiment of this application; as shown... Figure 12 As shown in interface 12-1, when a click operation is received on the preview icon of the file to be previewed 12-11, the file preview window 12-12 is opened, and the file content of the file to be previewed 12-11, "This is a demo preview document," is displayed. Below the file preview window 12-12 is a button 12-13 (expand details button, referred to as the file details control) for switching between preview content and file details information.
[0192] See Figure 13 , Figure 13 This is another exemplary file preview interface diagram provided in the embodiments of this application; as shown Figure 13 As shown in interface 13-1, for the file to be previewed 13-11, when the corresponding file content is displayed in the file preview window and the expand details button is displayed below the file preview window, clicking the expand details button will switch the file preview window to a smaller window 13-12 displayed in the upper half, the file details 13-13 displayed in the lower half, and the button 13-14 (preview button) for switching back to displaying the file preview window and the expand details button will be displayed.
[0193] It is understood that this application embodiment employs different technical means for different file types (e.g., Word, Excel, PPT, PDF, TXT, XML, image, video, audio, and compressed files) to achieve rapid viewing of part or all of the file content. This application embodiment uses the system-provided preview interface as a fallback solution, prioritizing the use of a custom previewer for file previewing to improve compatibility and preview breadth. Furthermore, regarding preview information, it not only supports rapid previewing of file content but also provides previewing of file details, enhancing the richness of information previews. Even if the file type to be previewed is not supported, file previewing can still be achieved through file details information to make a preliminary judgment on the file content. In addition, targeted optimizations have been made in previewer instantiation, document reading, image previewing, and compressed file previewing to balance preview breadth and performance, enabling improved preview breadth while consuming the same system resources.
[0194] The following description continues to illustrate the exemplary structure of the file preview device 455 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 2 As shown, the software module stored in the file preview device 455 of the memory 450 may include:
[0195] The type acquisition module 4551 is used to acquire the target file type of the file to be previewed in response to a file preview request of the file to be previewed;
[0196] The preview search module 4552 is used to search for a first previewer corresponding to the target file type and obtain the previewer search result;
[0197] The preview search module 4552 is further configured to, when it is determined that the preview of the file to be previewed has failed based on the previewer search result, search for a second previewer corresponding to the target file type and obtain a target second previewer, wherein the first previewer and the second previewer are implemented in different ways;
[0198] The file preview module 4553 is used to preview the file to be previewed based on the target second previewer.
[0199] In this embodiment of the application, the file preview device 455 further includes a result determination module 4554, which is used to determine that the preview of the file to be previewed has failed when the previewer search result indicates that the first previewer search corresponding to the target file type has failed.
[0200] In this embodiment of the application, the result determination module 4554 is further configured to preview the file to be previewed based on the target first previewer when the previewer search result indicates that a target first previewer has been found; and to determine that the preview of the file to be previewed has failed based on the previewer search result when the preview of the file to be previewed fails through the target first previewer.
[0201] In this embodiment of the application, the file preview module 4553 is further configured to instantiate the target second previewer to obtain an instantiated previewer; and to preview the file to be previewed based on the instantiated previewer.
[0202] In this embodiment of the application, the file preview module 4553 is further configured to destroy the instantiated previewer when the preview of the file to be previewed is completed; in response to a new file preview request for a new preview file, obtain a new second previewer corresponding to the new preview file; instantiate the new second previewer to obtain a new instantiated previewer; and preview the new preview file based on the new instantiated previewer.
[0203] In this embodiment of the application, the file preview module 4553 is further configured to determine whether the target file type is a portable file type when the preview of the file to be previewed is completed; and to destroy the instantiated previewer when the target file type is different from the portable file type.
[0204] In this embodiment of the application, the file preview module 4553 is further configured to retain the instantiated previewer when the target file type is the portable file type.
[0205] In this embodiment of the application, the file preview module 4553 is further configured to, when the preview of the file to be previewed is completed, respond to a new file preview request for a new preview file, obtain the new file type of the new preview file; when the new file type is the target file type, preview the new preview file through the instantiated previewer; when the new file type is different from the target file type, preview the new preview file based on the first previewer corresponding to the new file type, and destroy the instantiated previewer after a specified time has elapsed since the preview of the file to be previewed is completed.
[0206] In this embodiment of the application, the file preview module 4553 is further configured to construct an instantiated preview handle based on the target second previewer when the second previewer is a preview interface corresponding to an installed application, wherein the installed application refers to an installed application used to process the corresponding file type; and to determine the instantiated preview handle as the instantiated previewer.
[0207] In this embodiment of the application, the file preview module 4553 is further configured to obtain the first file size of the file to be previewed when the target file type is a document type; when the first file size is greater than the document size threshold, the target second previewer reads the file stream of the file to be previewed through a first thread and previews the read file stream through a second thread, wherein the first thread and the second thread are asynchronous threads.
[0208] In this embodiment of the application, the file preview module 4553 is further configured to, when the target file type is a compressed type, obtain the number of files to be previewed before a specified level in the file to be previewed based on the target second previewer; when the number of files to be previewed is greater than a file number threshold, determine the highest level where the total number of files is less than the file number threshold, and preview the file to be previewed by performing the following process: displaying the names of each file before the highest level and the level where each file name is located.
[0209] In this embodiment of the application, the file preview module 4553 is further configured to: when the target file type is an image type, obtain the second file size of the file to be previewed based on the target second previewer; when the second file size is greater than the image size threshold, obtain a compressed image of the file to be previewed; and preview the file to be previewed by displaying the compressed image.
[0210] In this embodiment of the application, the file preview module 4553 is further configured to display a file details control of the file to be previewed; in response to a trigger operation on the file details control, to obtain file details information of the file to be previewed, the file details information including at least one of the following: file name, file path, target file type, file size, creation time, modification time, access time, and extended information corresponding to the target file type; and to display the file details information.
[0211] In this embodiment of the application, the file preview module 4553 is further configured to obtain the file icon of the file to be previewed when the preview of the file to be previewed fails; and display the file icon of the file to be previewed in the file content preview area.
[0212] In this embodiment of the application, the preview search module 4552 is further configured to search for the first previewer corresponding to the target file type based on the first correspondence between the file type and the first previewer, and obtain the previewer search result.
[0213] In this embodiment of the application, the file preview device 455 further includes a relationship determination module 4555, which is used to generate a corresponding custom previewer for each of the file types when the first previewer is a custom previewer; obtain each custom previewer corresponding to each file type from the custom previewer corresponding to each file type; and determine the first correspondence relationship between the file type and the first previewer based on each custom previewer corresponding to each file type.
[0214] In this embodiment of the application, the relationship determination module 4555 is further configured to, in response to the installation of the file processing application, obtain the preview interface of the installed application when the first previewer is the preview interface corresponding to the installed application; determine the file type corresponding to the installed application; and determine the first correspondence relationship between the file type and the first previewer based on the preview interface and the file type.
[0215] In this embodiment of the application, the preview search module 4552 is further configured to search for a second previewer corresponding to the target file type based on a second correspondence between the file type and the second previewer, and obtain the target second previewer.
[0216] In this embodiment of the application, the file preview module 4553 is further configured to, when the preview of the file to be previewed fails and the second previewer is a preview interface corresponding to an installed application, update the second correspondence based on a specified second correspondence to obtain an updated second correspondence; determine a new preview interface corresponding to the target file type based on the updated second correspondence; and preview the file to be previewed based on the new preview interface.
[0217] This application provides a computer program product, which includes computer-executable instructions or a computer program stored in a computer-readable storage medium. The processor of an electronic device reads the computer-executable instructions or computer program from the computer-readable storage medium and executes the computer-executable instructions or computer program, causing the electronic device to perform the file preview method described in this application.
[0218] This application provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will execute the file preview method provided in this application. For example, ... Figure 3 The file preview method is shown.
[0219] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0220] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.
[0221] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).
[0222] As an example, computer-executable instructions can be deployed to execute on a single electronic device (in this case, the single electronic device is a file preview device), or to execute on multiple electronic devices located in one location (in this case, the multiple electronic devices located in one location are file preview devices), or to execute on multiple electronic devices distributed across multiple locations and interconnected via a communication network (in this case, the multiple electronic devices distributed across multiple locations and interconnected via a communication network are file preview devices).
[0223] It is understood that in the embodiments of this application, data such as documents are involved. When the embodiments of this application are applied to specific products or technologies, the permission or consent of the information subject is required. The collection, use and processing of related data must comply with relevant laws, regulations and standards, and conform to the principles of legality, legitimacy and necessity. It does not involve obtaining data types prohibited or restricted by laws and regulations, and will not hinder the normal operation of the target website.
[0224] In summary, this application embodiment pre-defines a first previewer and a second previewer based on the implementation method of the previewer before file previewing. This ensures that when responding to a file preview request, the first previewer corresponding to the target file type is first determined. If previewing the file using the first previewer fails, the file can still be previewed using the second previewer corresponding to the target file type. Thus, the first previewer is selected as the first layer for file previewing, and the second previewer is selected as the second layer, achieving a layered previewer system. This allows for file previewing even if the first previewer fails, improving the success rate and stability of file previewing. Furthermore, targeted optimizations have been made for previewing document types, image types, and other types, further enhancing the file previewing effect.
[0225] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.
Claims
1. A file preview method, characterized in that, The method includes: In response to a file preview request for a file to be previewed, obtain the target file type of the file to be previewed; Find the first previewer corresponding to the target file type and obtain the previewer search results; When it is determined that the preview of the file to be previewed has failed based on the previewer search results, a second previewer corresponding to the target file type is searched to obtain the target second previewer. The first previewer and the second previewer are implemented in different ways. The target second previewer is used to preview the file to be previewed.
2. The method according to claim 1, characterized in that, After finding the first previewer corresponding to the target file type and obtaining the previewer search result, the method further includes: When the previewer search result indicates that the first previewer search corresponding to the target file type failed, the preview of the file to be previewed is determined to have failed based on the previewer search result.
3. The method according to claim 1, characterized in that, After finding the first previewer corresponding to the target file type and obtaining the previewer search result, the method further includes: When the previewer search result indicates that a target first previewer has been found, the file to be previewed is previewed based on the target first previewer; When the preview of the file to be previewed fails through the target first previewer, the preview of the file to be previewed is determined to have failed based on the previewer search results.
4. The method according to any one of claims 1 to 3, characterized in that, The previewing of the file to be previewed based on the target second previewer includes: The target second previewer is instantiated to obtain an instantiated previewer; The file to be previewed is previewed based on the instantiated previewer.
5. The method according to claim 4, characterized in that, After previewing the file to be previewed based on the instantiated previewer, the method further includes: When the preview of the file to be previewed is completed, the instantiated previewer is destroyed; In response to a new file preview request for a new preview file, obtain a new second previewer corresponding to the new preview file; The new second previewer is instantiated to obtain a new instantiated previewer; The new preview file is previewed using the newly instantiated previewer.
6. The method according to claim 5, characterized in that, The step of destroying the instantiated previewer when the preview of the file to be previewed is completed includes: When the preview of the file to be previewed is completed, determine whether the target file type is a portable file type; If the target file type is different from the portable file type, the instantiated previewer is destroyed. After determining whether the target file type is a portable file type, the method further includes: When the target file type is the portable file type, the instantiated previewer is retained.
7. The method according to claim 4, characterized in that, After previewing the file to be previewed based on the instantiated previewer, the method further includes: When the preview of the file to be previewed is completed, in response to the new file preview request of the new preview file, the new file type of the new preview file is obtained; When the new file type is the target file type, the new preview file is previewed using the instantiated previewer; When the new file type is different from the target file type, the new preview file is previewed based on the first previewer corresponding to the new file type, and the instantiated previewer is destroyed after a specified time has elapsed since the preview of the file to be previewed is completed.
8. The method according to claim 4, characterized in that, The instantiation of the target second previewer to obtain the instantiated previewer includes: When the second previewer is a preview interface corresponding to an installed application, an instantiated preview handle is constructed based on the target second previewer. The installed application refers to an installed application used to process the corresponding file type. The instantiation preview handle is identified as the instantiation previewer.
9. The method according to any one of claims 1 to 3, characterized in that, The previewing of the file to be previewed based on the target second previewer includes: When the target file type is document type, obtain the first file size of the file to be previewed; When the size of the first file is greater than the document size threshold, the target second previewer reads the file stream of the file to be previewed through the first thread and previews the read file stream through the second thread. The first thread and the second thread are asynchronous threads.
10. The method according to any one of claims 1 to 3, characterized in that, The previewing of the file to be previewed based on the target second previewer includes: When the target file type is compressed, the number of files to be previewed before the specified level in the file to be previewed is obtained based on the target second previewer; When the number of files to be previewed is greater than the file number threshold, the highest level where the total number of files is less than the file number threshold is determined, and the files to be previewed are previewed by performing the following process: displaying the names of each file before the highest level and the level where each file name is located.
11. The method according to any one of claims 1 to 3, characterized in that, The previewing of the file to be previewed based on the target second previewer includes: When the target file type is an image, the second file size of the file to be previewed is obtained based on the target second previewer; When the size of the second file is greater than the image size threshold, obtain the compressed image of the file to be previewed; The file to be previewed is displayed by showing the compressed image.
12. The method according to any one of claims 1 to 3, characterized in that, After previewing the file to be previewed based on the target second previewer, the method further includes: A file details control that displays the file to be previewed; In response to a trigger operation on the file details control, the file details information of the file to be previewed is obtained. The file details information includes at least one of the following: file name, file path, target file type, file size, creation time, modification time, access time, and extended information corresponding to the target file type. Display the file details.
13. The method according to any one of claims 1 to 3, characterized in that, After previewing the file to be previewed based on the target second previewer, the method further includes: When the preview of the file to be previewed fails, obtain the file icon of the file to be previewed; The file icon of the file to be previewed is displayed in the file content preview area.
14. The method according to any one of claims 1 to 3, characterized in that, The process of finding the first previewer corresponding to the target file type and obtaining the previewer search results includes: Based on the first correspondence between file type and first previewer, the first previewer corresponding to the target file type is found, and the previewer search result is obtained; Before obtaining the previewer search result by finding the first previewer corresponding to the target file type based on the first correspondence between file type and first previewer, the method further includes: When the first previewer is a custom previewer, a corresponding custom previewer is generated for each of the file types. Each custom previewer corresponding to each file type is obtained from the custom previewer corresponding to each file type; Based on each custom previewer corresponding to each of the file types, the first correspondence between the file type and the first previewer is determined.
15. The method according to claim 14, characterized in that, Before obtaining the previewer search result by finding the first previewer corresponding to the target file type based on the first correspondence between file type and first previewer, the method further includes: When the first previewer is the preview interface corresponding to an installed application, the preview interface of the installed application is obtained in response to the installation of the file processing application. Determine the file type corresponding to the installed application; Based on the preview interface and the file type, the first correspondence between the file type and the first previewer is determined.
16. The method according to any one of claims 1 to 3, characterized in that, The step of finding the second previewer corresponding to the target file type and obtaining the target second previewer includes: Based on the second correspondence between file type and second previewer, find the second previewer corresponding to the target file type to obtain the target second previewer; After previewing the file to be previewed based on the target second previewer, the method further includes: When the preview of the file to be previewed fails and the second previewer is the preview interface corresponding to the installed application, the second correspondence is updated based on the specified second correspondence to obtain the updated second correspondence. Based on the updated second correspondence, a new preview interface corresponding to the target file type is determined; The file to be previewed is previewed using the new preview interface.
17. A file preview device, characterized in that, The file preview device includes: The type acquisition module is used to obtain the target file type of the file to be previewed in response to a file preview request. The preview search module is used to find the first previewer corresponding to the target file type and obtain the previewer search results. The preview search module is also used to search for a second previewer corresponding to the target file type when the preview of the file to be previewed fails to be previewed based on the previewer search result, and to obtain the target second previewer. The first previewer and the second previewer are implemented in different ways. The file preview module is used to preview the file to be previewed based on the target second previewer.
18. An electronic device for file previewing, characterized in that, The electronic device includes: Memory is used to store executable instructions or computer programs. A processor, when executing computer-executable instructions or computer programs stored in the memory, implements the file preview method according to any one of claims 1 to 16.
19. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, the file preview method according to any one of claims 1 to 16 is implemented.
20. A computer program product comprising computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, the file preview method according to any one of claims 1 to 16 is implemented.