即将修改网站-联系我们-混乱中

This commit is contained in:
qingyu 2025-06-23 13:42:37 +08:00
parent 6fe815b8d9
commit 3205a92d0f

View File

@ -1,7 +1,7 @@
<template>
<x-search-bar class="mb-8-2">
<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>
</template>
</x-search-bar>
@ -13,13 +13,15 @@ import { ref } from 'vue'
import apis from '@/apis' // saveAffirm
import { usePagination } from '@/hooks'
import { useI18n } from 'vue-i18n'
import { getWebData,updateWebData } from '@/apis/modules/webSite' //
import { getWebData,updateWebData} from '@/apis/modules/webSite' //
defineOptions({
name: 'friendlyLinks',
})
const { t } = useI18n()
const { showLoading, hideLoading, searchFormData } = usePagination()
searchFormData.affirm = '' //
const { showLoading, hideLoading} = usePagination()
let affirm = null //
let id = null //
//
getPageList()
@ -31,8 +33,11 @@ async function getPageList() {
try {
showLoading()
const res = await getWebData() // { data: { affirm: '' } }
if (res?.data?.affirm) {
searchFormData.affirm = res.data.affirm
if (res?.data) {
affirm = res.data.affirm
id = res.data.id //
//console.log(affirm)
//console.log(id)
}
} catch (e) {
message.error('获取声明内容失败')
@ -41,19 +46,22 @@ async function getPageList() {
}
}
function isEmptyRichText(html) {
return !html || html.replace(/<[^>]+>/g, '').trim() === ''
}
/**
* 提交声明内容
*/
async function handleSearch() {
if (!searchFormData.affirm?.trim()) {
console.log('affirm:', affirm)
if (isEmptyRichText(affirm)) {
message.warning('请输入声明内容')
return
}
try {
showLoading()
await apis.updateWebData({ affirm: searchFormData.affirm }) //
await apis.updateWebData(id, { affirm: affirm })
message.success('保存成功')
} catch (e) {
message.error('保存失败,请重试')