diff --git a/src/renderer/components/ConfigForm.vue b/src/renderer/components/ConfigForm.vue index 674c55a..7a24949 100644 --- a/src/renderer/components/ConfigForm.vue +++ b/src/renderer/components/ConfigForm.vue @@ -167,7 +167,16 @@ async function getCurConfigFormData () { return curTypeConfigList.find(i => i._id === configId) || {} } +function updateRuleForm (key: string, value: any) { + try { + ruleForm[key] = value + } catch (e) { + console.log(e) + } +} + defineExpose({ + updateRuleForm, validate, getConfigType }) diff --git a/src/renderer/pages/picbeds/index.vue b/src/renderer/pages/picbeds/index.vue index 0295177..4c84e64 100644 --- a/src/renderer/pages/picbeds/index.vue +++ b/src/renderer/pages/picbeds/index.vue @@ -44,6 +44,31 @@ > {{ $T('CONFIRM') }} + + + {{ $T('MANAGE_LOGIN_PAGE_PANE_IMPORT') }} + + + @@ -73,18 +98,23 @@ import { } from 'electron' import { OPEN_URL } from '~/universal/events/constants' import { Link } from '@element-plus/icons-vue' +import dayjs from 'dayjs' +import { ElDropdown } from 'element-plus' const type = ref('') const config = ref([]) +const picBedConfigList = ref([]) const picBedName = ref('') const $route = useRoute() const $router = useRouter() const $configForm = ref | null>(null) +const $dropdown = ref | null>(null) type.value = $route.params.type as string -onBeforeMount(() => { +onBeforeMount(async () => { sendToMain('getPicBedConfig', $route.params.type) ipcRenderer.on('getPicBedConfig', getPicBeds) + await getPicBedConfigList() }) const handleConfirm = async () => { @@ -101,6 +131,31 @@ const handleConfirm = async () => { } } +function handleMouseEnter () { + $dropdown.value?.handleOpen() +} + +function handleMouseLeave () { + $dropdown.value?.handleClose() +} + +async function getPicBedConfigList () { + const res = await triggerRPC(IRPCActionType.GET_PICBED_CONFIG_LIST, type.value) || undefined + const configList = res?.configList || [] + picBedConfigList.value = configList.filter((item) => item._id !== $route.params.configId) +} + +async function handleConfigImport (configItem: IUploaderConfigListItem) { + const { _id, _configName, _updatedAt, _createdAt, ...rest } = configItem + for (const key in rest) { + if (Object.prototype.hasOwnProperty.call(rest, key)) { + const value = rest[key] + $configForm.value?.updateRuleForm(key, value) + } + } + $configForm.value?.updateRuleForm('_configName', dayjs(_updatedAt).format('YYYYMMDDHHmmss')) +} + const handleReset = async () => { await triggerRPC(IRPCActionType.RESET_UPLOADER_CONFIG, type.value, $route.params.configId) const successNotification = new Notification($T('SETTINGS_RESULT'), { @@ -175,7 +230,7 @@ export default { cursor pointer color #409EFF .confirm-btn - width: 250px + width: 110px .el-form label line-height 22px @@ -186,7 +241,7 @@ export default { .el-button-group width 100% .el-button - width 50% + width 33% .el-radio-group margin-left 25px .el-switch__label