Skip to content

Commit a7e7d34

Browse files
committed
feat: 重置 AquaMai 设置
1 parent 49ff345 commit a7e7d34

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

AquaMai

MaiChartManager/Front/src/views/ModManager/ConfigSection.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,27 @@ export default defineComponent({
3333
return props.section.attribute?.comment?.commentEn;
3434
})
3535

36-
return () => <div class="flex flex-col p-1 border-transparent border-solid border-1px rd hover:border-[oklch(0.68_0.17_var(--hue))]">
36+
const resetSection = () => {
37+
props.section.entries?.forEach(entry => {
38+
const state = props.entryStates[entry.path!];
39+
if (state) {
40+
state.value = state.defaultValue;
41+
state.isDefault = true;
42+
}
43+
});
44+
};
45+
46+
const isEnabled = computed(() => props.section.attribute!.alwaysEnabled || props.sectionState.enabled);
47+
48+
const resetIcon = () => isEnabled.value ? (
49+
<div
50+
class="i-carbon:reset text-lg cursor-pointer opacity-0 group-hover:opacity-50 hover:opacity-80 transition-opacity shrink-0"
51+
title={t('mod.resetToDefault')}
52+
onClick={resetSection}
53+
/>
54+
) : null;
55+
56+
return () => <div class={["flex flex-col p-1 border-transparent border-solid border-1px rd hover:border-[oklch(0.68_0.17_var(--hue))] group"]}>
3757
{!props.section.attribute!.alwaysEnabled && <div class="flex gap-2 items-start"
3858
// @ts-ignore
3959
title={props.section.path!}
@@ -50,6 +70,8 @@ export default defineComponent({
5070
<div class="text-sm whitespace-pre-line lh-1.7em">{t('mod.community.description')}</div>
5171
</div>
5272
}}</Popover>}
73+
<div class="flex-1" />
74+
{resetIcon()}
5375
</div>
5476
<div class="text-sm op-80">{comment.value}</div>
5577
</div>

0 commit comments

Comments
 (0)