Feat: Vite + React (#991)

* remove test_web

* integrate reactjs-vite

* update lint-staged

* simple cors proxy server which handles cookies and redirections

* overrider global fetch with proxy call

* simple examples for set cookies and fetch request

* app bar

* add redux

* loadPlugins.
error: cant load urlencode module

* add ts-node for transforming

* plugin search & select

* plugin slice

* accordion components

* path item & popular novel

* optional for filters

* search novel

* parse novel

* parseChapter

* update cookies

* default filters

* fix: import path

* bundler module resolution

* new json_plugins

* fix: generate multisrc (missing filters)

* fix: host scripts

* fix: plugin code path

* remove typechecking action
This commit is contained in:
nyagami
2024-06-16 18:13:41 +07:00
committed by GitHub
parent a4cb781f32
commit d36e8ec85f
333 changed files with 5857 additions and 28579 deletions
+11
View File
@@ -0,0 +1,11 @@
import { AppState } from '@redux/store';
import React from 'react';
import { useSelector } from 'react-redux';
export default function DialogProvider() {
const activeDialogs = useSelector(
(state: AppState) => state.dialog.activeDialogs,
);
return <></>;
}
+29
View File
@@ -0,0 +1,29 @@
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 { 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
open={loading}
sx={{ color: '#fff', zIndex: theme => theme.zIndex.appBar + 1 }}
>
<Box sx={{ p: 4, bgcolor: 'InfoBackground' }}>
<CircularProgress color="primary" />
</Box>
</Backdrop>
<DialogProvider />
</Container>
);
}
+24
View File
@@ -0,0 +1,24 @@
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);
};
export const searchPlugins = (keyword: string) => {
return plugins.filter(
f => f.name.includes(keyword) || f.id.includes(keyword),
);
};
export const getPlugin = (id: string) => plugins.find(f => f.id === id);