feat(admin): add module settings to toggle trading feature

Introduce module_settings table to store global feature flags
Add admin UI to enable or disable the Trading module
Hide trading-related UI and skip data fetching when disabled
This commit is contained in:
2026-05-10 16:59:07 +08:00
parent 26bef1b749
commit 42319695e9
11 changed files with 271 additions and 85 deletions

View File

@@ -145,7 +145,9 @@ const selectedUploadImage = computed(() => (selectedPokemonImage.value?.source =
const canCreateConfig = computed(() => currentUser.value?.permissions.includes('admin.config.create') === true);
const canFetchPokemon = computed(() => currentUser.value?.permissions.includes('pokemon.fetch') === true);
const canUploadImage = computed(() => currentUser.value?.permissions.includes('pokemon.upload') === true);
const hasTradingSkill = computed(() => pokemonForm.value.skillIds.some((skillId) => skillSupportsTrading(skillId)));
const tradingModuleEnabled = computed(() => options.value?.moduleSettings.tradingEnabled ?? true);
const selectedTradingSkill = computed(() => pokemonForm.value.skillIds.some((skillId) => skillSupportsTrading(skillId)));
const hasTradingSkill = computed(() => tradingModuleEnabled.value && selectedTradingSkill.value);
function toIds(values: string[]): number[] {
return values.map(Number).filter((item) => Number.isInteger(item) && item > 0);
@@ -227,7 +229,7 @@ function skillSupportsTrading(skillId: string) {
function syncSkillFeatures() {
syncSkillItemDrops();
if (!hasTradingSkill.value) {
if (tradingModuleEnabled.value && !hasTradingSkill.value) {
pokemonForm.value.tradingItems = [];
}
}