mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-02 19:01:40 +00:00
restructure files onto electron-vite boilerplate
This commit is contained in:
parent
91ce2cd8a1
commit
1cf587bc8f
457 changed files with 9927 additions and 11705 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { createContext, Fragment, ReactNode, useState, useMemo, useCallback } from 'react';
|
||||
import { RowNode } from '@ag-grid-community/core';
|
||||
import { Divider, Group, Portal, Stack } from '@mantine/core';
|
||||
import {
|
||||
|
|
@ -11,8 +10,7 @@ import {
|
|||
import { closeAllModals, openContextModal, openModal } from '@mantine/modals';
|
||||
import { AnimatePresence } from 'framer-motion';
|
||||
import isElectron from 'is-electron';
|
||||
import { ServerFeature } from '/@/renderer/api/features-types';
|
||||
import { hasFeature } from '/@/renderer/api/utils';
|
||||
import { createContext, Fragment, ReactNode, useCallback, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
RiAddBoxFill,
|
||||
|
|
@ -21,20 +19,25 @@ import {
|
|||
RiArrowGoForwardLine,
|
||||
RiArrowRightSFill,
|
||||
RiArrowUpLine,
|
||||
RiCloseCircleLine,
|
||||
RiDeleteBinFill,
|
||||
RiDislikeFill,
|
||||
RiDownload2Line,
|
||||
RiHeartFill,
|
||||
RiInformationFill,
|
||||
RiPlayFill,
|
||||
RiPlayListAddFill,
|
||||
RiStarFill,
|
||||
RiCloseCircleLine,
|
||||
RiShareForwardFill,
|
||||
RiInformationFill,
|
||||
RiRadio2Fill,
|
||||
RiDownload2Line,
|
||||
RiShareForwardFill,
|
||||
RiShuffleFill,
|
||||
RiStarFill,
|
||||
} from 'react-icons/ri';
|
||||
import { AnyLibraryItems, LibraryItem, ServerType, AnyLibraryItem } from '/@/renderer/api/types';
|
||||
|
||||
import { api } from '/@/renderer/api';
|
||||
import { controller } from '/@/renderer/api/controller';
|
||||
import { ServerFeature } from '/@/renderer/api/features-types';
|
||||
import { AnyLibraryItem, AnyLibraryItems, LibraryItem, ServerType } from '/@/renderer/api/types';
|
||||
import { hasFeature } from '/@/renderer/api/utils';
|
||||
import {
|
||||
ConfirmModal,
|
||||
ContextMenu,
|
||||
|
|
@ -49,7 +52,9 @@ import {
|
|||
OpenContextMenuProps,
|
||||
useContextMenuEvents,
|
||||
} from '/@/renderer/features/context-menu/events';
|
||||
import { ItemDetailsModal } from '/@/renderer/features/item-details/components/item-details-modal';
|
||||
import { usePlayQueueAdd } from '/@/renderer/features/player';
|
||||
import { updateSong } from '/@/renderer/features/player/update-remote-song';
|
||||
import { useDeletePlaylist } from '/@/renderer/features/playlists';
|
||||
import { useRemoveFromPlaylist } from '/@/renderer/features/playlists/mutations/remove-from-playlist-mutation';
|
||||
import { useCreateFavorite, useDeleteFavorite, useSetRating } from '/@/renderer/features/shared';
|
||||
|
|
@ -63,10 +68,6 @@ import {
|
|||
} from '/@/renderer/store';
|
||||
import { usePlaybackType } from '/@/renderer/store/settings.store';
|
||||
import { Play, PlaybackType } from '/@/renderer/types';
|
||||
import { ItemDetailsModal } from '/@/renderer/features/item-details/components/item-details-modal';
|
||||
import { updateSong } from '/@/renderer/features/player/update-remote-song';
|
||||
import { controller } from '/@/renderer/api/controller';
|
||||
import { api } from '/@/renderer/api';
|
||||
import { setQueue, setQueueNext } from '/@/renderer/utils/set-transcoded-queue-data';
|
||||
|
||||
type ContextMenuContextProps = {
|
||||
|
|
@ -78,7 +79,7 @@ type ContextMenuItem = {
|
|||
children?: ContextMenuItem[];
|
||||
disabled?: boolean;
|
||||
id: string;
|
||||
label: string | ReactNode;
|
||||
label: ReactNode | string;
|
||||
leftIcon?: ReactNode;
|
||||
onClick?: (...args: any) => any;
|
||||
rightIcon?: ReactNode;
|
||||
|
|
@ -95,7 +96,11 @@ const JELLYFIN_IGNORED_MENU_ITEMS: ContextMenuItemType[] = ['setRating', 'shareI
|
|||
// const NAVIDROME_IGNORED_MENU_ITEMS: ContextMenuItemType[] = [];
|
||||
// const SUBSONIC_IGNORED_MENU_ITEMS: ContextMenuItemType[] = [];
|
||||
|
||||
const utils = isElectron() ? window.electron.utils : null;
|
||||
const utils = isElectron() ? window.api.utils : null;
|
||||
|
||||
export interface ContextMenuProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
function RatingIcon({ rating }: { rating: number }) {
|
||||
return (
|
||||
|
|
@ -109,10 +114,6 @@ function RatingIcon({ rating }: { rating: number }) {
|
|||
);
|
||||
}
|
||||
|
||||
export interface ContextMenuProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
||||
const disabledItems = useSettingsStore((state) => state.general.disabledContextMenu);
|
||||
const { t } = useTranslation();
|
||||
|
|
@ -139,15 +140,15 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
const openContextMenu = useCallback(
|
||||
(args: OpenContextMenuProps) => {
|
||||
const {
|
||||
context,
|
||||
data,
|
||||
dataNodes,
|
||||
menuItems,
|
||||
resetGridCache,
|
||||
tableApi,
|
||||
type,
|
||||
xPos,
|
||||
yPos,
|
||||
menuItems,
|
||||
data,
|
||||
type,
|
||||
tableApi,
|
||||
dataNodes,
|
||||
context,
|
||||
resetGridCache,
|
||||
} = args;
|
||||
|
||||
const serverType = data[0]?.serverType || useAuthStore.getState().currentServer?.type;
|
||||
|
|
@ -213,13 +214,13 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
playType,
|
||||
});
|
||||
break;
|
||||
case LibraryItem.ARTIST:
|
||||
case LibraryItem.ALBUM_ARTIST:
|
||||
handlePlayQueueAdd?.({
|
||||
byItemType: { id: ctx.data.map((item) => item.id), type: ctx.type },
|
||||
playType,
|
||||
});
|
||||
break;
|
||||
case LibraryItem.ALBUM_ARTIST:
|
||||
case LibraryItem.ARTIST:
|
||||
handlePlayQueueAdd?.({
|
||||
byItemType: { id: ctx.data.map((item) => item.id), type: ctx.type },
|
||||
playType,
|
||||
|
|
@ -231,9 +232,6 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
playType,
|
||||
});
|
||||
break;
|
||||
case LibraryItem.SONG:
|
||||
handlePlayQueueAdd?.({ byData: ctx.data, playType });
|
||||
break;
|
||||
case LibraryItem.PLAYLIST:
|
||||
for (const item of ctx.data) {
|
||||
handlePlayQueueAdd?.({
|
||||
|
|
@ -242,6 +240,9 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case LibraryItem.SONG:
|
||||
handlePlayQueueAdd?.({ byData: ctx.data, playType });
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
|
@ -510,8 +511,8 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
let songId: string[] | undefined;
|
||||
|
||||
switch (serverType) {
|
||||
case ServerType.NAVIDROME:
|
||||
case ServerType.JELLYFIN:
|
||||
case ServerType.NAVIDROME:
|
||||
songId = ctx.dataNodes?.map((node) => node.data.playlistItemId);
|
||||
break;
|
||||
case ServerType.SUBSONIC:
|
||||
|
|
@ -622,7 +623,7 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
);
|
||||
|
||||
const playbackType = usePlaybackType();
|
||||
const { moveToNextOfQueue, moveToBottomOfQueue, moveToTopOfQueue, removeFromQueue } =
|
||||
const { moveToBottomOfQueue, moveToNextOfQueue, moveToTopOfQueue, removeFromQueue } =
|
||||
useQueueControls();
|
||||
|
||||
const handleMoveToNext = useCallback(() => {
|
||||
|
|
@ -935,15 +936,15 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
<AnimatePresence>
|
||||
{opened && (
|
||||
<ContextMenu
|
||||
ref={mergedRef}
|
||||
minWidth={125}
|
||||
ref={mergedRef}
|
||||
xPos={ctx.xPos}
|
||||
yPos={ctx.yPos}
|
||||
>
|
||||
<Stack spacing={0}>
|
||||
<Stack
|
||||
spacing={0}
|
||||
onClick={closeContextMenu}
|
||||
spacing={0}
|
||||
>
|
||||
{ctx.menuItems?.map((item) => {
|
||||
return (
|
||||
|
|
@ -960,14 +961,14 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
contextMenuItems[item.id]
|
||||
.leftIcon
|
||||
}
|
||||
rightIcon={
|
||||
contextMenuItems[item.id]
|
||||
.rightIcon
|
||||
}
|
||||
onClick={
|
||||
contextMenuItems[item.id]
|
||||
.onClick
|
||||
}
|
||||
rightIcon={
|
||||
contextMenuItems[item.id]
|
||||
.rightIcon
|
||||
}
|
||||
>
|
||||
{
|
||||
contextMenuItems[item.id]
|
||||
|
|
@ -985,10 +986,10 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
leftIcon={
|
||||
child.leftIcon
|
||||
}
|
||||
onClick={child.onClick}
|
||||
rightIcon={
|
||||
child.rightIcon
|
||||
}
|
||||
onClick={child.onClick}
|
||||
>
|
||||
{child.label}
|
||||
</ContextMenuButton>
|
||||
|
|
@ -1001,12 +1002,12 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
leftIcon={
|
||||
contextMenuItems[item.id].leftIcon
|
||||
}
|
||||
rightIcon={
|
||||
contextMenuItems[item.id].rightIcon
|
||||
}
|
||||
onClick={
|
||||
contextMenuItems[item.id].onClick
|
||||
}
|
||||
rightIcon={
|
||||
contextMenuItems[item.id].rightIcon
|
||||
}
|
||||
>
|
||||
{contextMenuItems[item.id].label}
|
||||
</ContextMenuButton>
|
||||
|
|
@ -1014,8 +1015,8 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
|
||||
{item.divider && (
|
||||
<Divider
|
||||
key={`context-menu-divider-${item.id}`}
|
||||
color="rgb(62, 62, 62)"
|
||||
key={`context-menu-divider-${item.id}`}
|
||||
size="sm"
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,35 @@
|
|||
import { GridOptions, RowNode } from '@ag-grid-community/core';
|
||||
import { createUseExternalEvents } from '@mantine/utils';
|
||||
|
||||
import { LibraryItem } from '/@/renderer/api/types';
|
||||
|
||||
export type ContextMenuEvents = {
|
||||
closeContextMenu: () => void;
|
||||
openContextMenu: (args: OpenContextMenuProps) => void;
|
||||
};
|
||||
|
||||
export type ContextMenuItemType =
|
||||
| 'addToFavorites'
|
||||
| 'addToPlaylist'
|
||||
| 'createPlaylist'
|
||||
| 'deletePlaylist'
|
||||
| 'deselectAll'
|
||||
| 'download'
|
||||
| 'moveToBottomOfQueue'
|
||||
| 'moveToNextOfQueue'
|
||||
| 'moveToTopOfQueue'
|
||||
| 'play'
|
||||
| 'playLast'
|
||||
| 'playNext'
|
||||
| 'playShuffled'
|
||||
| 'playSimilarSongs'
|
||||
| 'removeFromFavorites'
|
||||
| 'removeFromPlaylist'
|
||||
| 'removeFromQueue'
|
||||
| 'setRating'
|
||||
| 'shareItem'
|
||||
| 'showDetails';
|
||||
|
||||
export type OpenContextMenuProps = {
|
||||
context?: any;
|
||||
data: any[];
|
||||
|
|
@ -14,33 +42,6 @@ export type OpenContextMenuProps = {
|
|||
yPos: number;
|
||||
};
|
||||
|
||||
export type ContextMenuEvents = {
|
||||
closeContextMenu: () => void;
|
||||
openContextMenu: (args: OpenContextMenuProps) => void;
|
||||
};
|
||||
|
||||
export type ContextMenuItemType =
|
||||
| 'play'
|
||||
| 'playLast'
|
||||
| 'playNext'
|
||||
| 'playShuffled'
|
||||
| 'addToPlaylist'
|
||||
| 'removeFromPlaylist'
|
||||
| 'addToFavorites'
|
||||
| 'removeFromFavorites'
|
||||
| 'setRating'
|
||||
| 'shareItem'
|
||||
| 'deletePlaylist'
|
||||
| 'createPlaylist'
|
||||
| 'moveToNextOfQueue'
|
||||
| 'moveToBottomOfQueue'
|
||||
| 'moveToTopOfQueue'
|
||||
| 'removeFromQueue'
|
||||
| 'deselectAll'
|
||||
| 'showDetails'
|
||||
| 'playSimilarSongs'
|
||||
| 'download';
|
||||
|
||||
export const CONFIGURABLE_CONTEXT_MENU_ITEMS: ContextMenuItemType[] = [
|
||||
'moveToBottomOfQueue',
|
||||
'moveToTopOfQueue',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { CellContextMenuEvent, GridApi } from '@ag-grid-community/core';
|
||||
import sortBy from 'lodash/sortBy';
|
||||
|
||||
import { Album, AlbumArtist, Artist, LibraryItem, QueueSong, Song } from '/@/renderer/api/types';
|
||||
import { openContextMenu, SetContextMenuItems } from '/@/renderer/features/context-menu/events';
|
||||
|
||||
|
|
@ -64,7 +65,7 @@ export const useHandleGeneralContextMenu = (
|
|||
) => {
|
||||
const handleContextMenu = (
|
||||
e: any,
|
||||
data: Song[] | QueueSong[] | AlbumArtist[] | Artist[] | Album[],
|
||||
data: Album[] | AlbumArtist[] | Artist[] | QueueSong[] | Song[],
|
||||
) => {
|
||||
if (!e) return;
|
||||
const clickEvent = e as MouseEvent;
|
||||
|
|
@ -92,7 +93,7 @@ export const useHandleGridContextMenu = (
|
|||
) => {
|
||||
const handleContextMenu = (
|
||||
e: any,
|
||||
data: Song[] | QueueSong[] | AlbumArtist[] | Artist[] | Album[],
|
||||
data: Album[] | AlbumArtist[] | Artist[] | QueueSong[] | Song[],
|
||||
) => {
|
||||
if (!e) return;
|
||||
const clickEvent = e as MouseEvent;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export * from './events';
|
||||
export * from './context-menu-provider';
|
||||
export * from './events';
|
||||
export * from './hooks/use-handle-context-menu';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue