From 0148f9bee0938cbd90a5e6f4cf46c57e3e1d1084 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Tue, 25 Mar 2025 11:17:04 +0900 Subject: [PATCH] [Update] (Affect to backend) Plugin System. Saveable if the plugin is enabled or not. Add functions that merge plugins data. --- src-python/config.py | 13 +++ src-python/controller.py | 9 ++ src-python/mainloop.py | 3 + src-ui/app/App.jsx | 8 +- .../_app_controllers/PluginsController.jsx | 77 +++++++++++++-- .../download_plugins/DownloadPlugins.jsx | 35 ------- .../setting_box/_components/index.js | 2 +- .../PluginsControlComponent.jsx | 48 ++++++++++ .../PluginsControlComponent.module.scss} | 0 .../switch_box/SwitchBox.module.scss | 1 + .../setting_box/plugins/Plugins.jsx | 95 ++++++++----------- .../app/main_page/main_section/PluginHost.jsx | 7 +- src-ui/logics/configs/plugins/usePlugins.js | 50 ++++++---- src-ui/logics/useReceiveRoutes.js | 6 ++ src-ui/store.js | 9 +- 15 files changed, 229 insertions(+), 134 deletions(-) delete mode 100644 src-ui/app/config_page/setting_section/setting_box/_components/download_plugins/DownloadPlugins.jsx create mode 100644 src-ui/app/config_page/setting_section/setting_box/_components/plugins_control_component/PluginsControlComponent.jsx rename src-ui/app/config_page/setting_section/setting_box/_components/{download_plugins/DownloadPlugins.module.scss => plugins_control_component/PluginsControlComponent.module.scss} (100%) diff --git a/src-python/config.py b/src-python/config.py index b607863b..8038b047 100644 --- a/src-python/config.py +++ b/src-python/config.py @@ -555,6 +555,18 @@ class Config: self._HOTKEYS[key] = value self.saveConfig(inspect.currentframe().f_code.co_name, self.HOTKEYS, immediate_save=True) + @property + @json_serializable('PLUGINS_STATUS') + def PLUGINS_STATUS(self): + return self._PLUGINS_STATUS + + @PLUGINS_STATUS.setter + def PLUGINS_STATUS(self, value): + if isinstance(value, list): + if all(isinstance(item, dict) for item in value): + self._PLUGINS_STATUS = value + self.saveConfig(inspect.currentframe().f_code.co_name, self.PLUGINS_STATUS, immediate_save=True) + @property @json_serializable('MIC_AVG_LOGPROB') def MIC_AVG_LOGPROB(self): @@ -1068,6 +1080,7 @@ class Config: "toggle_transcription_send": None, "toggle_transcription_receive": None, } + self._PLUGINS_STATUS = [] self._MIC_AVG_LOGPROB = -0.8 self._MIC_NO_SPEECH_PROB = 0.6 self._AUTO_SPEAKER_SELECT = True diff --git a/src-python/controller.py b/src-python/controller.py index f0356287..02ba5e34 100644 --- a/src-python/controller.py +++ b/src-python/controller.py @@ -1061,6 +1061,15 @@ class Controller: config.HOTKEYS = data return {"status":200, "result":config.HOTKEYS} + @staticmethod + def getPluginsStatus(*args, **kwargs) -> dict: + return {"status":200, "result":config.PLUGINS_STATUS} + + @staticmethod + def setPluginsStatus(data, *args, **kwargs) -> dict: + config.PLUGINS_STATUS = data + return {"status":200, "result":config.PLUGINS_STATUS} + @staticmethod def getSpeakerAvgLogprob(*args, **kwargs) -> dict: return {"status":200, "result":config.SPEAKER_AVG_LOGPROB} diff --git a/src-python/mainloop.py b/src-python/mainloop.py index cd50a503..edd5356a 100644 --- a/src-python/mainloop.py +++ b/src-python/mainloop.py @@ -190,6 +190,9 @@ mapping = { "/get/data/hotkeys": {"status": True, "variable":controller.getHotkeys}, "/set/data/hotkeys": {"status": True, "variable":controller.setHotkeys}, + "/get/data/plugins_status": {"status": True, "variable":controller.getPluginsStatus}, + "/set/data/plugins_status": {"status": True, "variable":controller.setPluginsStatus}, + "/get/data/mic_avg_logprob": {"status": True, "variable":controller.getMicAvgLogprob}, "/set/data/mic_avg_logprob": {"status": True, "variable":controller.setMicAvgLogprob}, diff --git a/src-ui/app/App.jsx b/src-ui/app/App.jsx index 22c5107c..269bf824 100644 --- a/src-ui/app/App.jsx +++ b/src-ui/app/App.jsx @@ -1,3 +1,4 @@ +import { useRef } from "react"; import { useTranslation } from "react-i18next"; import { @@ -29,6 +30,7 @@ export const App = () => { const { currentIsBackendReady } = useIsBackendReady(); const { WindowGeometryController } = useWindow(); const { i18n } = useTranslation(); + const fetchPluginsHasRunRef = useRef(false); return (
{plugin.title}
{plugin.plugin_id}
@@ -113,9 +93,10 @@ const PluginDownloadContainer = () => { Compatible: {plugin.min_supported_vrct_version} ~ {plugin.max_supported_vrct_version}