mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
Added shortcut sub icon
This commit is contained in:
@@ -121,22 +121,26 @@ export const getInfoWithExtension = (
|
||||
extension: string,
|
||||
callback: (value: FileInfo) => void
|
||||
): void => {
|
||||
const subIcons: string[] = [];
|
||||
const getInfoByFileExtension = (icon?: string): void =>
|
||||
callback({
|
||||
icon: icon || getIconByFileExtension(extension),
|
||||
pid: getProcessByFileExtension(extension),
|
||||
subIcons,
|
||||
url: path,
|
||||
});
|
||||
|
||||
if (extension === SHORTCUT_EXTENSION) {
|
||||
fs.readFile(path, (error, contents = EMPTY_BUFFER) => {
|
||||
subIcons.push("/System/Icons/shortcut.png");
|
||||
|
||||
if (error) {
|
||||
getInfoByFileExtension();
|
||||
} else {
|
||||
const { icon, pid, url } = getShortcutInfo(contents);
|
||||
const urlExt = extname(url);
|
||||
|
||||
callback({ icon, pid, url });
|
||||
callback({ icon, pid, subIcons, url });
|
||||
|
||||
if (
|
||||
IMAGE_FILE_EXTENSIONS.has(urlExt) ||
|
||||
@@ -145,7 +149,7 @@ export const getInfoWithExtension = (
|
||||
) {
|
||||
getInfoWithExtension(fs, url, urlExt, ({ icon: urlIcon }) => {
|
||||
if (urlIcon && urlIcon !== icon) {
|
||||
callback({ icon: urlIcon, pid, url });
|
||||
callback({ icon: urlIcon, pid, subIcons, url });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ const FileEntry = ({
|
||||
view,
|
||||
}: FileEntryProps): JSX.Element => {
|
||||
const { blurEntry, focusEntry } = focusFunctions;
|
||||
const { icon, pid, url } = useFileInfo(path, stats.isDirectory());
|
||||
const { icon, pid, subIcons, url } = useFileInfo(path, stats.isDirectory());
|
||||
const openFile = useFile(url);
|
||||
const { pasteList } = useFileSystem();
|
||||
const { formats } = useTheme();
|
||||
@@ -156,12 +156,15 @@ const FileEntry = ({
|
||||
)}
|
||||
>
|
||||
<figure>
|
||||
<Icon
|
||||
src={icon}
|
||||
alt={name}
|
||||
moving={pasteList[path] === "move"}
|
||||
{...FileEntryIconSize[view]}
|
||||
/>
|
||||
{[icon, ...(subIcons || [])].map((entryIcon) => (
|
||||
<Icon
|
||||
key={entryIcon}
|
||||
src={entryIcon}
|
||||
alt={name}
|
||||
moving={icon === entryIcon && pasteList[path] === "move"}
|
||||
{...FileEntryIconSize[view]}
|
||||
/>
|
||||
))}
|
||||
{renaming ? (
|
||||
<RenameBox
|
||||
name={name}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useEffect, useState } from "react";
|
||||
|
||||
export type FileInfo = {
|
||||
icon: string;
|
||||
subIcons?: string[];
|
||||
pid: string;
|
||||
url: string;
|
||||
};
|
||||
|
||||
@@ -44,6 +44,10 @@ const StyledFileEntry = styled.li<StyledFileEntryProps>`
|
||||
|
||||
img {
|
||||
width: ${({ theme }) => theme.sizes.fileEntry.iconSize};
|
||||
|
||||
&:not(:first-of-type) {
|
||||
position: absolute;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
public/System/Icons/16x16/shortcut.png
Normal file
BIN
public/System/Icons/16x16/shortcut.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 B |
BIN
public/System/Icons/48x48/shortcut.png
Normal file
BIN
public/System/Icons/48x48/shortcut.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 418 B |
Reference in New Issue
Block a user