[Update/Refactor/bugfix]

Update: Add functions and test ui.
Update, backend: send latest vrct version to frontend.
Refactor: Change the plugins data structure.
bugfix: fix endless showing update button.
This commit is contained in:
Sakamoto Shiina
2025-04-09 17:29:31 +09:00
parent 67f32ad7b9
commit 7e637b795d
18 changed files with 404 additions and 180 deletions

View File

@@ -0,0 +1,40 @@
import semver from "semver";
import { useStore_SoftwareVersion, useStore_LatestSoftwareVersionInfo } from "@store";
import { useStdoutToPython } from "@logics/useStdoutToPython";
export const useSoftwareVersion = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { currentLatestSoftwareVersionInfo, updateLatestSoftwareVersionInfo } = useStore_LatestSoftwareVersionInfo();
const { currentSoftwareVersion, updateSoftwareVersion, pendingSoftwareVersion } = useStore_SoftwareVersion();
const getSoftwareVersion = () => {
pendingSoftwareVersion();
asyncStdoutToPython("/get/data/version");
};
const isPluginCompatible = (main_version, lower_version, upper_version) => {
// lower_version 以上かつ upper_version 以下なら互換性ありと判定
return semver.gte(main_version, lower_version) && semver.lte(main_version, upper_version);
};
const checkVrctVerCompatibility = (min_version, max_version) => {
const current_vrct_version = currentSoftwareVersion.data;
const latest_vrct_version = currentLatestSoftwareVersionInfo.data.new_version;
const is_plugin_supported = isPluginCompatible(current_vrct_version, min_version, max_version);
const is_plugin_supported_latest_vrct = isPluginCompatible(latest_vrct_version, min_version, max_version);
return { is_plugin_supported, is_plugin_supported_latest_vrct };
};
return {
currentSoftwareVersion,
getSoftwareVersion,
updateSoftwareVersion,
currentLatestSoftwareVersionInfo,
updateLatestSoftwareVersionInfo,
checkVrctVerCompatibility,
};
};