fix(float): use shared sticky save bar and place panel warnings after device tags
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
<template>
|
||||
<div class="aksrt-page-container content-page">
|
||||
<PageHeader title="右侧悬浮按钮" desc="显示在页面右侧的悬浮按钮,支持排序及添加自定义按钮。">
|
||||
<template #actions>
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">保存</n-button>
|
||||
</template>
|
||||
</PageHeader>
|
||||
<PageHeader title="右侧悬浮按钮" desc="显示在页面右侧的悬浮按钮,支持排序及添加自定义按钮。" />
|
||||
|
||||
<n-spin :show="loading" style="width: 100%; min-height: 200px;">
|
||||
<n-alert type="warning" :bordered="false" class="float-settings__notice">
|
||||
@@ -67,20 +63,19 @@
|
||||
</draggable>
|
||||
</div>
|
||||
</n-card>
|
||||
|
||||
<div class="aksrt-form-actions">
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">保存悬浮按钮配置</n-button>
|
||||
</div>
|
||||
</n-spin>
|
||||
|
||||
<AksSaveBar :dirty="dirty" :saving="saving" @save="handleSave" @reload="loadSettings" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useMessage } from 'naive-ui'
|
||||
import draggable from 'vuedraggable'
|
||||
import api from '@/api'
|
||||
import PageHeader from '@/components/PageHeader.vue'
|
||||
import AksSaveBar from '@/components/form/AksSaveBar.vue'
|
||||
import FloatBtnItemPanel from '@/components/floating/FloatBtnItemPanel.vue'
|
||||
import { defaultSettings, normalizeItems } from '@/components/floating/floating-defaults.js'
|
||||
|
||||
@@ -89,6 +84,14 @@ const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
const form = reactive(defaultSettings())
|
||||
|
||||
// 与全局保存栏一致:仅在有未保存更改时显示。以最近一次加载/保存的快照为基准。
|
||||
const snapshot = ref('')
|
||||
const serialize = () => JSON.stringify(form)
|
||||
const dirty = computed(() => !loading.value && snapshot.value !== '' && serialize() !== snapshot.value)
|
||||
function markClean() {
|
||||
snapshot.value = serialize()
|
||||
}
|
||||
|
||||
function updateItem(index, value) {
|
||||
form.items.splice(index, 1, value)
|
||||
}
|
||||
@@ -108,6 +111,7 @@ async function loadSettings() {
|
||||
try {
|
||||
const res = await api.getFloatingButtons()
|
||||
if (res.code === 'success') applySettings(res.data)
|
||||
markClean()
|
||||
} catch (error) {
|
||||
console.error('[FloatingButtons] load failed:', error)
|
||||
message.error('加载配置失败')
|
||||
@@ -129,6 +133,7 @@ async function handleSave() {
|
||||
})
|
||||
if (res.code === 'success') {
|
||||
if (res.data) applySettings(res.data)
|
||||
markClean()
|
||||
message.success(res.message || '保存成功')
|
||||
} else {
|
||||
message.error(res.message || '保存失败')
|
||||
|
||||
Reference in New Issue
Block a user