mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-08-07 22:44:10 +08:00
✨ Feature(custom): automatically save config change of image process setting
#412
This commit is contained in:
@@ -9,15 +9,6 @@
|
|||||||
<p>{{ $t('pages.imageProcess.description') }}</p>
|
<p>{{ $t('pages.imageProcess.description') }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="header-actions">
|
|
||||||
<button class="btn btn-secondary" @click="closeDialog">
|
|
||||||
{{ $t('pages.imageProcess.cancel') }}
|
|
||||||
</button>
|
|
||||||
<button class="btn btn-primary" @click="handleSaveConfig">
|
|
||||||
<Save :size="16" />
|
|
||||||
{{ $t('pages.imageProcess.confirm') }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Tab Navigation -->
|
<!-- Tab Navigation -->
|
||||||
@@ -699,9 +690,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { Image, RotateCw, Save, Settings } from 'lucide-vue-next'
|
import { Image, RotateCw, Settings } from 'lucide-vue-next'
|
||||||
import type { IBuildInCompressOptions, IBuildInWaterMarkOptions } from 'piclist'
|
import type { IBuildInCompressOptions, IBuildInWaterMarkOptions } from 'piclist'
|
||||||
import { computed, onBeforeMount, reactive, ref, toRaw } from 'vue'
|
import { computed, onBeforeMount, reactive, ref, toRaw, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
import { configPaths } from '@/utils/configPaths'
|
import { configPaths } from '@/utils/configPaths'
|
||||||
@@ -711,7 +702,6 @@ import { updatePicBedGlobal } from '@/utils/global'
|
|||||||
import PerPicbedSetting from './PerPicbedSetting.vue'
|
import PerPicbedSetting from './PerPicbedSetting.vue'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const imageProcessDialogVisible = defineModel<boolean>()
|
|
||||||
const activeTab = ref('general')
|
const activeTab = ref('general')
|
||||||
|
|
||||||
const tabs = computed(() => [
|
const tabs = computed(() => [
|
||||||
@@ -847,6 +837,9 @@ const waterMarkFormKeys = Object.keys(waterMarkForm) as (keyof typeof waterMarkF
|
|||||||
const compressFormKeys = Object.keys(compressForm) as (keyof typeof compressForm)[]
|
const compressFormKeys = Object.keys(compressForm) as (keyof typeof compressForm)[]
|
||||||
const skipProcessFormKeys = Object.keys(skipProcessForm) as (keyof typeof skipProcessForm)[]
|
const skipProcessFormKeys = Object.keys(skipProcessForm) as (keyof typeof skipProcessForm)[]
|
||||||
|
|
||||||
|
const isInitialized = ref(false)
|
||||||
|
let saveTimeout: ReturnType<typeof setTimeout> | null = null
|
||||||
|
|
||||||
function handleSaveConfig() {
|
function handleSaveConfig() {
|
||||||
let iformatConvertObj = {}
|
let iformatConvertObj = {}
|
||||||
try {
|
try {
|
||||||
@@ -881,7 +874,18 @@ function handleSaveConfig() {
|
|||||||
saveConfig(configPaths.buildIn.compress, toRaw(compressForm))
|
saveConfig(configPaths.buildIn.compress, toRaw(compressForm))
|
||||||
saveConfig(configPaths.buildIn.watermark, toRaw(waterMarkForm))
|
saveConfig(configPaths.buildIn.watermark, toRaw(waterMarkForm))
|
||||||
saveConfig(configPaths.buildIn.skipProcess, toRaw(skipProcessForm))
|
saveConfig(configPaths.buildIn.skipProcess, toRaw(skipProcessForm))
|
||||||
closeDialog()
|
}
|
||||||
|
|
||||||
|
function debouncedSave() {
|
||||||
|
if (!isInitialized.value) return
|
||||||
|
|
||||||
|
if (saveTimeout) {
|
||||||
|
clearTimeout(saveTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
saveTimeout = setTimeout(() => {
|
||||||
|
handleSaveConfig()
|
||||||
|
}, 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function initData() {
|
async function initData() {
|
||||||
@@ -915,10 +919,6 @@ async function initData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeDialog() {
|
|
||||||
imageProcessDialogVisible.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function for getting map values (now unused - moved to component)
|
// Helper function for getting map values (now unused - moved to component)
|
||||||
// function getMapValue(mapObj: Record<string, any> | undefined, picbedType: string, defaultValue: any) {
|
// function getMapValue(mapObj: Record<string, any> | undefined, picbedType: string, defaultValue: any) {
|
||||||
// if (!mapObj) return defaultValue
|
// if (!mapObj) return defaultValue
|
||||||
@@ -941,7 +941,19 @@ function safeSetMapValue(form: any, fieldName: string, picbedType: string, value
|
|||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
await updatePicBedGlobal()
|
await updatePicBedGlobal()
|
||||||
await initData()
|
await initData()
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
isInitialized.value = true
|
||||||
|
}, 100)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => [compressForm, waterMarkForm, skipProcessForm, formatConvertObj.value],
|
||||||
|
() => {
|
||||||
|
debouncedSave()
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user