generated from Leo_Ding/web-template
即将修改网站-联系我们-混乱中
This commit is contained in:
parent
6fe815b8d9
commit
3205a92d0f
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<x-search-bar class="mb-8-2">
|
<x-search-bar class="mb-8-2">
|
||||||
<template #default="{ gutter, colSpan }">
|
<template #default="{ gutter, colSpan }">
|
||||||
<x-editor placeholder="请输入声明内容" v-model:value="searchFormData.affirm"></x-editor>
|
<x-editor :modelValue="affirm" @update:modelValue="affirm = $event" placeholder="请输入声明内容"></x-editor>
|
||||||
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
||||||
</template>
|
</template>
|
||||||
</x-search-bar>
|
</x-search-bar>
|
||||||
@ -13,13 +13,15 @@ import { ref } from 'vue'
|
|||||||
import apis from '@/apis' // 假设这里包含 saveAffirm 接口
|
import apis from '@/apis' // 假设这里包含 saveAffirm 接口
|
||||||
import { usePagination } from '@/hooks'
|
import { usePagination } from '@/hooks'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { getWebData,updateWebData } from '@/apis/modules/webSite' // 获取声明接口
|
import { getWebData,updateWebData} from '@/apis/modules/webSite' // 获取声明接口
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'friendlyLinks',
|
name: 'friendlyLinks',
|
||||||
})
|
})
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const { showLoading, hideLoading, searchFormData } = usePagination()
|
const { showLoading, hideLoading} = usePagination()
|
||||||
searchFormData.affirm = '' // 初始化声明内容
|
let affirm = null // 初始化声明内容
|
||||||
|
let id = null // 初始化声明内容
|
||||||
|
|
||||||
// 页面加载时获取声明内容
|
// 页面加载时获取声明内容
|
||||||
getPageList()
|
getPageList()
|
||||||
@ -31,8 +33,11 @@ async function getPageList() {
|
|||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
const res = await getWebData() // 假设返回格式为 { data: { affirm: '内容' } }
|
const res = await getWebData() // 假设返回格式为 { data: { affirm: '内容' } }
|
||||||
if (res?.data?.affirm) {
|
if (res?.data) {
|
||||||
searchFormData.affirm = res.data.affirm
|
affirm = res.data.affirm
|
||||||
|
id = res.data.id // 新增
|
||||||
|
//console.log(affirm)
|
||||||
|
//console.log(id)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error('获取声明内容失败')
|
message.error('获取声明内容失败')
|
||||||
@ -41,19 +46,22 @@ async function getPageList() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isEmptyRichText(html) {
|
||||||
|
return !html || html.replace(/<[^>]+>/g, '').trim() === ''
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交声明内容
|
* 提交声明内容
|
||||||
*/
|
*/
|
||||||
async function handleSearch() {
|
async function handleSearch() {
|
||||||
if (!searchFormData.affirm?.trim()) {
|
console.log('affirm:', affirm)
|
||||||
|
if (isEmptyRichText(affirm)) {
|
||||||
message.warning('请输入声明内容')
|
message.warning('请输入声明内容')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
await apis.updateWebData({ affirm: searchFormData.affirm }) // 假设这是你的保存接口
|
await apis.updateWebData(id, { affirm: affirm })
|
||||||
|
|
||||||
message.success('保存成功')
|
message.success('保存成功')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error('保存失败,请重试')
|
message.error('保存失败,请重试')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user