Dynamic generation method and device for file type icons with extension names
By dynamically generating file type icons, the method determines and generates icons based on file information, solving the problem of poor flexibility in traditional solutions and achieving efficient, flexible icon generation and adaptability.
Patent Information
- Application Number
- CN202510855930.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-11-18
AI Technical Summary
Traditional file icon management solutions lack flexibility and cannot efficiently cope with the increasing number of file types and personalized display needs, leading to increased application development and maintenance costs.
By dynamically generating file type icons, the system determines whether a file is a directory file based on its information, obtains or generates the corresponding icon, and detects and generates a bitmap in the cache space, thus avoiding repeated creation and improving generation flexibility and scalability.
It improves the flexibility and efficiency of file icon generation, avoids wasting performance and storage resources, and adapts to new file types without updating application resources.
Smart Images

Figure CN120973740A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of file icon generation, in particular to a dynamic generation method and device of file type icon with extension. BACKGROUND
[0002] With the development of mobile internet technology, in the scene of intelligent device file management, users' demand for file type visualization is increasing. When operating NAS storage, private cloud and other systems, users need to quickly identify different types of files through icons, which puts higher requirements on the flexibility, scalability and performance of the file icon system.
[0003] The traditional file icon management scheme relies on static resource files. File icons are usually designed by designers in advance and introduced into the project as static resources, and are bound to file types through hard coding. This scheme requires product managers and designers to manually plan the mapping relationship of each type of icon. When new file types are added or icon styles are modified, code modification and resource update must be implemented, which has poor flexibility and cannot efficiently cope with the increasing number of file types and personalized display requirements, resulting in significant increase in application development and maintenance costs. Therefore, it is particularly important to propose a technical scheme that can improve the flexibility, scalability and generation efficiency of file icon generation. SUMMARY
[0004] The present application provides a dynamic generation method and device of file type icon with extension, which can improve the flexibility, scalability and generation efficiency of file icon generation.
[0005] In order to solve the above technical problems, the first aspect of the present application discloses a dynamic generation method of file type icon with extension, which is applied to an electronic device installed with an application program, and a target interface is arranged on the application program, and the electronic device is in communication connection with a network attached storage device, and accesses the network attached storage device through the application program, characterized in that the method comprises: When the target file stored in the network attached storage device is read through the application program, the target file and the file information of the target file are obtained, and the file information includes path information and attribute information; According to the file information, it is judged whether the target file is a directory file, and when the target file is a directory file, the preset directory icon corresponding to the directory file is obtained; When the target file is a non-directory file, the file extension of the target file is extracted, and according to the file extension and the preset file type mapping table, the file type of the target file is determined; According to the file extension and the file type, the target key value of the target file is determined; detecting whether the target bitmap corresponding to the target key value exists in a preset cache space, and when the target bitmap corresponding to the target key value does not exist in the cache space, generating the bitmap corresponding to the target file according to the file extension and the file type, and displaying the bitmap in the target interface.
[0006] As an optional implementation form, in the first aspect of the present application, the file type includes a special file type or a common file type. The generating the bitmap corresponding to the target file according to the file extension and the file type includes: When the file type includes the special file type, loading a special file icon corresponding to the target file. When the file type includes the common file type, generating a file icon corresponding to the target file according to the common file type and the file extension, and converting the file icon into the bitmap corresponding to the target file according to a preset bitmap conversion method.
[0007] As an optional implementation form, in the first aspect of the present application, the generating the file icon corresponding to the target file according to the common file type and the file extension includes: generating a view component corresponding to the target file according to the common file type and the file extension, the view component including an icon and a text label corresponding to the file extension; obtaining icon configuration information corresponding to the common file type in a preset database, and configuring an icon style of the icon according to the icon configuration information to obtain the configured icon, the icon configuration information including icon resource information and icon background color information; judging whether the text label satisfies a preset text label condition, and when the text label does not satisfy the text label condition, adjusting the text label to obtain an adjusted text label; generating the file icon corresponding to the target file according to the configured icon and the adjusted text label.
[0008] As an optional implementation form, in the first aspect of the present application, the converting the file icon into the bitmap corresponding to the target file according to the preset bitmap conversion method includes: creating a measurement specification corresponding to the file icon, and measuring size information of the file icon according to the measurement specification, the size information including first size information of the file icon, second size information of an icon corresponding to the file icon, and third size information of a text label of the file extension in the file icon; determining a relative position relationship between the icon and the text label in the file icon; converting the file icon into a bitmap corresponding to the target file according to the size information and the relative position relationship.
[0009] As an optional implementation, in the first aspect of the present application, the converting the file icon into a bitmap corresponding to the target file according to the size information and the relative position relationship comprises: creating a target space according to the first size information; determining first coordinate information of the icon in the target space and second coordinate information of the text label in the target space according to the second size information, the third size information and the relative position relationship; drawing the file icon into the target space according to the first coordinate information and the second coordinate information to obtain the bitmap corresponding to the target file.
[0010] As an optional implementation, in the first aspect of the present application, the method further comprises: displaying the target bitmap corresponding to the target key value in a target interface corresponding to the target file when the target bitmap corresponding to the target key value exists in the cache space; and, after the generating the bitmap corresponding to the target file according to the file extension and the file type, the method further comprises: generating a key value pair according to the target key value and the bitmap, and storing the key value pair into the cache space.
[0011] As an optional implementation, in the first aspect of the present application, the special file type comprises a thumbnail file type or an ISO file type; the loading the special file icon corresponding to the target file when the file type comprises the special file type comprises: calling a preset thumbnail generation interface to obtain a thumbnail icon corresponding to the target file when the file type comprises the thumbnail file type; obtaining a preset mirror icon corresponding to the ISO file type when the file type comprises the ISO file type.
[0012] The second aspect of the present application discloses a dynamic generation device of a file type icon with an extension, which comprises: an obtaining module, configured to obtain a target file and file information of the target file when the target file stored in a network attached storage device is read by an application program, the file information comprising path information and attribute information; The judgment module is used to determine whether the target file is a directory file based on the file information. When the target file is a directory file, the module obtains the preset directory icon corresponding to the directory file. The determination module is used to extract the file extension of the target file when the target file is not a directory file, and determine the file type of the target file according to the file extension and a preset file type mapping table; The determining module is further configured to determine the target key value of the target file based on the file extension and the file type; The detection module is used to detect whether the target bitmap corresponding to the target key value exists in a preset cache space; The generation module is used to generate a bitmap corresponding to the target file based on the file extension and the file type when the target bitmap corresponding to the target key value does not exist in the cache space, and to display the bitmap in the target interface.
[0013] As an optional implementation, in the second aspect of the present invention, the file type includes a special file type or a common file type; The generation module generates the bitmap corresponding to the target file based on the file extension and the file type in the following specific ways: When the file type includes the special file type, load the special file icon corresponding to the target file; When the file type includes the ordinary file type, a file icon corresponding to the target file is generated according to the ordinary file type and the file extension, and the file icon is converted into a bitmap corresponding to the target file according to a preset bitmap conversion method.
[0014] As an optional implementation, in the second aspect of the present invention, the method by which the generation module generates the file icon corresponding to the target file based on the ordinary file type and the file extension specifically includes: Based on the common file type and the file extension, a view component corresponding to the target file is generated, and the view component includes an icon and a text label corresponding to the file extension; Obtain the icon configuration information corresponding to the ordinary file type from the preset database, and configure the icon style according to the icon configuration information to obtain the configured icon. The icon configuration information includes icon resource information and icon background color information. Determine whether the text label meets the preset text label conditions. If the text label does not meet the text label conditions, adjust the text label to obtain the adjusted text label. Based on the configured icon and the adjusted text label, generate the file icon corresponding to the target file.
[0015] As an optional implementation, in a second aspect of the present invention, the method by which the generation module converts the file icon into a bitmap corresponding to the target file according to a preset bitmap conversion method specifically includes: Create a measurement specification corresponding to the file icon, and measure the size information of the file icon according to the measurement specification. The size information includes the first size information of the file icon, the second size information of the icon corresponding to the file icon, and the third size information of the text label of the file extension in the file icon. Determine the relative positional relationship between the icon and the text label in the file icon; Based on the size information and the relative positional relationship, the file icon is converted into a bitmap corresponding to the target file.
[0016] As an optional implementation, in a second aspect of the present invention, the method by which the generation module converts the file icon into a bitmap corresponding to the target file based on the size information and the relative positional relationship specifically includes: Create the target space based on the first size information; Based on the second size information, the third size information, and the relative positional relationship, determine the first coordinate information of the icon in the target space and the second coordinate information of the text label in the target space; Based on the first coordinate information and the second coordinate information, the file icon is drawn onto the target space to obtain the bitmap corresponding to the target file.
[0017] As an optional implementation, in a second aspect of the invention, the apparatus further includes: The display module is used to display the target bitmap in the target interface corresponding to the target file when the detection module detects that the target bitmap corresponding to the target key value exists in the cache space. The device also includes: The storage module is configured to, after the generation module generates a bitmap corresponding to the target file based on the file extension and the file type, generate a key-value pair based on the target key and the bitmap, and store the key-value pair in the cache space.
[0018] As an optional implementation, in a second aspect of the invention, the special file type includes a thumbnail file type or an ISO file type; When the file type includes the special file type, the generation module loads the special file icon corresponding to the target file in the following ways: When the file type includes the thumbnail file type, the preset thumbnail generation interface is called to obtain the thumbnail icon corresponding to the target file; When the file type includes the ISO file type, obtain the preset image icon corresponding to the ISO file type.
[0019] A third aspect of the present invention discloses an electronic device, the electronic device comprising: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute some or all of the steps in the dynamic generation method of file type icons with extensions according to any of the first aspects of the present invention.
[0020] The fourth aspect of the present invention discloses a dynamic generation system for file type icons with extensions, characterized in that the system includes at least the dynamic generation device for file type icons with extensions as described in any of the second aspects of the present invention, and a network attached storage device communicatively connected to the dynamic generation device for file type icons with extensions, wherein the network attached storage device stores program code, and the dynamic generation device for file type icons with extensions runs the program code to execute the dynamic generation method for file type icons with extensions as described in any of the first aspects of the present invention; Alternatively, the system may include at least the electronic device described in the third aspect of the present invention, and a network-attached storage device communicatively connected to the electronic device, wherein the network-attached storage device stores program code, and the electronic device executes the program code to perform the dynamic generation method for file type icons with extensions as described in any of the first aspects of the present invention.
[0021] The fifth aspect of the present invention discloses a computer storage medium storing computer instructions, which, when invoked, are used to execute some or all of the steps in the dynamic generation method for file type icons with extensions as described in any of the first aspects of the present invention.
[0022] Compared with the prior art, the present invention has the following beneficial effects: In this embodiment of the invention, the system determines whether the target file is a directory file based on the obtained file information. When the target file is a directory file, a preset directory icon corresponding to the directory file is obtained. This method avoids wasting performance and memory resources caused by repeatedly generating icons, thus improving overall efficiency and performance. When the target file is not a directory file, the system determines the target key value of the file and checks whether a corresponding bitmap exists based on the target key value. If not, a bitmap corresponding to the target file is generated based on the file extension and file type, improving the flexibility of file icon generation and avoiding the waste of performance and storage space caused by repeatedly creating bitmaps. Furthermore, when a new file type appears, there is no need to update application resources; the icon corresponding to the file type is generated directly, improving the scalability and efficiency of file icon generation. Therefore, implementing this invention can avoid wasting performance and memory resources caused by repeatedly generating icons by directly obtaining directory icons, improving overall efficiency and performance. It can generate corresponding icons based on file type and extension, improving the flexibility of file icon generation. Moreover, when a new file type appears, there is no need to update application resources; the icon corresponding to the file type is generated directly, improving the scalability and efficiency of file icon generation. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 This is a flowchart illustrating a method for dynamically generating file type icons with file extensions, as disclosed in an embodiment of the present invention. Figure 2 This is a flowchart illustrating another method for dynamically generating file type icons with file extensions, as disclosed in an embodiment of the present invention. Figure 3 This is a schematic diagram of the structure of a dynamic generation device for file type icons with file extensions disclosed in an embodiment of the present invention; Figure 4 This is a schematic diagram of another dynamic generation device for file type icons with file extensions disclosed in an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. Detailed Implementation
[0025] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or end that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or ends.
[0027] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0028] This invention discloses a method and apparatus for dynamically generating file type icons with file extensions. It avoids wasting performance and memory resources by directly obtaining directory icons, thus improving overall efficiency and performance. It can generate corresponding icons based on file type and extension, increasing the flexibility of file icon generation. Furthermore, when a new file type appears, application resources do not need to be updated; the corresponding icon is generated directly, improving the scalability and efficiency of file icon generation. Detailed descriptions follow.
[0029] Example 1 Please see Figure 1 , Figure 1 This is a flowchart illustrating a method for dynamically generating file type icons with extensions, as disclosed in an embodiment of the present invention. Figure 1The described method for dynamically generating file type icons with extensions can be applied to electronic devices with installed applications, where the application has a target interface, and the electronic device is communicatively connected to a network attached storage device (NAS) and accesses the NAS through the application. It can also be applied to devices for dynamically generating file type icons with extensions, which can communicate with the NAS. These devices may include intelligent servers or platforms for generating file type and extension images. The intelligent server may include a NAS server or a cloud server; however, this embodiment of the invention does not limit the scope of the method. Figure 1 As shown, the method for dynamically generating file type icons with extensions can include the following operations: 101. When reading a target file stored on the network-attached storage device through the application, obtain the target file and its file information.
[0030] In this embodiment of the invention, optionally, the target file and its file information can be obtained through a preset setFileIcon extension method. This extension method is an extension function that can be called by any ImageView. The file information of the target file may include path information and attribute information, and may also include information such as the modification time of the target file. This invention does not limit this.
[0031] 102. Determine whether the target file is a directory file based on the file information. If the target file is a directory file, obtain the preset directory icon corresponding to the directory file.
[0032] In this embodiment of the invention, optionally, the target file can be determined to be a directory file based on the file information. When the target file is a directory file, a preset directory icon corresponding to the directory file can be obtained. The preset directory icon may include a folder icon. After obtaining the preset directory icon, the directory icon can be directly displayed in the target interface corresponding to the target file. This invention does not impose any limitations.
[0033] 103. When the target file is not a directory file, extract the file extension of the target file and determine the file type of the target file according to the file extension and the preset file type mapping table.
[0034] In this embodiment of the invention, optionally, when the target file is not a directory file, the file extension of the target file can be extracted. Optionally, after extracting the file extension of the target file, the file extension can be converted to lowercase, and then the file type of the target file can be determined according to the file extension and a preset file type mapping table. That is, the file extension is mapped to the internal type constant of the file type mapping table to determine the file type. The file type of the target file can include special file types or ordinary file types. Special file types can include thumbnail file types or ISO file types. Thumbnail file types can include image / video file types. Ordinary file types can include one or more of the following: audio file types, web page related file types, PDF file types, PPT file types, Word file types, torrent file types, Keynote file types, Numbers file types, Pages file types, APK file types, HTML and script file types, TXT file types, XLS file types, compressed file types, unknown file types, and description file types. The invention does not limit these categories.
[0035] In this embodiment of the invention, optionally, each file type may correspond to one or more file extensions. Specifically, the file extensions for image files may include one or more of the following: bmp, exif, gif, heic, ico, jpg, jpeg, jfif, png, pcd, pcx, raw, pgm, dng, dds, dpx, iff, jp2, pix, pnm, ppm, rgb, xpm, cr2, nef, arw, svg, tif, tiff, and tga; the file extensions for audio files may include aac, aiff, aif, amr, ape, ac3, flac, m4r, midi, mp3, and m4. The file extensions for video files can include one or more of the following: p, pcm, vqf, wav, wma, m4a, ogg, au, ram, mmf, mpa, ots, mp2, mid, aifc, mka, mus, okt, psm, ra, rmi, s3m, sid, wav, wma, wv, and xa; video files can also include 3gp, 3g2, 3gp2, 3gpp, amv, asf, asx, avi, avm, bik, cmv, csf, divx, evo, f4v, fla, flc, flv, hlv, ivf, kux, m1v, m2p, m2t, m2ts, m2v, m4v, mk3d, mkv. File extensions for various file types include mov, mp4, mpeg, mpg, mpe, mpv, mxf, nsv, nuv, ogm, ogv, qt, rm, rmvb, tod, ts, vob, vp6, webm, wmv, and y4m; file extensions for webpage-related files include wms, wpt, et, dpts, and dptx; file extensions for PDF files include pdf and / or pdf-a; file extensions for PPT files include fodp, odp, otp, pot, ppt, potx, potm, ppsm, ppsx, ppt, pptx, pptm, posx, and others. One or more of posm; the file extensions for Word type files can include doc, docx, docm, dot, dotx, dotm, epub, fb2, fodt, htm, odt, ott, oxps, rtf, xps, docf, oform, and DjVu; the file extensions for torrent file type files can include torrent; the file extensions for Keynote type files can include key and / or kth; the file extensions for Numbers type files can include nmbtemplate and / or number; the file extensions for Pages type files can include pages;The file extension for APK type files can include .apk; the file extension for HTML and script type files can include one or more of html, xml, bat, cmd, py, sh, md, js, css, log, svg, cpp, srt, lrc, nfo, and ass; the file extension for TXT type files can include txt; the file extension for XLS type files can include one or more of csv, fods, ods, ots, xls, xlsb, xlt, xlsx, xlsm, xltx, and xltm; the file extension for compressed file type files can include one or more of zip, 7z, gz, rar, tar, bz2, xz, z, tgz, and tar.gz, and this invention does not impose any limitations.
[0036] 104. Determine the target key value of the target file based on the file extension and file type.
[0037] In this embodiment of the invention, optionally, after determining the file type of the target file, the target key value of the target file can be determined according to the file extension and file type. The target key value can be used to detect whether there is a target bitmap corresponding to the target key value in the preset cache space, thereby avoiding the repeated creation of bitmaps and the waste of performance and storage space.
[0038] 105. Check if a target bitmap corresponding to the target key exists in the preset cache space. If the target bitmap corresponding to the target key does not exist in the cache space, generate the bitmap corresponding to the target file according to the file extension and file type, and display the bitmap in the target interface.
[0039] In this embodiment of the invention, optionally, the existence of a target bitmap corresponding to a target key value can be detected in a preset cache space. When the target bitmap corresponding to the target key value does not exist in the cache space, a bitmap corresponding to the target file is generated according to the file extension and file type. The bitmap corresponding to the target file may include the file type icon and extension text of the target file, which is not limited in this invention.
[0040] It is evident that implementation Figure 1The described method for dynamically generating file type icons with extensions can, when the application reads a target file stored on the network-attached storage device, obtain the target file and its file information, determine whether the target file is a directory file based on the file information, and if so, obtain a preset directory icon. This method avoids wasting performance and memory resources by directly obtaining the directory icon, thus improving overall efficiency and performance. If the target file is not a directory file, the method extracts the file extension and determines the file type based on the file extension and a preset file type mapping table. It then determines the target key value based on the file extension and file type, and checks whether a corresponding bitmap exists. If the bitmap does not exist, it generates the corresponding bitmap based on the file extension and file type, and displays the bitmap in the target interface corresponding to the target file. This method can generate corresponding icons based on file type and extension, improving the flexibility of file icon generation. Furthermore, it can directly generate icons for new file types without updating application resources, improving the scalability and efficiency of file icon generation.
[0041] In an optional embodiment, the method for dynamically generating file type icons with extensions may further include the following operations: When the target bitmap corresponding to the target key-value exists in the cache space, the target bitmap is displayed in the target interface corresponding to the target file; Furthermore, after generating the bitmap corresponding to the target file based on the file extension and file type, the dynamic generation method for the file type icon with the file extension can also include the following operations: Generate key-value pairs based on the target key and the bitmap, and store the key-value pairs in the cache space.
[0042] In this optional embodiment, after determining the file type of the target file, the target key value of the target file can be determined according to the file extension and file type. The target key value can be used to detect whether there is a target bitmap corresponding to the target key value in the preset cache space. When there is a target bitmap corresponding to the target key value in the cache space, the target bitmap corresponding to the target key value is directly returned and displayed in the target interface corresponding to the target file, avoiding repeated creation of bitmaps and causing waste of performance and storage space. This embodiment does not limit this.
[0043] In this optional embodiment, after generating the bitmap corresponding to the target file based on the file extension and file type, key-value pairs can be generated based on the target key and the bitmap, and then the bitmap can be stored in the cache space in the form of key-value pairs for use by subsequent files of the same type. This embodiment does not limit this.
[0044] As can be seen, implementing this optional embodiment can determine the target key value of the target file based on the file extension and file type, check whether there is a target bitmap corresponding to the target key value in the preset cache space, and display the target bitmap in the target interface corresponding to the target file when the target bitmap corresponding to the target key value exists in the cache space. When the target bitmap corresponding to the target key value does not exist in the cache space, the operation of generating the bitmap corresponding to the target file based on the file extension and file type is triggered. This can avoid the repeated generation of file icons of the same type and extension based on the cache, avoid the memory and performance waste caused by duplicate icons, and improve overall efficiency and performance.
[0045] Example 2 Please see Figure 2 , Figure 2 This is a flowchart illustrating a method for dynamically generating file type icons with extensions, as disclosed in an embodiment of the present invention. Figure 2 The described method for dynamically generating file type icons with extensions can be applied to electronic devices with installed applications, where the application has a target interface, and the electronic device is communicatively connected to a network attached storage device (NAS) and accesses the NAS through the application. It can also be applied to devices for dynamically generating file type icons with extensions, which can communicate with the NAS. These devices may include intelligent servers or platforms for generating file type and extension images. The intelligent server may include a NAS server or a cloud server; however, this embodiment of the invention does not limit the scope of the method. Figure 2 As shown, the method for dynamically generating file type icons with extensions can include the following operations: 201. When reading a target file stored on the network-attached storage device through the application, obtain the target file and its file information.
[0046] 202. Determine whether the target file is a directory file based on the file information. If the target file is a directory file, obtain the preset directory icon corresponding to the directory file.
[0047] 203. When the target file is not a directory file, extract the file extension of the target file and determine the file type of the target file according to the file extension and the preset file type mapping table.
[0048] 204. When the file type includes special file types, load the special file icon corresponding to the target file.
[0049] In this embodiment of the invention, the special file type may optionally include a thumbnail file type or an ISO file type. The thumbnail file type may include an image / video file type. When the file type includes a special file type, the special file icon corresponding to the target file can be directly loaded and displayed. The book file icon includes the thumbnail URL corresponding to the thumbnail file type or the image file icon corresponding to the ISO file type. This invention does not limit the scope of the invention.
[0050] 205. When the file type includes ordinary file types, determine the target key value of the target file based on the file extension and file type.
[0051] 206. Check if the target bitmap corresponding to the target key value exists in the preset cache space. If the target bitmap corresponding to the target key value does not exist in the cache space, generate the file icon corresponding to the target file according to the ordinary file type and file extension, and convert the file icon to the bitmap corresponding to the target file according to the preset bitmap conversion method.
[0052] In this embodiment of the invention, optionally, when the file type includes a regular file type, and a target bitmap corresponding to the target key value is detected in a preset cache space, if the target bitmap corresponding to the target key value is not found in the cache space, a file icon corresponding to the target file can be generated based on the regular file type and file extension. Specifically, a custom view component can be created using the ViewBinding component, which includes an icon and a file tag displaying the file extension. val view = FileIconLayoutBinding.inflate(LayoutInflater.from(CommonAppHelper.getApplication())) Then, the file icon is converted into the bitmap corresponding to the target file according to the preset bitmap conversion method. The preset bitmap conversion method includes the viewToBitmap method, which is not limited in this invention.
[0053] 207. Display the bitmap in the target interface.
[0054] In this embodiment of the invention, for other descriptions of steps 201-203 and step 207, please refer to the detailed description of steps 101-105 in Embodiment 1 of the invention. These descriptions will not be repeated in this embodiment of the invention.
[0055] It is evident that implementation Figure 2The described method for dynamically generating file type icons with extensions can, when the application reads a target file stored on the network-attached storage device, obtain the target file and its file information, determine whether the target file is a directory file based on the file information, and if so, obtain a preset directory icon corresponding to the directory file, thereby improving overall efficiency and performance by directly obtaining the directory icon. If the target file is not a directory file, the method extracts the file extension of the target file and determines the file type of the target file based on the file extension and a preset file type mapping table. If the file type includes special file types, the method loads the special file icon corresponding to the target file, enabling the direct loading of special file types. Specialized file icons (for images, videos, etc.) improve icon display efficiency while avoiding the waste of performance and memory resources caused by repeatedly generating icons, thus improving overall efficiency and performance. When the file type includes ordinary file types, a file icon corresponding to the target file is generated based on the ordinary file type and file extension. The file icon is then converted into a bitmap corresponding to the target file using a preset bitmap conversion method, and the bitmap is displayed in the target interface corresponding to the target file. This feature enables the generation of corresponding icons based on file type and extension, improving the flexibility of file icon generation. Furthermore, when a new file type appears, there is no need to update application resources; the icon corresponding to the file type is generated directly, improving the scalability and efficiency of file icon generation.
[0056] In an optional embodiment, generating a file icon corresponding to the target file based on the common file type and file extension may include the following operations: Based on the common file type and file extension, generate the view component corresponding to the target file. The view component includes an icon and a text label corresponding to the file extension. Retrieve icon configuration information corresponding to ordinary file types from the preset database, configure the icon style according to the icon configuration information, and obtain the configured icon. The icon configuration information includes icon resource information and icon background color information. Determine whether the text label meets the preset text label conditions. If the text label does not meet the text label conditions, adjust the text label to obtain the adjusted text label. Generate the file icon corresponding to the target file based on the configured icon and the adjusted text label.
[0057] In this optional embodiment, a custom view component can be created using the ViewBinding component. This view component includes an icon and text labels corresponding to the file extension. Then, icon configuration information for common file types is retrieved from a preset database. The preset database can store icon configuration information for each common file type, including icon resource information and icon background color information. The icon style is then configured according to the icon configuration information to obtain the configured icon. Specifically, different icons and color schemes can be assigned to different types of files based on the icon configuration information, for example: when (type) { WPS ->{ ivIcon.setImageResource(R.mipmap.file_wps_icon) tvFileType.background= tvFileType.drawable (R.drawable.shape_r2_bg_eo3f24) } PDF ->{ ivIcon.setImageResource(R.mipmap.file_pdf_icon) tvFileType.background= tvFileType.drawable (R.drawable.shape_r2_bg_eo3f24) } PPT ->{ ivIcon.setImageResource(R.mipmap.file_opt_icon) tvFileType.background= tvFileType.drawable (R.drawable.shape_r2_bg_f26e18) } WORD ->{ ivIcon.setImageResource(R.mipmap.file_word_icon) tvFileType.background= tvFileType.drawable (R.drawable.shape_r2_bg_0055ff)} BT ->{ ivIcon.setImageResource(R.mipmap.file_bt_icon) tvFileType.background= tvFileType.drawable (R.drawable.shape_r2_bg_0055ff) } KEYNOTE ->{ ivIcon.setImageResource(R.mipmap.file_keynote_icon) tvFileType.background= tvFileType.drawable (R.drawable.shape_r2_bg_0055ff) } NUMBERS ->{ ivIcon.setImageResource(R.mipmap.file_numbers_icon) tvFileType.background= tvFileType.drawable (R.drawable.shape_r2_bg_24b33c) } } In this optional embodiment, it can be determined whether the text label meets the preset text label conditions. When the text label does not meet the text label conditions, the text label is adjusted to obtain the adjusted text label. The text label conditions may include the text label length condition. Specifically, it can be determined whether the label length corresponding to the text label is greater than or equal to the text label length threshold. When the label length corresponding to the text label is greater than or equal to the text label length threshold, the font of the text label is adjusted, for example, by reducing the font size, to obtain the adjusted text label. This embodiment does not impose any limitations.
[0058] As can be seen, implementing this optional embodiment can generate a view component corresponding to the target file based on the common file type and file extension. The view component includes an icon and a text label corresponding to the file extension. It retrieves icon configuration information corresponding to the common file type from a preset database, configures the icon style according to the icon configuration information, and obtains the configured icon. It can generate icons based on basic icon resources and configure the graphics and colors of the icons according to preset configuration information, improving the efficiency and flexibility of icon generation while ensuring that the generated icons follow a unified design language. It determines whether the text label meets the preset text label conditions. When the text label does not meet the text label conditions, it adjusts the text label to obtain the adjusted text label. Based on the configured icon and the adjusted text label, it generates the file icon corresponding to the target file, enabling the display of the file icon's extension to adopt a unified layout and style, thus improving the user experience.
[0059] In another optional embodiment, converting a file icon into a bitmap corresponding to the target file according to a preset bitmap conversion method may include the following operations: Create a measurement specification corresponding to the file icon, and measure the size information of the file icon according to the measurement specification. The size information includes the first size information of the file icon, the second size information of the icon corresponding to the file icon, and the third size information of the text label of the file extension in the file icon. Determine the relative positions of the icons and text labels within the file icon; Based on the size information and relative position, the file icon is converted into a bitmap corresponding to the target file.
[0060] In this optional embodiment, optionally, measurement specifications corresponding to the text icons can be created, specifically: val measureWidth = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED) val measureHeight = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED) This code creates width and height measurement specifications. The parameter 0 in (0, View.MeasureSpec.UNSPECIFIED) indicates that no exact size value is specified. The code measures the dimensions of the icon in the document according to these specifications. Specifically, the measurement process for the View is triggered by calling `measure(measureWidth, measureHeight)`. This call recursively measures the View and all its child Views, calculating the required actual dimensions. After the measurement is complete, the calculated width and height can be obtained using `measuredWidth` and `measuredHeight`. The size information may include the overall size information of the file icon, and may also include the size information of each component of the file icon. Specifically, the size information may include the first size information of the file icon, the second size information of the icon corresponding to the file icon, and the third size information of the text label of the file extension in the file icon. This embodiment does not limit this.
[0061] In this optional embodiment, the relative positional relationship between the icons and text labels in the file icon can be determined. This relative positional relationship can include the layout relationship between each component of the file icon, such as one or more combinations of top-bottom layout, left-right layout, nested layout, center alignment, and edge alignment. It can also include the alignment method inside the icon, such as one or more combinations of horizontal alignment, vertical alignment, and group alignment. Furthermore, it can include spacing information, such as one or more combinations of inner margin, outer margin, and spacing ratio. It can also include the stacking order, such as one or more combinations of foreground and background, coverage relationship, and transparency control. Based on the size information and relative positional relationship, the file icon is converted into a bitmap corresponding to the target file. This embodiment does not limit this.
[0062] As can be seen, implementing this optional embodiment can create a measurement specification corresponding to the file icon, and measure the size information of the file icon according to the measurement specification. The size information includes the first size information of the file icon, the second size information of the icon corresponding to the file icon, and the third size information of the text label of the file extension in the file icon. The relative positional relationship between the icon and the text label in the file icon is determined. Based on the size information and the relative positional relationship, the file icon is converted into a bitmap corresponding to the target file. Based on the size and layout information of each component in the measured icon, the efficiency of the conversion operation can be improved and the accuracy of the bitmap obtained after conversion can be improved.
[0063] In yet another optional embodiment, converting a file icon into a bitmap corresponding to a target file based on size information and relative positional relationships may include the following operations: Create the target space based on the first dimension information; Based on the second size information, the third size information, and the relative positional relationship, determine the first coordinate information of the icon in the target space and the second coordinate information of the text label in the target space; Based on the first and second coordinate information, the file icon is drawn onto the target space to obtain the bitmap corresponding to the target file.
[0064] In this optional embodiment, a target space can be created based on the first size information. Specifically, a blank Bitmap with the same size as the View can be created using the viewToBitmap method. Then, based on the second size information, the third size information, and the relative positional relationship, the first coordinate information of the icon in the target space and the second coordinate information of the text label in the target space can be determined. For example: layout(0, 0, measuredWidth, measuredHeight) The View is laid out at the specified position and size. The first parameter 0 and the second parameter 00 indicate that the View is placed at the position of coordinates (0,0) (i.e., the top left corner of the blank Bitmap). The third and fourth parameters, measuredWidth and measuredHeight, specify the coordinates of the bottom right corner of the View. Using the measured width and height, the position of all components in the file icon can be determined in the target space using the coordinate information. Then, based on the first and second coordinate information, the file icon is drawn onto the target space to obtain the bitmap corresponding to the target file. Specifically, the View can be drawn onto the Bitmap using a Canvas, but this embodiment does not limit it.
[0065] As can be seen, implementing this optional embodiment can create a target space based on the first size information, determine the first coordinate information of the icon in the target space and the second coordinate information of the text label in the target space based on the second size information, the third size information and the relative positional relationship, draw the file icon into the target space based on the first coordinate information and the second coordinate information, and obtain the bitmap corresponding to the target file. It can draw the bitmap based on the size and layout information of the icon, improve the efficiency of the conversion operation, improve the accuracy of the bitmap obtained after conversion, and at the same time ensure that the icons and extensions in the bitmap follow a unified layout and style, thereby improving the user viewing experience.
[0066] In yet another optional embodiment, the special file type includes a thumbnail file type or an ISO file type; When the file type includes special file types, loading the special file icon corresponding to the target file can include the following operations: When the file type includes thumbnail file type, the preset thumbnail generation interface is called to obtain the thumbnail icon corresponding to the target file; When the file type includes ISO file type, retrieve the preset image icon corresponding to the ISO file type.
[0067] In this optional embodiment, the special file type may include a thumbnail file type or an ISO file type. The thumbnail file type may include an image / video file type. When the file type includes a thumbnail file type, a preset thumbnail generation interface can be called to obtain the thumbnail icon corresponding to the target file. The preset thumbnail generation interface may include getImageThumbnail. The thumbnail icon may include a thumbnail URL. After obtaining the thumbnail icon corresponding to the target file, Glide can be used to load it and directly display the thumbnail icon in the target interface corresponding to the target file. This embodiment does not impose any limitations.
[0068] In this optional embodiment, when the file type includes ISO file type, the preset image icon corresponding to the ISO file type can be directly obtained, and then the preset image icon can be directly displayed in the target interface corresponding to the target file. This embodiment does not limit this.
[0069] As can be seen, implementing this optional embodiment can call the preset thumbnail generation interface to obtain the thumbnail icon corresponding to the target file when the file type includes thumbnail file type, and obtain the preset image icon corresponding to the ISO file type when the file type includes ISO file type. It can directly load the special file icon of special file, improve the icon display efficiency, and avoid the waste of performance and memory resources caused by repeated icon generation, thereby improving the overall efficiency and performance.
[0070] Example 3 Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of a dynamic generation device for file type icons with file extensions disclosed in an embodiment of the present invention. Figure 3 The described dynamic file type icon generation device with file extension can communicate with a network attached storage device. This device may include a smart server or smart platform for generating images of file types and extensions. The smart server may be a NAS server or a cloud server; this embodiment of the invention is not limited to this. Figure 3 As shown, a dynamically generated device with a file type icon and extension may include: The acquisition module 301 is used to acquire the target file and its file information, including path information and attribute information, when the target file stored in the network attached storage device is read by the application. The judgment module 302 is used to determine whether the target file is a directory file based on the file information. When the target file is a directory file, the preset directory icon corresponding to the directory file is obtained. The determination module 303 is used to extract the file extension of the target file when the target file is not a directory file, and determine the file type of the target file according to the file extension and a preset file type mapping table; The determination module 303 is also used to determine the target key value of the target file based on the file extension and file type; The detection module 304 is used to detect whether a target bitmap corresponding to a target key value exists in a preset cache space; The generation module 305 is used to generate a bitmap corresponding to the target file based on the file extension and file type when the target bitmap corresponding to the target key value does not exist in the cache space, and to display the bitmap in the target interface.
[0071] It is evident that implementation Figure 3 The described dynamic file type icon generation device with file extension can, when the application reads a target file stored on the network-attached storage device, obtain the target file and its file information, determine whether the target file is a directory file based on the file information, and if the target file is a directory file, obtain a preset directory icon corresponding to the directory file, thereby improving overall efficiency and performance by directly obtaining the directory icon; if the target file is not a directory file, extract the file extension of the target file, determine the file type of the target file based on the file extension and a preset file type mapping table, generate a bitmap corresponding to the target file based on the file extension and file type, and display the bitmap in the target interface corresponding to the target file. It can generate corresponding icons based on file type and extension, improving the flexibility of file icon generation, and when a new file type appears, it does not need to update application resources, directly generating the icon corresponding to the file type, thus improving the scalability and efficiency of file icon generation.
[0072] In an optional embodiment, such as Figure 4 As shown, file types include special file types or ordinary file types; The generation module 305 generates the bitmap corresponding to the target file according to the file extension and file type in the following specific ways: When the file type includes a special file type, load the special file icon corresponding to the target file; When the file type includes ordinary file types, a file icon corresponding to the target file is generated based on the ordinary file type and file extension, and the file icon is converted into the bitmap corresponding to the target file according to the preset bitmap conversion method.
[0073] It is evident that implementation Figure 4The described file type icon dynamic generation device, which generates icons with file extensions, can obtain the target file and its file information when the application reads a target file stored on the network-attached storage device. Based on the file information, it determines whether the target file is a directory file. If the target file is a directory file, it obtains a preset directory icon, improving overall efficiency and performance by directly obtaining the directory icon. If the target file is not a directory file, it extracts the file extension and determines the file type based on the file extension and a preset file type mapping table. If the file type includes special file types, it loads the special file icon corresponding to the target file, enabling direct loading of special file types. Specialized file icons (for images, videos, etc.) improve icon display efficiency while avoiding the waste of performance and memory resources caused by repeatedly generating icons, thus improving overall efficiency and performance. When the file type includes ordinary file types, a file icon corresponding to the target file is generated based on the ordinary file type and file extension. The file icon is then converted into a bitmap corresponding to the target file using a preset bitmap conversion method, and the bitmap is displayed in the target interface corresponding to the target file. This feature enables the generation of corresponding icons based on file type and extension, improving the flexibility of file icon generation. Furthermore, when a new file type appears, there is no need to update application resources; the icon corresponding to the file type is generated directly, improving the scalability and efficiency of file icon generation.
[0074] In another alternative embodiment, such as Figure 4 As shown, the specific methods by which the generation module 305 generates the file icon corresponding to the target file based on the ordinary file type and file extension include: Based on the common file type and file extension, generate the view component corresponding to the target file. The view component includes an icon and a text label corresponding to the file extension. Retrieve icon configuration information corresponding to ordinary file types from the preset database, configure the icon style according to the icon configuration information, and obtain the configured icon. The icon configuration information includes icon resource information and icon background color information. Determine whether the text label meets the preset text label conditions. If the text label does not meet the text label conditions, adjust the text label to obtain the adjusted text label. Generate the file icon corresponding to the target file based on the configured icon and the adjusted text label.
[0075] It is evident that implementation Figure 4The described dynamic file type icon generation device can generate view components corresponding to target files based on common file types and file extensions. These view components include an icon and a text label corresponding to the file extension. The device retrieves icon configuration information for common file types from a preset database, configures the icon style according to this information, and obtains the configured icon. It can generate icons based on basic icon resources and configure the graphics and colors of the icons according to preset configuration information, improving icon generation efficiency and flexibility while ensuring the generated icons adhere to a unified design language. The device also determines whether the text label meets preset text label conditions; if not, it adjusts the text label to obtain an adjusted text label. Finally, based on the configured icon and the adjusted text label, it generates the file icon corresponding to the target file, enabling a unified layout and style for the file icon's extension display, thus enhancing the user experience.
[0076] In yet another alternative embodiment, such as Figure 4 As shown, the specific methods by which the generation module 305 converts the file icon into the bitmap corresponding to the target file according to the preset bitmap conversion method include: Create a measurement specification corresponding to the file icon, and measure the size information of the file icon according to the measurement specification. The size information includes the first size information of the file icon, the second size information of the icon corresponding to the file icon, and the third size information of the text label of the file extension in the file icon. Determine the relative positions of the icons and text labels within the file icon; Based on the size information and relative position, the file icon is converted into a bitmap corresponding to the target file.
[0077] It is evident that implementation Figure 4 The described dynamic file type icon generation device with file extension can create a measurement specification corresponding to the file icon and measure the size information of the file icon according to the measurement specification. The size information includes the first size information of the file icon, the second size information of the icon corresponding to the file icon, and the third size information of the text label of the file extension in the file icon. It determines the relative positional relationship between the icon and the text label in the file icon, and converts the file icon into a bitmap corresponding to the target file based on the size and layout information of each component in the measured icon, thereby improving the efficiency of the conversion operation and the accuracy of the bitmap obtained after conversion.
[0078] In yet another alternative embodiment, such as Figure 4 As shown, the specific methods by which the generation module 305 converts the file icon into a bitmap corresponding to the target file based on the size information and relative positional relationship include: Create the target space based on the first dimension information; Based on the second size information, the third size information, and the relative positional relationship, determine the first coordinate information of the icon in the target space and the second coordinate information of the text label in the target space; Based on the first and second coordinate information, the file icon is drawn onto the target space to obtain the bitmap corresponding to the target file.
[0079] It is evident that implementation Figure 4 The described dynamic file type icon generation device with extension can create a target space based on first size information, and determine the first coordinate information of the icon and the second coordinate information of the text label in the target space based on second size information, third size information, and relative positional relationships. Based on the first and second coordinate information, the file icon is drawn into the target space to obtain the bitmap corresponding to the target file. It can draw the bitmap based on the size and layout information of the icon, improve the efficiency of the conversion operation, improve the accuracy of the bitmap obtained after conversion, and at the same time ensure that the icon and extension in the bitmap follow a unified layout and style, thereby improving the user viewing experience.
[0080] In yet another alternative embodiment, such as Figure 4 As shown, the dynamic generation device for the file type icon with the file extension may also include: The display module 306 is used to display the target bitmap in the target interface corresponding to the target file when the detection module 304 detects that there is a target bitmap corresponding to the target key value in the cache space; Furthermore, the dynamically generated device for the file type icon with the file extension may also include: The storage module 307 is used to generate key-value pairs based on the target key and the bitmap after the generation module 305 generates the bitmap corresponding to the target file according to the file extension and file type, and then stores the key-value pairs in the cache space.
[0081] It is evident that implementation Figure 4 The described dynamic file type icon generation device with file extension can determine the target key value of the target file based on the file extension and file type. It checks whether the target bitmap corresponding to the target key value exists in a preset cache space. When the target bitmap corresponding to the target key value exists in the cache space, it displays the target bitmap in the target interface corresponding to the target file. When the target bitmap corresponding to the target key value does not exist in the cache space, it triggers the operation of generating the bitmap corresponding to the target file based on the file extension and file type. It can avoid the repeated generation of file icons of the same type and extension based on caching, avoid the memory and performance waste caused by duplicate icons, and improve overall efficiency and performance.
[0082] In yet another alternative embodiment, such as Figure 4As shown, special file types include thumbnail file types or ISO file types; When the file type includes special file types, the generation module 305 loads the special file icon corresponding to the target file in the following ways: When the file type includes thumbnail file type, the preset thumbnail generation interface is called to obtain the thumbnail icon corresponding to the target file; When the file type includes ISO file type, retrieve the preset image icon corresponding to the ISO file type.
[0083] It is evident that implementation Figure 5 The described dynamic file type icon generation device with extension can call a preset thumbnail generation interface to obtain the thumbnail icon corresponding to the target file when the file type includes thumbnail file type, and obtain the preset image icon corresponding to ISO file type when the file type includes ISO file type. It can directly load special file icons for special files, improving icon display efficiency while avoiding the waste of performance and memory resources caused by repeated icon generation, thus improving overall efficiency and performance.
[0084] Example 4 Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of the present invention. For example... As shown, the electronic device may include: Memory 401 storing executable program code; Processor 402 coupled to memory 401; The processor 402 calls the executable program code stored in the memory 401 to execute the steps in the dynamic generation method of file type icons with extensions described in Embodiment 1 or Embodiment 2 of the present invention.
[0085] Example 5 This invention discloses a dynamic generation system for file type icons with extensions. The system includes at least a dynamic generation device for file type icons with extensions as described in Embodiment 3 of this invention, and a network attached storage device communicatively connected to the dynamic generation device for file type icons with extensions. The network attached storage device stores program code, and the dynamic generation device for file type icons with extensions runs the program code to execute the dynamic generation method for file type icons with extensions as described in Embodiment 1 or Embodiment 2 of this invention. Alternatively, the system may include at least the electronic device described in Embodiment 4 of the present invention, and a network-attached storage device communicatively connected to the electronic device, wherein the network-attached storage device stores program code, and the electronic device runs the program code to execute the dynamic generation method of file type icons with extensions described in Embodiment 1 of the present invention or Embodiment 2 of the present invention.
[0086] Example 6 This invention discloses a computer storage medium storing computer instructions. When these computer instructions are invoked, they are used to execute some or all of the steps in the dynamic generation method for any type of file icon with extension disclosed in Embodiment 1 of this invention.
[0087] Example 7 This invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to perform the steps in the dynamic generation method of file type icons with extensions described in Embodiment 1 or Embodiment 2.
[0088] The device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0089] Through the detailed description of the above embodiments, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0090] Finally, it should be noted that the method and apparatus for dynamically generating file type icons with extensions disclosed in the embodiments of the present invention are merely preferred embodiments of the present invention and are only used to illustrate the technical solutions of the present invention, not to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for dynamically generating file type icons with file extensions, the method being applied to an electronic device with an application installed, wherein the application has a target interface, and the electronic device is communicatively connected to a network attached storage device (NETD), and accesses the NETD through the application, characterized in that... The method includes: When the application reads a target file stored on the network-attached storage device, it obtains the target file and its file information, including path information and attribute information. Based on the file information, determine whether the target file is a directory file. If the target file is a directory file, obtain the preset directory icon corresponding to the directory file. When the target file is not a directory file, extract the file extension of the target file, and determine the file type of the target file according to the file extension and a preset file type mapping table; Determine the target key value of the target file based on the file extension and the file type; The system checks whether a target bitmap corresponding to the target key value exists in the preset cache space. If the target bitmap corresponding to the target key value does not exist in the cache space, the system generates a bitmap corresponding to the target file based on the file extension and the file type, and displays the bitmap in the target interface.
2. The method for dynamically generating file type icons with extensions according to claim 1, characterized in that, The file types include special file types or ordinary file types; The step of generating the bitmap corresponding to the target file based on the file extension and the file type includes: When the file type includes the special file type, load the special file icon corresponding to the target file; When the file type includes the ordinary file type, a file icon corresponding to the target file is generated according to the ordinary file type and the file extension, and the file icon is converted into a bitmap corresponding to the target file according to a preset bitmap conversion method.
3. The method for dynamically generating file type icons with extensions according to claim 2, characterized in that, The step of generating a file icon corresponding to the target file based on the ordinary file type and the file extension includes: Based on the common file type and the file extension, a view component corresponding to the target file is generated, and the view component includes an icon and a text label corresponding to the file extension; Obtain the icon configuration information corresponding to the ordinary file type from the preset database, and configure the icon style according to the icon configuration information to obtain the configured icon. The icon configuration information includes icon resource information and icon background color information. Determine whether the text label meets the preset text label conditions. If the text label does not meet the text label conditions, adjust the text label to obtain the adjusted text label. Based on the configured icon and the adjusted text label, generate the file icon corresponding to the target file.
4. The method for dynamically generating file type icons with extensions according to claim 2 or 3, characterized in that, The step of converting the file icon into a bitmap corresponding to the target file according to a preset bitmap conversion method includes: Create a measurement specification corresponding to the file icon, and measure the size information of the file icon according to the measurement specification. The size information includes the first size information of the file icon, the second size information of the icon corresponding to the file icon, and the third size information of the text label of the file extension in the file icon. Determine the relative positional relationship between the icon and the text label in the file icon; Based on the size information and the relative positional relationship, the file icon is converted into a bitmap corresponding to the target file.
5. The method for dynamically generating file type icons with extensions according to claim 4, characterized in that, The step of converting the file icon into a bitmap corresponding to the target file based on the size information and the relative position relationship includes: Create the target space based on the first size information; Based on the second size information, the third size information, and the relative positional relationship, determine the first coordinate information of the icon in the target space and the second coordinate information of the text label in the target space; Based on the first coordinate information and the second coordinate information, the file icon is drawn onto the target space to obtain the bitmap corresponding to the target file.
6. The method for dynamically generating file type icons with extensions according to any one of claims 1-3, characterized in that, The method further includes: When the target bitmap corresponding to the target key value exists in the cache space, the target bitmap is displayed in the target interface corresponding to the target file. And, after generating the bitmap corresponding to the target file based on the file extension and the file type, the method further includes: Generate key-value pairs based on the target key and the bitmap, and store the key-value pairs in the cache space.
7. The method for dynamically generating file type icons with extensions according to claim 2 or 3, characterized in that, The special file types include thumbnail file types or ISO file types; When the file type includes the special file type, loading the special file icon corresponding to the target file includes: When the file type includes the thumbnail file type, the preset thumbnail generation interface is called to obtain the thumbnail icon corresponding to the target file; When the file type includes the ISO file type, obtain the preset image icon corresponding to the ISO file type.
8. A device for dynamically generating file type icons with file extensions, characterized in that, The device includes: The acquisition module is used to acquire the target file and the file information of the target file, wherein the file information includes path information and attribute information; The judgment module is used to obtain the target file and its file information when the target file stored in the network attached storage device is read by the application. The file information includes path information and attribute information. The determination module is used to extract the file extension of the target file when the target file is not a directory file, and determine the file type of the target file according to the file extension and a preset file type mapping table; The determining module is further configured to determine the target key value of the target file based on the file extension and the file type; The detection module is used to detect whether the target bitmap corresponding to the target key value exists in a preset cache space; The generation module is used to generate a bitmap corresponding to the target file based on the file extension and the file type when the target bitmap corresponding to the target key value does not exist in the cache space, and to display the bitmap in the target interface.
9. An electronic device, characterized in that, The electronic device includes: Memory containing executable program code; A processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the dynamic generation method for file type icons with extensions as described in any one of claims 1-7.
10. A dynamic generation system for file type icons with extensions, characterized in that, The system includes at least the dynamic generation device for file type icons with extensions as described in claim 8, and a network attached storage device communicatively connected to the dynamic generation device for file type icons with extensions, wherein program code is stored on the network attached storage device, and the dynamic generation device for file type icons with extensions runs the program code to perform the dynamic generation method for file type icons with extensions as described in any one of claims 1-7. Alternatively, the system may include at least the electronic device as described in claim 9, and a network-attached storage device communicatively connected to the electronic device, wherein the network-attached storage device stores program code, and the electronic device executes the program code to perform the dynamic generation method for file type icons with extensions as described in any one of claims 1-7.