修复前端登录提示和店铺表单移动端交互

This commit is contained in:
2026-07-01 00:10:14 +08:00
parent a8469d1916
commit a1d81d2dab
4 changed files with 45 additions and 1 deletions
@@ -601,7 +601,7 @@
* ShopsView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, ref, reactive, onMounted } from 'vue'
import { computed, ref, reactive, onBeforeUnmount, onMounted } from 'vue'
import { message } from 'ant-design-vue'
import type { FormInstance, UploadProps } from 'ant-design-vue'
import { PlusOutlined } from '@ant-design/icons-vue'
@@ -2177,6 +2177,21 @@ const handleSaveDraft = () => {
message.success('已暂存到本地')
}
const saveDraftSilently = () => {
if (!modalVisible.value || isUploadPending.value) {
return
}
syncBusinessHoursValue()
const draft = saveDraftRecord(getDraftKey(), buildDraftPayload())
draftSavedAt.value = draft.savedAt
}
const handleDocumentVisibilityChange = () => {
if (document.visibilityState === 'hidden') {
saveDraftSilently()
}
}
/** handleClearDraft is a local helper used by this page script. */
const handleClearDraft = (showMessage = true) => {
clearDraftRecord(getDraftKey())
@@ -2382,10 +2397,15 @@ const handleStatusChange = async (record: Shop | Record<string, any>, enabled: b
}
onMounted(async () => {
document.addEventListener('visibilitychange', handleDocumentVisibilityChange)
loadCustomThemeTemplates()
await loadUserPermissions()
fetchShopList()
})
onBeforeUnmount(() => {
document.removeEventListener('visibilitychange', handleDocumentVisibilityChange)
})
</script>
<style scoped>