refactor: 修改确认框

This commit is contained in:
zerosaturation 2026-04-13 11:30:05 +08:00
parent c7495ae42c
commit b25046f051

View File

@ -157,11 +157,24 @@
</view>
</view>
</view>
<!-- 通用确认弹窗 -->
<ConfirmModal
:visible="confirmModal.visible"
:title="confirmModal.title"
:content="confirmModal.content"
:confirmText="confirmModal.confirmText"
:cancelText="confirmModal.cancelText"
:showCancel="confirmModal.showCancel"
@confirm="onConfirmModal"
@cancel="onCancelModal"
/>
</template>
<script setup>
import { ref, computed } from 'vue'
import { GRID_CONFIG, generateGridCoordinates, IMAGE_W, IMAGE_H } from './config/cabin.js'
import ConfirmModal from '@/components/ConfirmModal.vue'
const config = ref(JSON.parse(JSON.stringify(GRID_CONFIG)))
const selectedIndex = ref(null)
@ -175,7 +188,46 @@ const scale = ref(1)
//
const bgOffsetX = ref(0)
let touchStartX = 0
let lastMoveX = 0
//
const confirmModal = ref({
visible: false,
title: '',
content: '',
confirmText: '确认',
cancelText: '取消',
showCancel: true,
confirmCallback: null
})
//
const onConfirmModal = () => {
if (confirmModal.value.confirmCallback) {
confirmModal.value.confirmCallback({ confirm: true })
}
confirmModal.value.visible = false
}
//
const onCancelModal = () => {
if (confirmModal.value.confirmCallback) {
confirmModal.value.confirmCallback({ confirm: false })
}
confirmModal.value.visible = false
}
//
const showConfirmModal = (options) => {
confirmModal.value = {
visible: true,
title: options.title || '',
content: options.content || '',
confirmText: options.confirmText || '确认',
cancelText: options.cancelText || '取消',
showCancel: options.showCancel !== false,
confirmCallback: options.success || null
}
}
//
const originalCoords = computed(() => {
@ -354,7 +406,7 @@ const exportConfig = () => {
console.log('}')
}
uni.showModal({
showConfirmModal({
title: '配置已导出',
content: '请查看控制台输出,复制到 config/cabin.js',
showCancel: false
@ -362,7 +414,7 @@ const exportConfig = () => {
}
const resetConfig = () => {
uni.showModal({
showConfirmModal({
title: '确认重置',
content: '将重置所有参数和调整,是否继续?',
success: (res) => {