diff --git a/src/pages/pc/Setting.vue b/src/pages/pc/Setting.vue
index 2b7a7fd6..f26a852b 100644
--- a/src/pages/pc/Setting.vue
+++ b/src/pages/pc/Setting.vue
@@ -14,9 +14,10 @@ import {saveAs} from "file-saver";
import {GITHUB} from "@/config/ENV.ts";
import dayjs from "dayjs";
import BasePage from "@/pages/pc/components/BasePage.vue";
-import {ElInputNumber, ElRadio, ElRadioGroup, ElSlider, ElSwitch} from 'element-plus'
+import {ElInputNumber, ElRadio, ElRadioGroup, ElSlider} from 'element-plus'
import Toast from '@/pages/pc/components/Toast/Toast.ts'
import {Option, Select} from "@/pages/pc/components/Select";
+import Switch from "@/pages/pc/components/Switch.vue";
const emit = defineEmits<{
toggleDisabledDialogEscKey: [val: boolean]
@@ -163,9 +164,8 @@ function importData(e) {
-
@@ -175,7 +175,7 @@ function importData(e) {
-
-
-
-
-
-
+import {ref, computed, defineProps, defineEmits, watch} from 'vue';
+
+const props = defineProps<{
+ modelValue: boolean;
+ disabled?: boolean;
+ width?: number; // 开关宽度,默认 40px
+ activeText?: string; // 开启状态显示文字
+ inactiveText?: string;// 关闭状态显示文字
+}>();
+
+const emit = defineEmits(['update:modelValue']);
+
+const isChecked = ref(props.modelValue);
+
+watch(() => props.modelValue, (val) => {
+ isChecked.value = val;
+});
+
+const toggle = () => {
+ if (props.disabled) return;
+ isChecked.value = !isChecked.value;
+ emit('update:modelValue', isChecked.value);
+};
+
+const onKeydown = (e: KeyboardEvent) => {
+ if (e.code === 'Space' || e.key === ' ') {
+ e.preventDefault();
+ toggle();
+ }
+};
+
+const switchWidth = computed(() => props.width ?? 40);
+const switchHeight = computed(() => (switchWidth.value / 2) | 0);
+const ballSize = computed(() => switchHeight.value - 4);
+
+
+
+
+
+ {{ activeText }}
+
+
+
+ {{ inactiveText }}
+
+
+
+
+