[Refactor] Export config hooks from index.js
This commit is contained in:
@@ -595,48 +595,11 @@ const buildCategoryApiFromSettings = (settings, settingsArray, Category, extraFu
|
|||||||
return { ...api, ...extraFunctions };
|
return { ...api, ...extraFunctions };
|
||||||
};
|
};
|
||||||
|
|
||||||
const createCategoryHook = (Category) => {
|
export const createCategoryHook = (Category) => {
|
||||||
return () => {
|
return () => {
|
||||||
const { settings } = useSettingsLogics(SETTINGS_ARRAY, Category);
|
const { settings } = useSettingsLogics(SETTINGS_ARRAY, Category);
|
||||||
const extraFunctions = useConfigFunctions(Category);
|
const extraFunctions = useConfigFunctions(Category);
|
||||||
const autoApi = buildCategoryApiFromSettings(settings, SETTINGS_ARRAY, Category, extraFunctions);
|
const autoApi = buildCategoryApiFromSettings(settings, SETTINGS_ARRAY, Category, extraFunctions);
|
||||||
return { ...autoApi };
|
return { ...autoApi };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --- 自動エクスポート: SETTINGS_ARRAY に含まれるユニークな Category ごとに use<Category> を作って export ---
|
|
||||||
// 例: Category === "Appearance" -> export const useAppearance = createCategoryHook("Appearance");
|
|
||||||
|
|
||||||
// const uniqueCategories = Array.from(new Set(SETTINGS_ARRAY.map((s) => s.Category)));
|
|
||||||
|
|
||||||
// 動的に named export を作る(静的解析を壊さないために明示的に定義)
|
|
||||||
/* eslint-disable import/prefer-default-export */
|
|
||||||
export const useAppearance = createCategoryHook("Appearance");
|
|
||||||
export const useDevice = createCategoryHook("Device");
|
|
||||||
export const useTranslation = createCategoryHook("Translation");
|
|
||||||
export const useTranscription = createCategoryHook("Transcription");
|
|
||||||
export const useVr = createCategoryHook("Vr");
|
|
||||||
export const useOthers = createCategoryHook("Others");
|
|
||||||
export const useAdvancedSettings = createCategoryHook("AdvancedSettings");
|
|
||||||
|
|
||||||
// Exceptional exports that are not part of SETTINGS_ARRAY or have custom logic.
|
|
||||||
export { useHotkeys } from "./hotkeys/useHotkeys.js";
|
|
||||||
export { useSupporters } from "./supporters/useSupporters.js";
|
|
||||||
export { usePlugins } from "./plugins/usePlugins.js";
|
|
||||||
|
|
||||||
export { useSettingBoxScrollPosition } from "./_aux/useSettingBoxScrollPosition.js";
|
|
||||||
|
|
||||||
|
|
||||||
// If you later add other categories, you can either manually add:
|
|
||||||
// export const useDevice = createCategoryHook("Device");
|
|
||||||
// or uncomment the code below to auto-attach to module.exports (less ideal for tree-shaking).
|
|
||||||
//
|
|
||||||
// Auto-attach (not recommended for tree-shaking in bundlers):
|
|
||||||
// uniqueCategories.forEach((Category) => {
|
|
||||||
// const hookName = `use${Category}`;
|
|
||||||
// module.exports[hookName] = createCategoryHook(Category);
|
|
||||||
// });
|
|
||||||
|
|
||||||
/* eslint-enable import/prefer-default-export */
|
|
||||||
16
src-ui/logics/configs/index.js
Normal file
16
src-ui/logics/configs/index.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import { createCategoryHook } from "./config_page_setter/ui_config_setter.js";
|
||||||
|
|
||||||
|
export const useAppearance = createCategoryHook("Appearance");
|
||||||
|
export const useDevice = createCategoryHook("Device");
|
||||||
|
export const useTranslation = createCategoryHook("Translation");
|
||||||
|
export const useTranscription = createCategoryHook("Transcription");
|
||||||
|
export const useVr = createCategoryHook("Vr");
|
||||||
|
export const useOthers = createCategoryHook("Others");
|
||||||
|
export const useAdvancedSettings = createCategoryHook("AdvancedSettings");
|
||||||
|
|
||||||
|
// Exceptional exports that are not part of SETTINGS_ARRAY or have custom logic.
|
||||||
|
export { useHotkeys } from "./config_page_setter/hotkeys/useHotkeys.js";
|
||||||
|
export { useSupporters } from "./config_page_setter/supporters/useSupporters.js";
|
||||||
|
export { usePlugins } from "./config_page_setter/plugins/usePlugins.js";
|
||||||
|
|
||||||
|
export { useSettingBoxScrollPosition } from "./config_page_setter/_aux/useSettingBoxScrollPosition.js";
|
||||||
@@ -70,7 +70,7 @@ export default defineConfig(async () => {
|
|||||||
"@logics": path.resolve(__dirname, "src-ui/logics"),
|
"@logics": path.resolve(__dirname, "src-ui/logics"),
|
||||||
"@logics_common": path.resolve(__dirname, "src-ui/logics/common"),
|
"@logics_common": path.resolve(__dirname, "src-ui/logics/common"),
|
||||||
"@logics_main": path.resolve(__dirname, "src-ui/logics/main"),
|
"@logics_main": path.resolve(__dirname, "src-ui/logics/main"),
|
||||||
"@logics_configs": path.resolve(__dirname, "src-ui/logics/configs/config_page_setter/ui_config_setter.js"),
|
"@logics_configs": path.resolve(__dirname, "src-ui/logics/configs"),
|
||||||
|
|
||||||
"@setting_box": path.resolve(__dirname, "src-ui/views/app/config_page/setting_section/setting_box/index.js"),
|
"@setting_box": path.resolve(__dirname, "src-ui/views/app/config_page/setting_section/setting_box/index.js"),
|
||||||
"@common_components": path.resolve(__dirname, "src-ui/views/common_components/index.js"),
|
"@common_components": path.resolve(__dirname, "src-ui/views/common_components/index.js"),
|
||||||
|
|||||||
Reference in New Issue
Block a user