导入 AKSRT 主题开发源码
This commit is contained in:
1 parent
9681dd3d48
commit
1268a55dd0
595 files changed
+127705
No files matched your search
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<div class="aksrt-page-container">
|
||||
<PageHeader
|
||||
title="下载/付费内容中心"
|
||||
desc="统一管理资源下载门槛、默认扣费、角色免扣和人工交付说明。运行中的下载 token 流程保持不变。"
|
||||
>
|
||||
<template #actions>
|
||||
<n-space>
|
||||
<n-button quaternary @click="go('/permissions/download')">下载权限</n-button>
|
||||
<n-button quaternary @click="go('/payment/gateway')">收款接口</n-button>
|
||||
</n-space>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<n-spin :show="loading" style="width: 100%; min-height: 200px;">
|
||||
<n-card class="aksrt-section-card">
|
||||
<div class="aksrt-section-header">
|
||||
<h3>当前联动摘要</h3>
|
||||
</div>
|
||||
<n-space>
|
||||
<n-tag round :type="form.download_login ? 'warning' : 'default'">
|
||||
登录门槛:{{ form.download_login ? '已启用' : '已关闭' }}
|
||||
</n-tag>
|
||||
<n-tag round :type="form.download_credit ? 'warning' : 'default'">
|
||||
积分扣费:{{ form.download_credit ? '已启用' : '已关闭' }}
|
||||
</n-tag>
|
||||
<n-tag round :type="form.download_captcha ? 'warning' : 'default'">
|
||||
下载验证码:{{ form.download_captcha ? '已启用' : '已关闭' }}
|
||||
</n-tag>
|
||||
<n-tag round type="info">
|
||||
默认价格:{{ form.download_default_cost }} {{ currencyName }}
|
||||
</n-tag>
|
||||
<n-tag round :type="form.payment_vip_free_download ? 'success' : 'default'">
|
||||
角色免扣:{{ form.payment_vip_free_download ? '已启用' : '未启用' }}
|
||||
</n-tag>
|
||||
<n-tag round type="info">
|
||||
Token TTL:10 分钟
|
||||
</n-tag>
|
||||
</n-space>
|
||||
</n-card>
|
||||
|
||||
<n-card class="aksrt-section-card">
|
||||
<div class="aksrt-section-header">
|
||||
<h3>下载门槛</h3>
|
||||
</div>
|
||||
<n-form :model="form" label-placement="left" label-width="180" class="aksrt-form">
|
||||
<n-form-item label="下载需要登录">
|
||||
<n-switch v-model:value="form.download_login" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="下载启用积分扣费">
|
||||
<n-switch v-model:value="form.download_credit" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="下载启用验证码">
|
||||
<n-switch v-model:value="form.download_captcha" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item :label="`默认资源价格(${currencyName})`">
|
||||
<n-input-number v-model:value="form.download_default_cost" :min="0" :max="100000" style="width: 180px;" />
|
||||
<template #feedback>
|
||||
<span class="aksrt-hint-text">资源未单独设价时回退到这里。角色免扣命中时会直接跳过积分扣费。</span>
|
||||
</template>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-card>
|
||||
|
||||
<n-card class="aksrt-section-card">
|
||||
<div class="aksrt-section-header">
|
||||
<h3>付费内容策略</h3>
|
||||
</div>
|
||||
<n-form :model="form" label-placement="left" label-width="180" class="aksrt-form">
|
||||
<n-form-item label="受管内容类型">
|
||||
<n-input v-model:value="form.payment_paid_post_types" placeholder="post,course,doc" />
|
||||
<template #feedback>
|
||||
<span class="aksrt-hint-text">逗号分隔,标记纳入统一付费策略的内容类型。</span>
|
||||
</template>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="角色白名单免扣下载">
|
||||
<n-switch v-model:value="form.payment_vip_free_download" />
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="免扣角色列表" v-if="form.payment_vip_free_download">
|
||||
<n-input v-model:value="form.payment_vip_exempt_roles" placeholder="administrator,editor,vip" />
|
||||
<template #feedback>
|
||||
<span class="aksrt-hint-text">命中这些 WordPress role 的用户下载资源时将直接跳过积分扣费。</span>
|
||||
</template>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="前台付费提示">
|
||||
<n-input
|
||||
v-model:value="form.payment_paid_catalog_note"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 3, maxRows: 6 }"
|
||||
placeholder="可填写资源购买须知、交付说明或人工确认提示。"
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="人工交付备注">
|
||||
<n-input
|
||||
v-model:value="form.payment_manual_delivery_note"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 3, maxRows: 6 }"
|
||||
/>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-card>
|
||||
|
||||
<n-card class="aksrt-section-card">
|
||||
<n-alert type="info" :show-icon="false">
|
||||
当前收款模式:{{ gatewayModeLabel }}。充值、VIP、返佣和分成页均已提供稳定结构,订单和结算台账直接衔接这些字段。
|
||||
</n-alert>
|
||||
</n-card>
|
||||
|
||||
<div class="aksrt-form-actions">
|
||||
<n-button type="primary" :loading="saving" @click="handleSave">保存配置</n-button>
|
||||
</div>
|
||||
</n-spin>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useMessage } from 'naive-ui'
|
||||
import api from '@/api'
|
||||
import PageHeader from '@/components/PageHeader.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const message = useMessage()
|
||||
|
||||
const loading = ref(true)
|
||||
const saving = ref(false)
|
||||
const featureSnapshot = ref({})
|
||||
const creditSnapshot = ref({})
|
||||
const overview = ref({})
|
||||
|
||||
const form = reactive({
|
||||
download_login: true,
|
||||
download_credit: true,
|
||||
download_captcha: false,
|
||||
download_default_cost: 0,
|
||||
payment_paid_post_types: 'post',
|
||||
payment_vip_free_download: false,
|
||||
payment_vip_exempt_roles: '',
|
||||
payment_paid_catalog_note: '',
|
||||
payment_manual_delivery_note: '付费或人工确认内容请在订单备注中记录交付方式。',
|
||||
})
|
||||
|
||||
const currencyName = computed(() => overview.value.currency_name || creditSnapshot.value.currency_name || '积分')
|
||||
const gatewayModeLabel = computed(() => {
|
||||
const mode = overview.value.gateway?.mode || 'manual_review'
|
||||
if (mode === 'test_gateway') return '测试网关'
|
||||
if (mode === 'adapter_ready') return '适配器就绪'
|
||||
return '人工确认'
|
||||
})
|
||||
|
||||
function go(path) {
|
||||
router.push(path)
|
||||
}
|
||||
|
||||
function extractData(response) {
|
||||
return response?.data ?? response ?? {}
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try {
|
||||
const [featureRes, creditRes, schemaRes, overviewRes] = await Promise.all([
|
||||
api.getCmsFeatures(),
|
||||
api.getCreditSettings(),
|
||||
api.getSchemaPage('payment', 'paid'),
|
||||
api.getPaymentOverview(),
|
||||
])
|
||||
|
||||
const featureData = featureRes?.cms_features ?? featureRes?.data?.cms_features ?? {}
|
||||
const creditData = extractData(creditRes)
|
||||
const schemaData = extractData(schemaRes)
|
||||
|
||||
featureSnapshot.value = featureData
|
||||
creditSnapshot.value = creditData
|
||||
overview.value = extractData(overviewRes)
|
||||
|
||||
form.download_login = featureData.download_login !== false
|
||||
form.download_credit = featureData.download_credit !== false
|
||||
form.download_captcha = !!featureData.download_captcha
|
||||
form.download_default_cost = Number(creditData.download_default_cost || 0)
|
||||
form.payment_paid_post_types = schemaData.payment_paid_post_types || 'post'
|
||||
form.payment_vip_free_download = !!schemaData.payment_vip_free_download
|
||||
form.payment_vip_exempt_roles = schemaData.payment_vip_exempt_roles || ''
|
||||
form.payment_paid_catalog_note = schemaData.payment_paid_catalog_note || ''
|
||||
form.payment_manual_delivery_note = schemaData.payment_manual_delivery_note || '付费或人工确认内容请在订单备注中记录交付方式。'
|
||||
} catch (error) {
|
||||
message.error(error.message || '加载下载/付费内容中心失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSave() {
|
||||
saving.value = true
|
||||
try {
|
||||
const nextFeatures = {
|
||||
...featureSnapshot.value,
|
||||
download_login: form.download_login,
|
||||
download_credit: form.download_credit,
|
||||
download_captcha: form.download_captcha,
|
||||
}
|
||||
const nextCredits = {
|
||||
...creditSnapshot.value,
|
||||
download_default_cost: Number(form.download_default_cost || 0),
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
api.saveCmsFeatures(nextFeatures),
|
||||
api.saveCreditSettings(nextCredits),
|
||||
api.saveSchemaPage('payment', 'paid', {
|
||||
payment_paid_post_types: form.payment_paid_post_types,
|
||||
payment_vip_free_download: form.payment_vip_free_download,
|
||||
payment_vip_exempt_roles: form.payment_vip_exempt_roles,
|
||||
payment_paid_catalog_note: form.payment_paid_catalog_note,
|
||||
payment_manual_delivery_note: form.payment_manual_delivery_note,
|
||||
}),
|
||||
])
|
||||
|
||||
featureSnapshot.value = nextFeatures
|
||||
creditSnapshot.value = nextCredits
|
||||
message.success('下载/付费内容中心已保存')
|
||||
} catch (error) {
|
||||
message.error(error.message || '保存失败')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(load)
|
||||
</script>
|
||||
Reference in new issue
Block a user