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

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> <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('保存失败,请重试')