File management method, device, computer equipment and storage medium
By determining the target storage path of the file to be dragged in the Electron framework, the problem of cloud files cannot be downloaded efficiently is solved, and the convenient dragging and drop of files from the file management client to the local file system is achieved.
Patent Information
- Application Number
- CN202010963714.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-14
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2040-09-14
AI Technical Summary
The existing Electron framework cannot effectively obtain the target path of cloud files dragging and dropping in Windows and macOS operating systems, resulting in cloud files being unable to be downloaded efficiently.
By determining the file to be dragged corresponding to the hypertext markup language drag event in the file management client, and determining its target storage path in the local file system of the operating system when the drag type is external drag, obtaining and storing the file to be dragged.
It realizes the convenient and efficient dragging of files from the file management client into the local file system of the operating system, solving the problem of cloud file download.
Smart Images

Figure CN114185845B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a file management method, device, computer equipment and storage medium. Background Art
[0002] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.
[0003] Electron is a cross-platform framework for building desktop applications using JavaScript, Hypertext Markup Language (HTML), and Cascading Style Sheets (CSS). It's based on the Chromium browser. File dragging in Electron involves using a mouse to select a draggable Document Object Model (DOM) element within the software interface and then dragging it to any location within the interface (moving it) or to the local file system (generating a physical file corresponding to the DOM element in the file system). Existing file dragging technologies for desktop applications primarily rely on browser HTML dragging and native system dragging.
[0004] On Windows, existing HTML drag-and-drop and native API drag-and-drop only support dragging local physical files, preventing the caller from obtaining the target path of a cloud-based file drag to download it. On macOS, existing HTML drag-and-drop also fails to obtain the target path of a cloud-based file drag to download it.
[0005] Therefore, how to realize the drag-and-drop download of cloud files is a problem that needs to be solved urgently. Summary of the Invention
[0006] The embodiments of the present invention provide a file management method, apparatus, computer equipment, and storage medium, which can conveniently and efficiently drag and drop network disk files in a file management client to a local file system.
[0007] An embodiment of the present application provides a file management method, which specifically includes:
[0008] When a first hypertext markup language drag event is triggered for the file management client, determining a file to be dragged corresponding to the first hypertext markup language drag event from a plurality of files managed by the file management client;
[0009] If the drag type of the first hypertext markup language drag event is external drag, determining a target storage path of the file to be dragged in a local file system of the operating system according to the first hypertext markup language drag event;
[0010] The file to be dragged is acquired, and the file to be dragged is stored in the local file system according to the target storage path.
[0011] In one aspect, an embodiment of the present application provides a file management device that implements the aforementioned file management method. The function may be implemented by hardware or by hardware executing corresponding software. The hardware or software includes:
[0012] a determining unit configured to, when a first hypertext markup language drag event is triggered for a file management client, determine a file to be dragged corresponding to the first hypertext markup language drag event from a plurality of files managed by the file management client;
[0013] a processing unit configured to determine, if the drag type of the first hypertext markup language drag event is an external drag, a target storage path of the file to be dragged in a local file system of an operating system according to the first hypertext markup language drag event;
[0014] An acquiring unit, configured to acquire the file to be dragged;
[0015] A storage unit is used to store the file to be dragged in the local file system according to the target storage path.
[0016] On the one hand, an embodiment of the present application provides a computer device, which includes a processor, an input device, an output device and a memory, wherein the processor, input device, output device and memory are interconnected, wherein the memory is used to store a computer program, and the computer program includes program instructions. The processor is configured to call the program instructions to execute the operations involved in the above-mentioned file management method.
[0017] On one hand, an embodiment of the present application provides a computer-readable storage medium for storing computer program instructions for use by a computer device, which includes a program for executing the above-mentioned file management method.
[0018] In one aspect, an embodiment of the present application provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the above-described file management method.
[0019] Through the embodiments of the present application, when the file to be dragged corresponding to the HTML drag event is determined from multiple files managed by the file management client, and the drag type of the HTML drag event is determined to be an external drag, the target storage path of the file to be dragged in the local file system of the operating system can be determined according to the HTML drag event, and the dragged file can be obtained according to the target storage path, so that the file in the file management client can be dragged to the local file system of the operating system conveniently and efficiently. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 This is a schematic diagram of the architecture of a file management system provided in an embodiment of the present application;
[0022] Figure 2a This is a schematic diagram of a file management scenario provided by an embodiment of the present application;
[0023] Figure 2b This is a schematic diagram of another file management scenario provided by an embodiment of the present application;
[0024] Figure 3 This is a flowchart of a file management method provided by an embodiment of the present application;
[0025] Figure 4a This is a schematic diagram of a drag event processing flow provided by an embodiment of the present application;
[0026] Figure 4b This is another schematic diagram of a drag event processing flow provided by an embodiment of the present application;
[0027] Figure 5 This is a flowchart of another file management method provided by an embodiment of the present application;
[0028] Figure 6a This is another schematic diagram of a drag event processing flow provided by an embodiment of the present application;
[0029] Figure 6b This is another schematic diagram of a drag event processing flow provided by an embodiment of the present application;
[0030] Figure 7 This is a schematic diagram of the structure of a file management device provided in an embodiment of the present application;
[0031] Figure 8 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0033] It should be noted that the terms "first" and "second" in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature designated as "first" or "second" may explicitly or implicitly include at least one such feature.
[0034] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form a resource pool that can be used on demand with flexibility and convenience. Currently, the backend services of technical network systems, such as video websites, image websites, and more portals, require a large amount of computing and storage resources. With the rapid development and application of the internet industry, every item will likely have its own unique identification mark and need to be transmitted to the backend system for logical processing. Different levels of data will be processed separately. All kinds of industry data require a strong system support, which can only be achieved through cloud computing.
[0035] At present, cloud technology is mainly divided into cloud basic technology and cloud application. Cloud basic technology can be further divided into: cloud computing, cloud storage, database and big data; cloud application can be further divided into: medical cloud, cloud Internet of Things, cloud security, cloud call, private cloud, public cloud, hybrid cloud, cloud gaming, cloud education, cloud conferencing, cloud social networking and artificial intelligence cloud services.
[0036] From the perspective of basic technology, the file management method of this application involves cloud storage under cloud technology; from the application perspective, the file management method of this application involves artificial intelligence cloud services under cloud technology.
[0037] Cloud storage is a new concept that has been extended and developed from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.
[0038] Currently, storage systems utilize a method for creating logical volumes. When creating a logical volume, physical storage space is allocated for each logical volume. This physical storage space may consist of disks on a specific storage device or several storage devices. When a client stores data on a logical volume, it stores the data on a file system. The file system divides the data into multiple parts, each of which is an object. An object contains not only the data but also additional information such as the data identifier (ID) of the data entity. The file system writes each object to the physical storage space of the logical volume and records the storage location information of each object. Therefore, when a client requests access to data, the file system can provide access to the data based on the storage location information of each object.
[0039] The storage system allocates physical storage space to logical volumes by pre-dividing the physical storage space into stripes based on the estimated capacity of the objects to be stored in the logical volume (this estimate often has a large margin relative to the actual capacity of the objects to be stored) and the Redundant Array of Independent Disks (RAID) groupings. A logical volume can be understood as a stripe, thereby allocating physical storage space to the logical volume.
[0040] In this application, the cloud file management client can be regarded as a distributed cloud storage system. A large number of files are stored in the cloud file management client. Through the cloud file management method provided in the embodiment of this application, the user can determine the files to be dragged from multiple files stored in the cloud file management client and store the files to be dragged in the local file system.
[0041] Artificial intelligence cloud services, also commonly referred to as AIaaS (AI as a Service), are a mainstream AI platform service model. Specifically, AIaaS platforms break down several common AI services and provide them as standalone or packaged services in the cloud. This service model is similar to an AI-themed marketplace: all developers can access one or more AI services provided by the platform through an application programming interface (API). Experienced developers can also use the platform's AI framework and infrastructure to deploy and maintain their own cloud AI services.
[0042] The file management method involved in this application can be encapsulated as an artificial intelligence service, and only one interface is exposed to the outside world. When the file management function involved in this application is needed in a certain business scenario, by calling this interface, the file to be dragged and dropped can be stored in the local file system of the operating system.
[0043] It should be noted that the file management method provided in this application can be applied to the Tencent Micro Cloud desktop, allowing users to quickly upload and download batch files stored in the Tencent Micro Cloud desktop through drag and drop operations.
[0044] The computer device involved in the embodiments of the present application can be a device that provides voice and / or data connectivity to a user, for example, a handheld device with wireless connection function, a vehicle-mounted device, etc. The computer device can also be other processing devices connected to a wireless modem. The computer device can communicate with a radio access network (RAN). The computer device can also be called a wireless terminal, a subscriber unit (SUB), a subscriber station (SSS), a mobile station (MS), a mobile station (MS), a remote station (MS), an access point (AP), a remote terminal (RT), an access terminal (AT), a user terminal (UE), a user agent (UA), a user device (DEVICE), or a user equipment (UE), etc. The computer device can be a mobile terminal, such as a mobile phone (or "cellular" phone) and a computer with a mobile terminal, for example, a portable, pocket-sized, handheld, computer-built-in or vehicle-mounted mobile device, which exchanges voice and / or data with a radio access network. For example, the computer device may also be a Personal Communication Service (PCS) phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA), etc. Common computer devices include, for example, mobile phones, tablet computers, laptop computers, PDAs, Mobile Internet Devices (MIDs), vehicles, roadside devices, aircraft, and wearable devices such as smart watches, smart bracelets, and pedometers, but the embodiments of the present application are not limited thereto.
[0045] See Figure 1 , Figure 1A schematic diagram of the structure of a file management system provided in an embodiment of the present application. The schematic diagram of the structure of the file management system includes: a Windows application program interface 101, a macOS application program interface 102, a file monitoring module 103, a native drag module 104, an Electron drag module 105, and a user interface 106. Among them, the Windows application program interface (API) 101 and the macOS application program interface (API) 102 are a set of definitions, programs, and protocols. Through the Windows API and macOS API interfaces, mutual communication between computer software can be achieved in the Electron platform.
[0046] In one possible implementation, the file monitoring module 103 is applied to the Windows operating system, the native drag module 104 is applied to the macOS operating system, and the V8 layer encapsulates the C++ code in the file monitoring module 103 and the native drag module 104 into a V8 interface. The Electron drag module 105 can call the software code in the V8 layer through the V8 interface to store the to-be-dragged file in the local file system through the file monitoring module 103 and the native drag module 104.
[0047] In one possible implementation, the JS layer encapsulates the Electron drag module 105. The JS layer is developed in Javascript and is mainly used for interactive implementation of the user interface 106.
[0048] In one possible implementation, when a hypertext markup language (HTML) drag event of the Electron platform is triggered, the file to be dragged corresponding to the HTML drag event is determined from multiple files managed in the Electron platform; if the drag type of the HTML drag event is external drag, the file monitoring module 103 or the native drag module 104 is called according to the HTML drag event to determine the target storage path of the file to be dragged in the local file system of the operating system; the file to be dragged is obtained, and the file to be dragged is stored in the local file system according to the target storage path.
[0049] In one possible implementation, the user interface 106 can be Slack, Light Table, Game DevTycoon, Gitter, and Macaw. Among them, Slack is an enterprise communication and collaboration tool that can support audio or video functions, etc. We can use Electron to do this. Light Table is a code editor, and we can also use Electron to make a desktop application for the code editor. Game Dev Tycoon is a simulation game, and it can also be used to make game-related products. Gitter is a service that provides chat room functions for open source projects on GitHub, allowing users to log in with their Github account and then access the chat room of the project or organization. Macaw is an innovative WYSIWYG web design tool that allows web designers to directly design the visual design for their website. The tool can be used to directly generate website code, eliminating the step of converting the visual design draft into a website, and can directly generate semantic HTML and CSS code.
[0050] It can be understood that the system architecture diagram described in the embodiment of the present application is intended to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. Ordinary technicians in this field can know that with the evolution of the system architecture and the emergence of new business scenarios, the technical solution provided by the embodiment of the present application is also applicable to similar technical problems.
[0051] See Figure 2a , Figure 2a A schematic diagram of a file management scenario provided by an embodiment of the present application. This schematic diagram can be applied to computer devices. Taking the Tencent Micro Cloud client as an example, the user can enter a search option in the search interface of the Tencent Micro Cloud client. The content of the search option can be the specific name of a folder. For example, if the search option entered by the user in the search interface is "Folder 1", the search result corresponding to the search option can be displayed as "Folder 1" on the right side of the Tencent Micro Cloud client. Figure 2a As shown, the user can also click the buttons below the search interface. The buttons below the search interface specifically include "Recent", "All", "Documents", "Pictures", "Videos" and "Music". For example, the user can click the "All" button, and the Tencent Weiyun client responds to the user's click operation and displays all the files managed by the Tencent Weiyun client on the right side of the Tencent Weiyun client, such as Figure 2aAs shown, when the user clicks the "All" button, the right part of the Tencent Weiyun client displays "Folder 1", "Folder 2", "Folder 3", "Folder 4" and "Folder 5", and each folder is followed by the corresponding folder's attribute information, such as time information. Specifically, the time information corresponding to Folder 1 is 21:00 on June 4, the time information corresponding to Folder 2 is 18:18 on June 6, the time information corresponding to Folder 3 is 15:00 on June 8, the time information corresponding to Folder 4 is 12:00 on June 9, and the time information corresponding to Folder 5 is 10:05 on June 10. In addition, in addition to time information, the attribute information included after each folder can also include the size of each folder, for example, the file size corresponding to "Folder 1" can be 1.5M.
[0052] In one possible implementation, after the user clicks the "All" button, all files can be selected in the right part of the Tencent Micro Cloud client. Specifically, the user clicks on a folder, for example, the user clicks on "Folder 2", and a rectangular box appears in front of "Folder 2". A "√" is marked in the rectangular box, which means that the user has selected Folder 2. Then the user drags Folder 2 from the location of the Tencent Micro Cloud client to the local file system of the computer device, as shown in FIG. Figure 2a As shown, the arrow indicates that the user has dragged Folder 2 (the file to be dragged) from the Tencent Weiyun client to the local file system of the computer's operating system. It should be noted that the file system can specifically be the computer's home screen interface, a dialog box in a social software application, such as a WeChat or QQ chat dialog box, etc. This is not a limitation of the present invention. The purpose is to illustrate that when a user drags the file to be dragged from the file management client to the local file system, it is an external drag event.
[0053] See Figure 2b , Figure 2b This is a schematic diagram of another file management scenario provided by an embodiment of the present application. In one possible implementation, Figure 2a Based on the drag event, Figure 2b This shows the internal processing flow of the Tencent Weiyun Management Client after the user selects "Folder 2." Specifically, the right-hand display interface of the Tencent Weiyun Management Client shows that Folder 2 is downloading. Following "Folder 2" is information about the download progress of Folder 2, including the download progress and the remaining download time, such as "Downloading 1 / 2" and "Remaining 02:01:16." If Folder 2 has already been downloaded in the Tencent Weiyun Management Client, post-processing operations can be performed on Folder 2 in the corresponding display interface of the operating system's local file system.
[0054] Through the file management method provided by the present application, when a drag event is triggered for a file management client, the file to be dragged is determined from multiple files managed by the file management client. If the drag type of the drag event is an external drag, the target storage path of the file to be dragged in the local file system of the operating system is determined according to the drag event; the file to be dragged is obtained, and the file to be dragged is stored in the file system according to the target storage path, so that files in the file management client can be dragged from the file management client to the file system; if the drag type of the drag event is an internal drag, the file can be moved.
[0055] See Figure 3 , Figure 3 A flowchart of a file management method provided in an embodiment of the present application is provided. The file management method is applied to computer devices, such as Figure 3 As shown, the file management method may include steps S310 to S330. Among them:
[0056] Step S310: When a first hypertext markup language (HTML) drag event is triggered for a file management client, a file to be dragged corresponding to the first HTML drag event is determined from a plurality of files managed by the file management client.
[0057] In one possible implementation, the file management client may be an application that manages batch files, specifically an application that can store a large number of files in the file management client, such as Tencent Weiyun. It should be noted that the embodiments of the present application can be applied to the Windows operating system or the macOS operating system, that is, the operating system involved in the embodiments of the present application can be the Windows operating system or the macOS operating system, and the embodiments of the present application are described in detail using the Windows operating system as an example.
[0058] In one possible implementation, the drag event may include Hypertext Markup Language (HTML) drag and Object Linking and Embedding (OLE) drag. Among them, HTML drag refers to the user using the mouse to select a draggable DOM element in a browser or a browser-based framework (such as Electron), drag the DOM element to a droppable DOM element, and release the mouse button to drop these DOM elements. OLE drag refers to the use of IDropSource, IDropTarget, and IDataObject, through the OLE interface design method provided by the Windows operating system, to drag files or folders in one's own window from one's own client window to other client windows or system windows to achieve the system's drag effect, that is, a native drag method for representing objects and data in the drag process.
[0059] It should be noted that a complete HTML drag event can include events triggered on the drag target and events triggered when the target is released. Among them, the events triggered on the drag target can specifically include: ondragstart event (triggered when the user starts dragging an element), ondrag event (triggered while the element is being dragged), and ondragend event (triggered after the user completes dragging the element); among them, the events triggered when the target is released include: ondragenter event (triggered when the dragged object enters the scope of its container), ondragover event (triggered when a dragged object is dragged within the scope of another object's container), ondragleave event (triggered when the dragged object leaves the scope of its container), and ondrop event (triggered when the mouse button is released during a drag process).
[0060] For example, when a user clicks on a file icon of any file among multiple files managed in a file management client, the computer device determines that a first Hypertext Markup Language (HTML) drag event has been triggered, and the file corresponding to the clicked file icon is the file to be dragged corresponding to the first Hypertext Markup Language (HTML) drag event. Specifically, the file to be dragged can be a folder, or any other file such as a document, image, audio, or video, and this application does not limit this.
[0061] Step S320: If the drag type of the first hypertext markup language drag event is external drag, determine the target storage path of the file to be dragged in the local file system of the operating system according to the first hypertext markup language drag event.
[0062] In a possible implementation, the drag type of the first hypertext markup language HTML drag event may include external drag and internal drag. Figure 4a and Figure 4b , Figure 4a and Figure 4b A schematic diagram of the processing flow of a drag event provided in an embodiment of the present application. The so-called external drag refers to dragging the file to be dragged corresponding to the first hypertext markup language HTML drag event from the file management client to the local file system. The process of external drag is: first, determine the file to be dragged corresponding to the first hypertext markup language HTML drag event, and then, monitor whether there is a file with a specific identifier created in the file system through the monitoring module. If there is a file with a specific identifier created in the file system, obtain the target storage path of the file to be dragged in the file system, and finally, store the file to be dragged in the file system according to the target storage path. If the operating system is specifically a Windows operating system, then external drag specifically refers to dragging from the file management client to the local file system of the Windows operating system. For example, if the file management client is a Tencent WeCloud client, drag the file to be dragged from the Tencent WeCloud client to the desktop of the Windows operating system. The so-called internal dragging refers to dragging the file to be dragged within the file management client. The process of internal dragging is: first, determining the file to be dragged corresponding to the first hypertext markup language HTML drag event, then determining the target hypertext markup language HTML drag path in the file management client through the first hypertext markup language HTML drag event, and finally, moving the file to be dragged to the target path of the file management client through the target hypertext markup language HTML drag path. For example, if the arrangement order of multiple files managed by the file management client is folder 1, folder 2 and folder 3, if the user clicks on folder 2 and drags folder 2 to the bottom of the location of folder 3, the arrangement order of the multiple files in the file management client will become folder 1, folder 3 and folder 2; or, if the user drags folder 2 to the location of folder 1, the arrangement order of the multiple files in the file management client will be folder 1, folder 3. At this time, since folder 2 is dragged into folder 1, folder 2 can only be seen by clicking folder 1 again. Therefore, internal dragging can change the arrangement order of multiple files in the file management client, and internal dragging can also adjust the number of folders in the upper interface of the file management client.
[0063] In one possible implementation, a computer device calls a property setting function to set the property of a first hypertext markup language (HTML) drag event to a file link. For example, the property setting function may be the dataTransfer.setData function. The computer device sets the property of the first hypertext markup language (HTML) drag event to 'DownloadURL' by calling the dataTransfer.setData function. The computer device sets the file name of the file link to a file name with a specific identifier. Specifically, the computer device sets a file name with a specific identifier as the name of the file link. The file name with a specific identifier is used to create a temporary file in a target storage path in the local file system of the operating system. The file name with a specific identifier may be in text, character, or text + character format, which is not limited in the present invention. For example, the file name with a specific identifier may be the file name of the file to be dragged with ".abc11" appended to it. Finally, the computer device creates a temporary file in the target storage path based on the file name with a specific identifier. The temporary file may be an empty file. The purpose is to obtain the target storage path corresponding to the file to be dragged.
[0064] In one possible implementation, the computer device calls a form registration function to register a callback for file system event changes, and turns on the listening function in the file system. For example, the form registration function can specifically be the SHChangeNotifyRegister function. The SHChangeNotifyRegister function is a function used to register a form to receive file system messages. The computer device registers a callback for a custom event (i.e., a callback for file system event changes) by calling the SHChangeNotifyRegister function, thereby turning on the listening function in the file system. If the file name with a specific identifier is included in the callback of the file system monitor, the target storage path corresponding to the temporary file is obtained in the callback of the file system monitor. Specifically, if the file name in the callback of the file system monitor contains the specific identifier ".abc11", the target storage path corresponding to the temporary file is obtained, and the temporary file is deleted.
[0065] In one possible implementation, if the drag type of the first hypertext markup language HTML drag event is an internal drag, that is, the file to be dragged is dragged inside the file management client, then the computer device does not need to perform the step of determining the target storage path of the file to be dragged in the local file system of the operating system according to the first hypertext markup language HTML drag event, and can directly drag the file to be dragged to the corresponding target storage path according to each trigger event corresponding to the first hypertext markup language HTML drag event. For example, in the file management client, the file to be dragged is folder 1, the user clicks folder 1 with the mouse, and drags folder 1 to the bottom of the area where folder 2 is located. When the user releases the mouse, folder 1 is dragged to the bottom of the area where folder 2 is located. It should be noted that the position area below the area where folder 2 is located can be debugged and identified according to the computer program embedded in the computer device.
[0066] Step S330: Acquire the file to be dragged and store the file to be dragged in the local file system according to the target storage path.
[0067] In a possible implementation, after deleting the temporary file, the file to be dragged is downloaded to the target storage path corresponding to the temporary file. When the download of the file to be dragged is completed, the file to be dragged is stored in the file system according to the target storage path.
[0068] In one possible implementation, when an HTMLdragend event corresponding to a first hypertext markup language (HTML) drag event is triggered (where the HTMLdragend event is triggered when a user drags the file to be dragged into the operating system's local file system and releases the mouse), the computer device calls the SHChangeNotifyDeregister function to disable the file system's monitoring function, completing the HTML drag event. The SHChangeNotifyDeregister function is a function that unregisters a form from receiving file system messages. By calling the SHChangeNotifyDeregister function, the computer device can cancel the file system's monitoring function.
[0069] Through the file management method provided in the embodiments of the present application, when the file to be dragged corresponding to the HTML drag event is determined from multiple files managed by the file management client, and the drag type of the HTML drag event is determined to be external drag, a temporary file and a file name with a specific identifier are created according to a property setting function, and the file to be dragged is stored in the file system according to the target storage path corresponding to the temporary file. This allows files from the file management client to be dragged to the Windows operating system, and when the drag type of the HTML drag event is internal drag, the drag effect for the file to be dragged can be directly executed according to the target storage path corresponding to the drag event, thereby achieving both internal and external drag effects for files in the file management client.
[0070] See Figure 5 , Figure 5 This is a flow chart of another file management method provided in an embodiment of the present application. The file management method is applied to computer devices, such as Figure 5 As shown, the file management method may include steps S510 to S540.
[0071] Step S510: When a first hypertext markup language drag event is triggered for a file management client, a file to be dragged corresponding to the first hypertext markup language drag event is determined from a plurality of files managed by the file management client.
[0072] It should be noted that the embodiment of the present application can be applied to the macOS operating system, so the embodiment of the present application is described in detail using the macOS operating system as an example, and the detailed operation steps performed by the computer device in step S410 can be specifically referred to in the following. Figure 3 The operation steps executed by the computer device in step S310 in the embodiment will not be described in detail in this application.
[0073] Step S520: If the drag type of the first hypertext markup language drag event is external drag, call a drag session creation function to generate a system drag event corresponding to the first hypertext markup language drag event.
[0074] In a possible implementation, the drag type of the first hypertext markup language HTML drag event may include external drag and internal drag. Figure 6a and Figure 6b , Figure 6a and Figure 6bA schematic diagram of another process flow for drag events provided in an embodiment of the present application. The so-called external drag refers to dragging the file to be dragged corresponding to the first hypertext markup language HTML drag event from the file management client to the local file system of the operating system. It should be noted that the operating system involved in the embodiment of the present application is the macOS operating system. The process of external drag is: first, determine the file to be dragged corresponding to the first hypertext markup language HTML drag event, then determine the system drag event by obtaining the window handle and drag icon of the file to be dragged, obtain the target storage path of the file to be dragged in the file system according to the system drag event, and finally, store the file to be dragged in the file system according to the target storage path. The internal drag process is as follows: first, determine the file to be dragged corresponding to the first hypertext markup language HTML drag event, then determine the system drag event by obtaining the window handle and drag icon of the file to be dragged, and then determine the second hypertext markup language HTML drag event according to the position of the system drag event in the window, and finally, download the file to be dragged to the local storage address of the file management client through the target drag path corresponding to the second hypertext markup language HTML drag event.
[0075] In one possible implementation, a computer device obtains a window handle and a drag icon corresponding to a first hypertext markup language (HTML) drag event by calling a handle acquisition function. For example, the handle acquisition function may be the BrowserWindow.GetNativeHandle function. By calling the BrowserWindow.GetNativeHandle function, the computer device can obtain the window handle and the drag icon of the file to be dragged corresponding to the first hypertext markup language (HTML) drag event. It should be noted that the handle acquisition functions involved in the embodiments of the present application include, but are not limited to, GetTopWindow, GetForegroundWindow, GetActiveWindow, and GetSafeHwnd functions, and the present invention is not limited thereto.
[0076] In one possible implementation, based on the window handle and drag icon, the computer device calls a drag session creation function to generate a system drag event corresponding to the first Hypertext Markup Language (HTML) drag event. For example, based on the obtained window handle and drag icon, the computer device calls the NSDraggingItem.beginDraggingSession function to construct a custom system drag event. The system drag event is a native drag event of the file system, and the custom system drag event is specifically a native drag event corresponding to the macOS operating system.
[0077] Step S530: determining a target storage path of the file to be dragged in the local file system of the operating system according to the drag completion event and the drag-and-drop event of the system drag event.
[0078] In one possible implementation, the computer device registers the drag completion event and the drag and drop event corresponding to the system drag event. It should be noted that when the user drags an element, the events triggered are: ondragstart event, ondrag event and ondragend event. Specifically, when the user presses the mouse button and starts to move the mouse, the ondragstart event is triggered on the dragged element; when the drag starts, JavaScript code can be run through the ondragstart event handler; after the ondragstart event is triggered, the ondrag event is immediately triggered, and the drag event will continue to be triggered while the element is being dragged; when the drag stops (regardless of whether the element is dropped on a valid drop target or an invalid drop target), the ondragend event will occur. When an element is dragged to a valid drop target, the events triggered are: ondragenter event, ondragover event and ondragleave or ondrop event. In addition, as long as an element is dragged onto the drop target, the ondragenter event will be triggered; the ondragover event will follow immediately after the ondragenter event, and the ondragover event will be triggered continuously while the dragged element is still moving within the range of the drop target; if the element is dragged out of the drop target, the ondragover event will no longer occur, but the ondragleave event will be triggered; if the element is dropped into the drop target, the drop event will be triggered instead of the ondragleave event.
[0079] For example, in a file management client, when a user clicks the drag icon of a file to be dragged and the dragging stops, the computer device registers the ondragend event of the custom system drag event. Furthermore, when the user drags and drops the drag icon from the file management client to the file system of the macOS operating system, the computer device registers the ondragover event of the custom system drag event. Based on these ondragend and ondragover events, the computer device obtains the target storage path of the file to be dragged in the local file system of the macOS operating system.
[0080] Step S540: Acquire the file to be dragged and store the file to be dragged in the local file system according to the target storage path.
[0081] For example, the computer device downloads the file to be dragged to the local computer according to the target storage path of the file to be dragged in the macOS local file system, that is, downloads the file to be dragged to the macOS local file system, and stores the file to be dragged in the macOS local file system according to the target storage path.
[0082] In one possible implementation, if the drag type of a first hypertext markup language HTML drag event is an internal drag, the computer device calls a drag session creation function to generate a system drag event corresponding to the first hypertext markup language HTML drag event; when a drag completion event and a drag-and-drop event of the system drag event are triggered, the system drag event is converted to obtain a second hypertext markup language HTML drag event; and the display position of the file to be dragged in the display interface of the file management client is adjusted according to the second hypertext markup language HTML drag event.
[0083] For example, if the drag type of the first hypertext markup language HTML drag event is an internal drag, the computer device calls the NSDraggingItem.beginDraggingSession function to construct a custom system drag event, and then the computer device registers the drag completion event and drag-and-drop event of the system drag event. It should be noted that the detailed execution steps of the computer device calling the drag session creation function to generate the system drag event corresponding to the first hypertext markup language HTML drag event and registering the drag completion event and drag-and-drop event of the system drag event can be specifically referred to the execution process of the computer device when the drag type of the first hypertext markup language HTML drag event is an external drag, and this application will not go into details here. After receiving the ondragend and ondragover events of the custom system drag event, the computer device calls the CustomEvent constructor, the purpose of which is to create a custom event CustomEvent, which can convert the custom system drag event into a second hypertext markup language HTML drag event, thereby supporting the internal dragging of the file to be dragged in the file management client. Specifically, the computer device adjusts the display position of the file to be dragged in the display interface of the file management client according to the second hypertext markup language HTML drag event. For example, the display interface of the file management client includes folder 1, folder 2, and folder 3. If the file to be dragged is folder 1, and if the target storage path corresponding to the second hypertext markup language HTML drag event is the storage path of folder 2 in the file management client, the computer device drags folder 1 to the storage path of folder 2 according to the storage path of folder 2 for downloading and storage. Then, the adjusted display interface of the file management client includes folder 2 and folder 3. When the user clicks folder 2 with the mouse, folder 1 can be found.
[0084] Through the file management method provided in the embodiment of the present application, for the macOS operating system, if the drag type of the first hypertext markup language HTML drag event is an external drag, a system drag event corresponding to the first hypertext markup language HTML drag event is generated to obtain the target storage path of the file to be dragged and execute the download of the file to be dragged, thereby effectively realizing the effect of dragging the network disk file to the file system under the macOS operating system; and, the system drag event can be converted into a second hypertext markup language HTML drag event inside the file management client in real time, thereby being compatible with the internal drag of the file management client.
[0085] See Figure 7 , Figure 7 This is a schematic diagram of the structure of a file management device provided in an embodiment of the present application. The file management device is used to execute Figures 3 to 6bIn the corresponding method embodiment, the steps performed by the computer device may include:
[0086] A determining unit 710 is configured to, when a first hypertext markup language (HTML) drag event is triggered for a file management client, determine a file to be dragged corresponding to the first HTML drag event from a plurality of files managed by the file management client;
[0087] The processing unit 720 is configured to determine a target storage path of the file to be dragged in the local file system of the operating system according to the first hypertext markup language drag event if the drag type of the first hypertext markup language drag event is an external drag;
[0088] An acquiring unit 730 is configured to acquire the file to be dragged;
[0089] The storage unit 740 is configured to store the file to be dragged in the local file system according to the target storage path.
[0090] In a possible implementation, the processing unit 720 determines, according to the first hypertext markup language drag event, a target storage path of the file to be dragged in the local file system of the operating system, including:
[0091] Get the temporary file created at the target storage path in the local file system of the operating system;
[0092] The target storage path corresponding to the temporary file is obtained in the callback of the file system monitor.
[0093] In a possible implementation, if the drag type of the first hypertext markup language drag event is an external drag, and before the processing unit 720 obtains the temporary file created in the target storage path in the local file system of the operating system, the method further includes:
[0094] Calling an attribute setting function to set the attribute of the first hypertext markup language drag event as a file link;
[0095] Setting the file name of the file link to a file name with a specific identifier, wherein the file name with the specific identifier is used to create a temporary file in a target storage path in a local file system of the operating system;
[0096] The temporary file is created in the target storage path according to the file name of the specific identifier.
[0097] In a possible implementation, if the drag type of the first hypertext markup language drag event is an external drag, and before the processing unit 720 obtains the target storage path corresponding to the temporary file in the file system monitoring callback, the method further includes:
[0098] Call the form registration function to register the callback of file system event changes and enable the monitoring function in the file system;
[0099] If the file name of the specific identifier is included in the callback of the file system monitor, the step of obtaining the target storage path corresponding to the temporary file in the callback of the file system monitor is performed.
[0100] In a possible implementation, the processing unit 720 determines, according to the first hypertext markup language drag event, a target storage path of the file to be dragged in the local file system of the operating system, including:
[0101] Calling a drag session creation function to generate a system drag event corresponding to the first hypertext markup language drag event;
[0102] The target storage path of the file to be dragged in the local file system of the operating system is determined according to the drag completion event and the drag-and-drop event of the system drag event.
[0103] In a possible implementation, the processing unit 720 calls a drag session creation function to generate a system drag event corresponding to the first hypertext markup language drag event, including:
[0104] Calling a handle acquisition function to acquire the window handle and the drag icon corresponding to the first hypertext markup language drag event;
[0105] According to the window handle and the drag icon, a drag session creation function is called to generate a system drag event corresponding to the first hypertext markup language drag event.
[0106] In a possible implementation, the file management device further includes: a creating unit 750 and an adjusting unit 760 .
[0107] The creation unit 750 is configured to, if the drag type of the first hypertext markup language drag event is internal drag, call a drag session creation function to generate a system drag event corresponding to the first hypertext markup language drag event;
[0108] The adjustment unit 760 is used to adjust the display position of the file to be dragged in the display interface of the file management client according to the second hypertext markup language drag event after the processing unit 720 converts the system drag event into a second hypertext markup language drag event when the drag completion event and the drag and drop event of the system drag event are triggered.
[0109] Through the file management device provided by the embodiment of the present application, when the file to be dragged corresponding to the HTML drag event is determined from multiple files managed by the file management client, and the drag type of the HTML drag event is determined to be an external drag, the target storage path of the file to be dragged in the local file system of the operating system can be determined according to the HTML drag event, and the dragged file can be obtained according to the target storage path, so that the file in the file management client can be dragged to the local file system of the operating system.
[0110] See Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application, which is used to execute Figures 3 to 6b The steps performed by a computer device in the corresponding method embodiment include: one or more processors 810; one or more input devices 820; one or more output devices 830; and a memory 840. The processors 810, input devices 820, output devices 830, and memory 840 are connected via a bus 850. The memory 820 is used to store a computer program, which includes program instructions. The processor 810 is used to execute the program instructions stored in the memory 840 to perform the following operations:
[0111] When a first hypertext markup language drag event is triggered for the file management client, determining a file to be dragged corresponding to the first hypertext markup language drag event from a plurality of files managed by the file management client;
[0112] If the drag type of the first hypertext markup language drag event is external drag, determining a target storage path of the file to be dragged in a local file system of the operating system according to the first hypertext markup language drag event;
[0113] The file to be dragged is acquired, and the file to be dragged is stored in the local file system according to the target storage path.
[0114] In a possible implementation, the processor 810 determines, according to the first hypertext markup language drag event, a target storage path of the file to be dragged in the local file system of the operating system, including:
[0115] Get the temporary file created at the target storage path in the local file system of the operating system;
[0116] The target storage path corresponding to the temporary file is obtained in the callback of the file system monitor.
[0117] In a possible implementation, if the drag type of the first hypertext markup language drag event is an external drag, and before the processor 810 obtains the temporary file created at the target storage path in the local file system of the operating system, the method further includes:
[0118] Calling an attribute setting function to set the attribute of the first hypertext markup language drag event as a file link;
[0119] Setting the file name of the file link to a file name with a specific identifier, wherein the file name with the specific identifier is used to create a temporary file in a target storage path in a local file system of the operating system;
[0120] The temporary file is created in the target storage path according to the file name of the specific identifier.
[0121] In a possible implementation, if the drag type of the first hypertext markup language drag event is an external drag, and before the processor 810 obtains the target storage path corresponding to the temporary file in the callback monitored by the file system, the method further includes:
[0122] Call the form registration function to register the callback of file system event changes and enable the monitoring function in the file system;
[0123] If the file name of the specific identifier is included in the callback of the file system monitor, the step of obtaining the target storage path corresponding to the temporary file in the callback of the file system monitor is performed.
[0124] In a possible implementation, the processor 810 determines, according to the first hypertext markup language drag event, a target storage path of the file to be dragged in the local file system of the operating system, including:
[0125] Calling a drag session creation function to generate a system drag event corresponding to the first hypertext markup language drag event;
[0126] The target storage path of the file to be dragged in the local file system of the operating system is determined according to the drag completion event and the drag-and-drop event of the system drag event.
[0127] In a possible implementation, the processor 810 calls a drag session creation function to generate a system drag event corresponding to the first hypertext markup language drag event, including:
[0128] Calling a handle acquisition function to acquire the window handle and the drag icon corresponding to the first hypertext markup language drag event;
[0129] According to the window handle and the drag icon, a drag session creation function is called to generate a system drag event corresponding to the first hypertext markup language drag event.
[0130] In a possible implementation, the processor 810 is further configured to perform the following operations:
[0131] If the drag type of the first hypertext markup language drag event is internal drag, calling a drag session creation function to generate a system drag event corresponding to the first hypertext markup language drag event;
[0132] When a drag completion event and a drag-and-drop event of the system drag event are triggered, converting the system drag event into a second hypertext markup language drag event;
[0133] The display position of the file to be dragged in the display interface of the file management client is adjusted according to the second hypertext markup language drag event.
[0134] Through the computer device provided by the embodiment of the present application, when the file to be dragged corresponding to the HTML drag event is determined from multiple files managed by the file management client, and the drag type of the HTML drag event is determined to be an external drag, the target storage path of the file to be dragged in the local file system of the operating system can be determined according to the HTML drag event, and the dragged file can be obtained according to the target storage path, so that the file in the file management client can be dragged to the local file system of the operating system.
[0135] A computer-readable storage medium is also provided in an embodiment of the present application. The computer-readable storage medium stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the steps performed by the computer device in the above embodiment can be executed.
[0136] Those skilled in the art will appreciate that all or part of the processes in the above-described embodiments can be implemented by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium. When executed, the program can include the processes in the above-described file management method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0137] The present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps performed in the above-described method embodiments.
[0138] The above disclosure is only part of the embodiments of the present invention, which certainly cannot be used to limit the scope of the rights of the present invention. Ordinary technicians in this field can understand that implementing all or part of the processes of the above embodiments and making equivalent changes in accordance with the claims of the present invention still fall within the scope of the invention.
Claims
1. A file management method, characterized in that: The method comprises: When a first hypertext markup language drag event is triggered for a file management client, determining a file to be dragged corresponding to the first hypertext markup language drag event from multiple files managed by the file management client; the file management client is developed based on the Electron cross-platform framework, and the operating system running the file management client includes: a Windows operating system or a macOS operating system; If the drag type of the first hypertext markup language drag event is external drag and the operating system is a Windows operating system, setting an attribute of the first hypertext markup language drag event to a file link and setting a file name for the file link, creating a temporary file in a target storage path according to the set file name, and obtaining the target storage path corresponding to the temporary file in a file system detection callback; If the drag type of the first hypertext markup language drag event is an external drag and the operating system is a macOS operating system, generating a system drag event corresponding to the first hypertext markup language drag event, and determining a target storage path of the file to be dragged in the local file system of the macOS operating system based on a drag completion event and a drag-and-drop event of the system drag event; If the drag type of the first hypertext markup language drag event is an internal drag and the operating system is a macOS operating system, generating a system drag event corresponding to the first hypertext markup language drag event; when a drag completion event and a drag-and-drop event of the system drag event are triggered, converting the system drag event into a second hypertext markup language drag event; and adjusting a display position of the file to be dragged in a display interface of the file management client according to the second hypertext markup language drag event; The file to be dragged is acquired, and the file to be dragged is stored in the local file system according to the target storage path.
2. The method according to claim 1, characterized in that After the drag type of the first hypertext markup language drag event is an external drag, and before obtaining the target storage path corresponding to the temporary file in the callback of the file system detection, the method further includes: Call the form registration function to register the callback of file system event changes and enable the detection function in the file system; If the file name with a specific identifier is included in the callback of the file system detection, the step of obtaining the target storage path corresponding to the temporary file in the callback of the file system detection is performed.
3. The method according to claim 1, characterized in that The generating of a system drag event corresponding to the first hypertext markup language drag event includes: Calling a handle acquisition function to acquire the window handle and the drag icon corresponding to the first hypertext markup language drag event; According to the window handle and the drag icon, a drag session creation function is called to generate a system drag event corresponding to the first hypertext markup language drag event.
4. A file management device, characterized in that: include: a determining unit configured to, when a first hypertext markup language drag event is triggered for a file management client, determine a file to be dragged corresponding to the first hypertext markup language drag event from a plurality of files managed by the file management client; The file management client is developed based on the Electron cross-platform framework, and the operating system running the file management client includes: Windows operating system or macOS operating system; a processing unit configured to, if the drag type of the first hypertext markup language drag event is external drag and the operating system is a Windows operating system, set an attribute of the first hypertext markup language drag event to a file link, set a file name for the file link, create a temporary file in a target storage path according to the set file name, and obtain the target storage path corresponding to the temporary file in a file system detection callback; The processing unit is further configured to, if the drag type of the first hypertext markup language drag event is an external drag and the operating system is a macOS operating system, generate a system drag event corresponding to the first hypertext markup language drag event, and determine a target storage path of the file to be dragged in the local file system of the macOS operating system based on a drag completion event and a drag-and-drop event of the system drag event; The processing unit is further configured to, if the drag type of the first hypertext markup language drag event is an internal drag and the operating system is a macOS operating system, generate a system drag event corresponding to the first hypertext markup language drag event; when a drag completion event and a push-and-drag event of the system drag event are triggered, convert the system drag event into a second hypertext markup language drag event; and adjust a display position of the file to be dragged in a display interface of the file management client according to the second hypertext markup language drag event; An acquiring unit, configured to acquire the file to be dragged; A storage unit is used to store the file to be dragged in the local file system according to the target storage path.
5. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a set of program codes, and the processor calls the program codes stored in the memory to execute the method according to any one of claims 1 to 3.
6. A computer storage medium, characterized in that The computer storage medium stores a computer program, which includes program instructions. When the program instructions are executed by a processor, the method according to any one of claims 1 to 3 is executed.
7. A computer program product, characterized in that The computer program product includes computer instructions, which are stored in a computer storage medium. The processor of the computer device reads the computer instructions from the computer storage medium and executes the computer instructions, so that the computer device performs the method according to any one of claims 1 to 3.