mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 14:48:13 -05:00
✨ Feature: add config import for picbed setting
This commit is contained in:
parent
dce26ff6f3
commit
1b15ccb19c
@ -167,7 +167,16 @@ async function getCurConfigFormData () {
|
|||||||
return curTypeConfigList.find(i => i._id === configId) || {}
|
return curTypeConfigList.find(i => i._id === configId) || {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateRuleForm (key: string, value: any) {
|
||||||
|
try {
|
||||||
|
ruleForm[key] = value
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
updateRuleForm,
|
||||||
validate,
|
validate,
|
||||||
getConfigType
|
getConfigType
|
||||||
})
|
})
|
||||||
|
@ -44,6 +44,31 @@
|
|||||||
>
|
>
|
||||||
{{ $T('CONFIRM') }}
|
{{ $T('CONFIRM') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
class="confirm-btn"
|
||||||
|
round
|
||||||
|
type="warning"
|
||||||
|
@mouseenter="handleMouseEnter"
|
||||||
|
@mouseleave="handleMouseLeave"
|
||||||
|
>
|
||||||
|
<el-dropdown
|
||||||
|
ref="$dropdown"
|
||||||
|
placement="top"
|
||||||
|
style="color: #fff; font-size: 12px;width: 100%;"
|
||||||
|
:disabled="picBedConfigList.length === 0"
|
||||||
|
>
|
||||||
|
{{ $T('MANAGE_LOGIN_PAGE_PANE_IMPORT') }}
|
||||||
|
<template #dropdown>
|
||||||
|
<el-dropdown-item
|
||||||
|
v-for="i in picBedConfigList"
|
||||||
|
:key="i._id"
|
||||||
|
@click="handleConfigImport(i)"
|
||||||
|
>
|
||||||
|
{{ i._configName }}
|
||||||
|
</el-dropdown-item>
|
||||||
|
</template>
|
||||||
|
</el-dropdown>
|
||||||
|
</el-button>
|
||||||
</el-button-group>
|
</el-button-group>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</config-form>
|
</config-form>
|
||||||
@ -73,18 +98,23 @@ import {
|
|||||||
} from 'electron'
|
} from 'electron'
|
||||||
import { OPEN_URL } from '~/universal/events/constants'
|
import { OPEN_URL } from '~/universal/events/constants'
|
||||||
import { Link } from '@element-plus/icons-vue'
|
import { Link } from '@element-plus/icons-vue'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import { ElDropdown } from 'element-plus'
|
||||||
|
|
||||||
const type = ref('')
|
const type = ref('')
|
||||||
const config = ref<IPicGoPluginConfig[]>([])
|
const config = ref<IPicGoPluginConfig[]>([])
|
||||||
|
const picBedConfigList = ref<IUploaderConfigListItem[]>([])
|
||||||
const picBedName = ref('')
|
const picBedName = ref('')
|
||||||
const $route = useRoute()
|
const $route = useRoute()
|
||||||
const $router = useRouter()
|
const $router = useRouter()
|
||||||
const $configForm = ref<InstanceType<typeof ConfigForm> | null>(null)
|
const $configForm = ref<InstanceType<typeof ConfigForm> | null>(null)
|
||||||
|
const $dropdown = ref<InstanceType<typeof ElDropdown> | null>(null)
|
||||||
type.value = $route.params.type as string
|
type.value = $route.params.type as string
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(async () => {
|
||||||
sendToMain('getPicBedConfig', $route.params.type)
|
sendToMain('getPicBedConfig', $route.params.type)
|
||||||
ipcRenderer.on('getPicBedConfig', getPicBeds)
|
ipcRenderer.on('getPicBedConfig', getPicBeds)
|
||||||
|
await getPicBedConfigList()
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
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<IUploaderConfigItem>(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 () => {
|
const handleReset = async () => {
|
||||||
await triggerRPC<void>(IRPCActionType.RESET_UPLOADER_CONFIG, type.value, $route.params.configId)
|
await triggerRPC<void>(IRPCActionType.RESET_UPLOADER_CONFIG, type.value, $route.params.configId)
|
||||||
const successNotification = new Notification($T('SETTINGS_RESULT'), {
|
const successNotification = new Notification($T('SETTINGS_RESULT'), {
|
||||||
@ -175,7 +230,7 @@ export default {
|
|||||||
cursor pointer
|
cursor pointer
|
||||||
color #409EFF
|
color #409EFF
|
||||||
.confirm-btn
|
.confirm-btn
|
||||||
width: 250px
|
width: 110px
|
||||||
.el-form
|
.el-form
|
||||||
label
|
label
|
||||||
line-height 22px
|
line-height 22px
|
||||||
@ -186,7 +241,7 @@ export default {
|
|||||||
.el-button-group
|
.el-button-group
|
||||||
width 100%
|
width 100%
|
||||||
.el-button
|
.el-button
|
||||||
width 50%
|
width 33%
|
||||||
.el-radio-group
|
.el-radio-group
|
||||||
margin-left 25px
|
margin-left 25px
|
||||||
.el-switch__label
|
.el-switch__label
|
||||||
|
Loading…
Reference in New Issue
Block a user