[skip ci] Feat: Hot reload for plugins
This commit is contained in:
@@ -1,18 +1,11 @@
|
||||
import React, { ReactNode, useEffect } from 'react';
|
||||
import DialogProvider from './DialogProvider';
|
||||
import { Backdrop, Box, CircularProgress, Container } from '@mui/material';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { AppState } from '@redux/store';
|
||||
import { loadPlugins } from './plugins';
|
||||
import { hideLoading } from '@redux/overlaySlice';
|
||||
|
||||
export default function AppProvider() {
|
||||
const loading = useSelector((state: AppState) => state.overlay.loading);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
useEffect(() => {
|
||||
loadPlugins().then(() => dispatch(hideLoading()));
|
||||
}, []);
|
||||
return (
|
||||
<Container sx={{ position: 'absolute' }}>
|
||||
<Backdrop
|
||||
|
||||
+1
-16
@@ -1,19 +1,4 @@
|
||||
import { Plugin } from '@typings/plugin';
|
||||
|
||||
const plugins: Plugin.PluginBase[] = [];
|
||||
|
||||
export const loadPlugins = async () => {
|
||||
const paths = await fetch('pluginPaths').then(res => res.json());
|
||||
const fetchedPlugins: Plugin.PluginBase[] = [];
|
||||
for (const path of paths) {
|
||||
const relativePath = '../plugins/' + path;
|
||||
const plugin: Plugin.PluginBase = (
|
||||
await import(/* @vite-ignore */ relativePath)
|
||||
).default;
|
||||
fetchedPlugins.push(plugin);
|
||||
}
|
||||
plugins.splice(0, plugins.length, ...fetchedPlugins);
|
||||
};
|
||||
import plugins from '../plugins';
|
||||
|
||||
export const searchPlugins = (keyword: string) => {
|
||||
return plugins.filter(
|
||||
|
||||
Reference in New Issue
Block a user