增加发布协议确认配置

This commit is contained in:
yml2213
2026-06-07 21:14:49 +08:00
parent 954c3d6be3
commit eebd2d3b04
19 changed files with 760 additions and 13 deletions
@@ -0,0 +1,236 @@
<script setup lang="ts">
import { ElMessage } from 'element-plus'
import { ref, watch } from 'vue'
import { updateSystemConfig, type SystemConfig } from '@/features/admin/api/systemConfigs'
import type { ListingPublishAgreements } from '@/features/listings/api/listingOptions'
import { safeParseJSON } from '@/utils/json'
const defaultListingPublishAgreements: ListingPublishAgreements = {
virtual_asset_sale: {
title: '虚拟资产出售协议',
content: `请您在发布账号前仔细阅读并确认以下内容:
一、发布性质
1. 您发布的账号、哈夫币、皮肤、装备、消耗品等均属于游戏内虚拟资产或使用权益展示。
2. 虚拟资产受游戏厂商规则、版本更新、风控策略和账号状态影响,平台不承诺其具备现实货币价值或永久可用性。
3. 您应确保发布信息真实、完整、可交接,且与截图材料和账号实际资产一致。
二、风险告知
1. 发布账号后,买家下单前后可能因游戏环境变化、资产变动、封禁记录、登录限制等产生交易风险。
2. 若您隐瞒账号异常、资产缺失、封禁记录、不可用物资或其他影响交易的信息,平台可依据证据处理赔付、退款或下架。
3. 请勿绕过平台私下收款、私下交接或诱导用户脱离平台沟通,否则平台可能限制账号发布权限。
三、费用与结算
1. 发布价格、押金、额外消耗品价值以平台发布页和订单页面展示为准。
2. 订单完成后,平台将按订单记录、结账结果和相关规则进行结算。
3. 若发生争议,平台将依据订单记录、资产快照、聊天记录、截图证据和双方说明进行处理。`,
},
seller_agreement: {
title: '号主协议',
content: `请您作为号主在发布账号前确认并遵守以下约定:
一、账号发布义务
1. 您应如实填写区服、段位、哈夫币数量、保险、体力、负重、登录方式、封禁记录、常用地区和备注信息。
2. 您应上传真实、清晰、可核验的账号截图材料,不得使用伪造、过期或与账号不一致的截图。
3. 您不得发布盗号、黑号、纠纷账号、已被限制使用账号或无法完成正常交接的账号。
二、交接与协作
1. 买家下单后,您应在平台要求时间内完成交接,及时响应扫码、人脸冻结、登录验证等流程。
2. 您应在租用期间保持可联系状态,不得无故拒绝交接、恶意拖延或私下更改交易条件。
3. 租用结束后,请按平台流程确认归还和结账,配合核验资产状态。
三、责任承担
1. 因您发布信息不实、交接不及时、账号异常隐瞒或私下交易造成的损失,平台可依据规则处理退款、赔付、下架或限制发布。
2. 因租客违规使用造成的损失,您应通过平台流程提交证据并配合争议处理。
3. 您同意平台依据订单记录、资产快照、聊天记录、截图证据和相关规则处理结算、赔付及争议。`,
},
}
const props = defineProps<{
modelValue: boolean
config: SystemConfig
}>()
const emit = defineEmits<{
(e: 'update:modelValue', val: boolean): void
(e: 'saved'): void
}>()
const submitting = ref(false)
const description = ref('')
const draft = ref<ListingPublishAgreements>(cloneAgreements(defaultListingPublishAgreements))
watch(
() => props.modelValue,
(val) => {
if (val) {
draft.value = parseListingPublishAgreements(props.config.value)
description.value = props.config.description || ''
}
},
{ immediate: true },
)
function parseListingPublishAgreements(raw: string) {
const parsed = safeParseJSON(raw, defaultListingPublishAgreements)
return cloneAgreements({
virtual_asset_sale: {
title: readText(parsed?.virtual_asset_sale?.title, defaultListingPublishAgreements.virtual_asset_sale.title),
content: readText(parsed?.virtual_asset_sale?.content, defaultListingPublishAgreements.virtual_asset_sale.content),
},
seller_agreement: {
title: readText(parsed?.seller_agreement?.title, defaultListingPublishAgreements.seller_agreement.title),
content: readText(parsed?.seller_agreement?.content, defaultListingPublishAgreements.seller_agreement.content),
},
})
}
function readText(value: unknown, fallback: string) {
return typeof value === 'string' && value.trim() ? value : fallback
}
function cloneAgreements(value: ListingPublishAgreements) {
return JSON.parse(JSON.stringify(value)) as ListingPublishAgreements
}
function resetDefaults() {
draft.value = cloneAgreements(defaultListingPublishAgreements)
}
async function handleSave() {
submitting.value = true
try {
await updateSystemConfig(props.config.key, {
value: JSON.stringify(draft.value, null, 2),
description: description.value,
})
ElMessage.success('发布协议配置已更新')
emit('saved')
emit('update:modelValue', false)
} catch (error) {
ElMessage.error(readError(error, '保存失败'))
} finally {
submitting.value = false
}
}
function readError(error: unknown, fallback: string) {
if (typeof error === 'object' && error && 'response' in error) {
const response = (error as { response?: { data?: { message?: string } } }).response
return response?.data?.message || fallback
}
return fallback
}
</script>
<template>
<el-dialog
:model-value="modelValue"
title="编辑发布协议"
width="860px"
@update:model-value="emit('update:modelValue', $event)"
>
<div class="dialog-body">
<div class="dialog-header">
<p class="config-key-label"><strong>{{ config.key }}</strong></p>
<el-button size="small" @click="resetDefaults">恢复默认文本</el-button>
</div>
<div class="agreement-editor-grid">
<section class="agreement-editor-card">
<div class="agreement-card-title">虚拟资产出售协议</div>
<el-form-item label="协议标题" class="full-control">
<el-input v-model="draft.virtual_asset_sale.title" placeholder="请输入协议标题" />
</el-form-item>
<el-form-item label="协议正文" class="full-control">
<el-input
v-model="draft.virtual_asset_sale.content"
type="textarea"
:rows="14"
resize="vertical"
placeholder="请输入协议正文"
/>
</el-form-item>
</section>
<section class="agreement-editor-card">
<div class="agreement-card-title">号主协议</div>
<el-form-item label="协议标题" class="full-control">
<el-input v-model="draft.seller_agreement.title" placeholder="请输入协议标题" />
</el-form-item>
<el-form-item label="协议正文" class="full-control">
<el-input
v-model="draft.seller_agreement.content"
type="textarea"
:rows="14"
resize="vertical"
placeholder="请输入协议正文"
/>
</el-form-item>
</section>
</div>
<el-form-item label="配置说明" class="desc-item">
<el-input v-model="description" type="textarea" :rows="3" placeholder="配置说明" />
</el-form-item>
</div>
<template #footer>
<el-button @click="emit('update:modelValue', false)">取消</el-button>
<el-button type="primary" :loading="submitting" @click="handleSave">保存</el-button>
</template>
</el-dialog>
</template>
<style scoped>
.dialog-body {
display: grid;
gap: 16px;
max-height: 68vh;
overflow-y: auto;
padding-right: 8px;
}
.dialog-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.config-key-label {
margin: 0;
color: #374151;
}
.agreement-editor-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
}
.agreement-editor-card {
display: grid;
gap: 12px;
padding: 14px;
border: 1px solid #e5e7eb;
border-radius: 8px;
background: #f9fafb;
}
.agreement-card-title {
color: #111827;
font-weight: 700;
}
.full-control,
.desc-item {
margin-bottom: 0;
}
@media (max-width: 900px) {
.agreement-editor-grid {
grid-template-columns: 1fr;
}
}
</style>
@@ -7,6 +7,7 @@ import {
mergeListingSalePriceConfig,
mergeListingPublishOptions,
type ListingPublishOptions,
type ListingPublishAgreements,
type PublishSalePriceConfig,
} from '@/features/listings/api/listingOptions'
import {
@@ -26,6 +27,7 @@ import PublishOptionsDialog from '../components/PublishOptionsDialog.vue'
import SalePriceDialog from '../components/SalePriceDialog.vue'
import HomeAnnouncementsDialog from '../components/HomeAnnouncementsDialog.vue'
import HomeBannersDialog from '../components/HomeBannersDialog.vue'
import ListingPublishAgreementsDialog from '../components/ListingPublishAgreementsDialog.vue'
import OrderAgreementsDialog from '../components/OrderAgreementsDialog.vue'
import PostRentalNoticeDialog from '../components/PostRentalNoticeDialog.vue'
import GeneralConfigDialog from '../components/GeneralConfigDialog.vue'
@@ -42,6 +44,17 @@ const defaultOrderAgreements: OrderAgreements = {
},
}
const defaultListingPublishAgreements: ListingPublishAgreements = {
virtual_asset_sale: {
title: '虚拟资产出售协议',
content: '',
},
seller_agreement: {
title: '号主协议',
content: '',
},
}
const loading = ref(false)
const configs = ref<SystemConfig[]>([])
const currentEditingConfig = ref<SystemConfig | null>(null)
@@ -51,6 +64,7 @@ const publishVisible = ref(false)
const salePriceVisible = ref(false)
const announcementsVisible = ref(false)
const bannersVisible = ref(false)
const listingPublishAgreementsVisible = ref(false)
const agreementsVisible = ref(false)
const postRentalNoticeVisible = ref(false)
const generalVisible = ref(false)
@@ -59,6 +73,7 @@ const publishConfig = computed(() => configs.value.find((item) => item.key === '
const salePriceConfig = computed(() => configs.value.find((item) => item.key === 'listing.sale_price_config') || null)
const homeAnnouncementsConfig = computed(() => configs.value.find((item) => item.key === 'mobile.home_announcements') || null)
const homeBannersConfig = computed(() => configs.value.find((item) => item.key === 'mobile.home_banners') || null)
const listingPublishAgreementsConfig = computed(() => configs.value.find((item) => item.key === 'listing.publish_agreements') || null)
const orderAgreementsConfig = computed(() => configs.value.find((item) => item.key === 'order.agreements') || null)
const postRentalNoticeConfig = computed(() => configs.value.find((item) => item.key === 'profile.post_rental_notice') || null)
@@ -69,6 +84,7 @@ const regularConfigs = computed(() =>
item.key !== 'listing.sale_price_config' &&
item.key !== 'mobile.home_announcements' &&
item.key !== 'mobile.home_banners' &&
item.key !== 'listing.publish_agreements' &&
item.key !== 'order.agreements' &&
item.key !== 'profile.post_rental_notice',
),
@@ -117,6 +133,16 @@ const agreementStats = computed(() => {
}
})
const listingPublishAgreementStats = computed(() => {
const agreements = parseListingPublishAgreements(listingPublishAgreementsConfig.value?.value || '')
return {
saleTitle: agreements.virtual_asset_sale.title || '出售协议',
sellerTitle: agreements.seller_agreement.title || '号主协议',
saleWords: countContentWords(agreements.virtual_asset_sale.content),
sellerWords: countContentWords(agreements.seller_agreement.content),
}
})
onMounted(loadConfigs)
async function loadConfigs() {
@@ -138,6 +164,8 @@ function openEdit(row: SystemConfig) {
announcementsVisible.value = true
} else if (row.key === 'mobile.home_banners') {
bannersVisible.value = true
} else if (row.key === 'listing.publish_agreements') {
listingPublishAgreementsVisible.value = true
} else if (row.key === 'order.agreements') {
agreementsVisible.value = true
} else if (row.key === 'profile.post_rental_notice') {
@@ -181,6 +209,20 @@ function parseOrderAgreements(raw: string) {
}
}
function parseListingPublishAgreements(raw: string) {
const parsed = safeParseJSON(raw, defaultListingPublishAgreements)
return {
virtual_asset_sale: {
title: readText(parsed.virtual_asset_sale?.title, defaultListingPublishAgreements.virtual_asset_sale.title),
content: readText(parsed.virtual_asset_sale?.content, defaultListingPublishAgreements.virtual_asset_sale.content),
},
seller_agreement: {
title: readText(parsed.seller_agreement?.title, defaultListingPublishAgreements.seller_agreement.title),
content: readText(parsed.seller_agreement?.content, defaultListingPublishAgreements.seller_agreement.content),
},
}
}
function readText(value: unknown, fallback: string) {
return typeof value === 'string' && value.trim() ? value : fallback
}
@@ -329,6 +371,39 @@ function formatConfigValue(row: SystemConfig) {
</div>
</section>
<section v-if="listingPublishAgreementsConfig" class="publish-config-panel">
<div class="publish-config-main">
<div>
<p class="eyebrow">Publish Agreements</p>
<h2>发布协议配置</h2>
<span>管理发布账号前必须勾选确认的虚拟资产出售协议和号主协议</span>
</div>
<el-button type="primary" @click="openEdit(listingPublishAgreementsConfig)">编辑发布协议</el-button>
</div>
<div class="publish-stat-grid home-stat-grid">
<div class="publish-stat">
<strong>2</strong>
<span>协议数量</span>
</div>
<div class="publish-stat">
<strong>{{ listingPublishAgreementStats.saleWords }}</strong>
<span>{{ listingPublishAgreementStats.saleTitle }}字数</span>
</div>
<div class="publish-stat">
<strong>{{ listingPublishAgreementStats.sellerWords }}</strong>
<span>{{ listingPublishAgreementStats.sellerTitle }}字数</span>
</div>
<div class="publish-stat">
<strong>接口</strong>
<span>/api/listing-publish-agreements</span>
</div>
<div class="publish-stat">
<strong>更新</strong>
<span>{{ formatHomeConfigStatus(listingPublishAgreementsConfig, '未初始化') }}</span>
</div>
</div>
</section>
<section v-if="orderAgreementsConfig" class="publish-config-panel">
<div class="publish-config-main">
<div>
@@ -446,6 +521,13 @@ function formatConfigValue(row: SystemConfig) {
@saved="loadConfigs"
/>
<ListingPublishAgreementsDialog
v-if="listingPublishAgreementsConfig"
v-model="listingPublishAgreementsVisible"
:config="listingPublishAgreementsConfig"
@saved="loadConfigs"
/>
<OrderAgreementsDialog
v-if="orderAgreementsConfig"
v-model="agreementsVisible"