feat(user): add local avatar management flow
This commit is contained in:
@@ -85,22 +85,6 @@
|
||||
</n-form>
|
||||
</n-card>
|
||||
|
||||
<!-- 4. 头像 -->
|
||||
<n-card class="aksrt-section-card">
|
||||
<div class="aksrt-section-header">
|
||||
<span class="section-icon"><svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg></span>
|
||||
<h3>Gravatar 头像源</h3>
|
||||
</div>
|
||||
<n-form :model="basic" label-placement="left" label-width="130" class="aksrt-form">
|
||||
<n-form-item label="头像服务源">
|
||||
<n-select v-model:value="basic.avatar_source" :options="avatarSourceOptions" placeholder="选择头像镜像源" />
|
||||
<template #feedback>
|
||||
<span class="aksrt-hint-text">国内站点建议优先选 Cravatar。</span>
|
||||
</template>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-card>
|
||||
|
||||
<!-- 5. 备案 -->
|
||||
<n-card class="aksrt-section-card">
|
||||
<div class="aksrt-section-header">
|
||||
@@ -140,7 +124,6 @@ const saving = ref(false)
|
||||
const basic = reactive({
|
||||
comment_enabled: true,
|
||||
comment_requires_registration: false,
|
||||
avatar_source: 'cn.cravatar.com',
|
||||
icp_number: '',
|
||||
police_number: '',
|
||||
lazyload_enabled: true,
|
||||
@@ -149,12 +132,6 @@ const basic = reactive({
|
||||
comment_pagination_mode: 'numbered',
|
||||
})
|
||||
|
||||
const avatarSourceOptions = [
|
||||
{ label: 'Cravatar (国内推荐)', value: 'cn.cravatar.com' },
|
||||
{ label: 'Gravatar 国内镜像', value: 'cn.gravatar.com' },
|
||||
{ label: 'Gravatar 官方', value: 'gravatar.com' },
|
||||
]
|
||||
|
||||
async function loadAll() {
|
||||
loading.value = true
|
||||
try {
|
||||
@@ -163,7 +140,6 @@ async function loadAll() {
|
||||
const d = basicRes.data
|
||||
basic.comment_enabled = d.comment_enabled !== false
|
||||
basic.comment_requires_registration = !!d.comment_requires_registration
|
||||
basic.avatar_source = d.avatar_source || 'cn.cravatar.com'
|
||||
basic.icp_number = d.icp_number || ''
|
||||
basic.police_number = d.police_number || ''
|
||||
basic.lazyload_enabled = d.lazyload_enabled !== false
|
||||
@@ -184,7 +160,6 @@ async function handleSave() {
|
||||
const basicPayload = {
|
||||
comment_enabled: basic.comment_enabled,
|
||||
comment_requires_registration: basic.comment_requires_registration,
|
||||
avatar_source: basic.avatar_source,
|
||||
icp_number: basic.icp_number,
|
||||
police_number: basic.police_number,
|
||||
lazyload_enabled: basic.lazyload_enabled,
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<n-form-item label="允许用户上传头像">
|
||||
<n-switch v-model:value="form.allow_avatar_upload" />
|
||||
<template #feedback>
|
||||
<span class="aksrt-hint-text">关闭后用户只能使用 Gravatar/Cravatar 自动头像。</span>
|
||||
<span class="aksrt-hint-text">关闭后用户使用项目内置默认头像,且不能自行更换。</span>
|
||||
</template>
|
||||
</n-form-item>
|
||||
|
||||
|
||||
@@ -65,13 +65,6 @@
|
||||
<h3>公开资料编辑位</h3>
|
||||
</div>
|
||||
<n-form :model="form" label-placement="left" label-width="170" class="aksrt-form">
|
||||
<n-form-item label="头像编辑入口">
|
||||
<n-switch v-model:value="form.user_avatar_upload" />
|
||||
<template #feedback>
|
||||
<span class="aksrt-hint-text">开启后,用户中心会显示跳转到 WordPress 原生资料页的头像修改入口。</span>
|
||||
</template>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="背景图编辑位">
|
||||
<n-switch v-model:value="form.user_cover_upload" />
|
||||
<template #feedback>
|
||||
@@ -121,7 +114,6 @@ const homeSummary = reactive({
|
||||
|
||||
const form = reactive({
|
||||
dynamicTabs: ['posts', 'comments', 'favorites'],
|
||||
user_avatar_upload: true,
|
||||
user_cover_upload: true,
|
||||
user_social_links: true,
|
||||
})
|
||||
@@ -160,7 +152,6 @@ async function load() {
|
||||
const permissionData = extractData(permissionRes)
|
||||
|
||||
form.dynamicTabs = parseTabs(featureData.user_center_tabs || 'profile,posts,comments,favorites')
|
||||
form.user_avatar_upload = featureData.user_avatar_upload !== false
|
||||
form.user_cover_upload = featureData.user_cover_upload !== false
|
||||
form.user_social_links = featureData.user_social_links !== false
|
||||
|
||||
@@ -179,7 +170,6 @@ async function handleSave() {
|
||||
try {
|
||||
await api.saveSchemaPage('users', 'features', {
|
||||
user_center_tabs: ['profile', ...form.dynamicTabs].join(','),
|
||||
user_avatar_upload: form.user_avatar_upload,
|
||||
user_cover_upload: form.user_cover_upload,
|
||||
user_social_links: form.user_social_links,
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@ export const commonSchema = {
|
||||
key: 'global.common',
|
||||
title: '常用功能',
|
||||
icon: 'fas fa-cog',
|
||||
description: '管理站点常用开关、懒加载、头像源与备案信息等基础配置。',
|
||||
description: '管理站点常用开关、懒加载与备案信息等基础配置。',
|
||||
defaults: {
|
||||
comment_enabled: true,
|
||||
lazyload_enabled: true,
|
||||
@@ -17,7 +17,6 @@ export const commonSchema = {
|
||||
lazyload_cover: true,
|
||||
lazyload_other: true,
|
||||
lazyload_widget: true,
|
||||
avatar_source: 'cn.cravatar.com',
|
||||
icp_filing: '',
|
||||
footer_text: '',
|
||||
},
|
||||
@@ -67,25 +66,6 @@ export const commonSchema = {
|
||||
{ key: 'lazyload_widget', label: '小工具图片懒加载', type: 'switch', default: true, dependsOn: { key: 'lazyload_enabled', value: true } },
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'avatar',
|
||||
title: '头像服务',
|
||||
icon: 'fas fa-user-circle',
|
||||
fields: [
|
||||
{
|
||||
key: 'avatar_source',
|
||||
label: '头像源',
|
||||
type: 'select',
|
||||
default: 'cn.cravatar.com',
|
||||
options: [
|
||||
{ label: 'Cravatar (推荐)', value: 'cn.cravatar.com' },
|
||||
{ label: 'Gravatar 中国', value: 'cn.gravatar.com' },
|
||||
{ label: 'Gravatar 国际', value: 'gravatar.com' },
|
||||
],
|
||||
help: 'Cravatar 是国内最快的头像服务,推荐使用',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'filing',
|
||||
title: '备案信息',
|
||||
|
||||
@@ -5,14 +5,12 @@ export const featuresSchema = {
|
||||
description: '配置用户中心和个人主页的功能模块。',
|
||||
defaults: {
|
||||
user_center_tabs: 'profile,posts,comments,favorites,vip,credits,auth',
|
||||
user_avatar_upload: true,
|
||||
user_cover_upload: true,
|
||||
user_social_links: true,
|
||||
user_desc_std: '这家伙很懒…',
|
||||
user_city_s: true,
|
||||
user_city_type: 'province',
|
||||
user_join_day_my_name: '本站',
|
||||
user_avatar_default: '',
|
||||
user_cover_img: '',
|
||||
user_rewrite_slug: 'user',
|
||||
user_follow_s: true,
|
||||
@@ -27,7 +25,6 @@ export const featuresSchema = {
|
||||
icon: 'fas fa-user-shield',
|
||||
fields: [
|
||||
{ key: 'user_center_tabs', label: '用户中心 Tab', type: 'input', default: 'profile,posts,comments,favorites,vip,credits,auth', help: '逗号分隔。auth=官方认证;vip、订单和认证会按功能开关自动注入' },
|
||||
{ key: 'user_avatar_upload', label: '头像上传', type: 'switch', default: true },
|
||||
{ key: 'user_cover_upload', label: '封面上传', type: 'switch', default: true },
|
||||
{ key: 'user_social_links', label: '社交链接', type: 'switch', default: true },
|
||||
{ key: 'user_desc_std', label: '默认签名', type: 'input', default: '这家伙很懒…', help: '用户未设置个人简介时显示的默认文案' },
|
||||
@@ -45,7 +42,6 @@ export const featuresSchema = {
|
||||
dependsOn: { key: 'user_city_s', value: true },
|
||||
},
|
||||
{ key: 'user_join_day_my_name', label: '站名', type: 'input', default: '本站', help: '用于「已加入 X 天」显示中的站点名称' },
|
||||
{ key: 'user_avatar_default', label: '默认头像', type: 'media', default: '' },
|
||||
{ key: 'user_cover_img', label: '默认封面', type: 'media', default: '' },
|
||||
{ key: 'user_rewrite_slug', label: '用户页 slug', type: 'input', default: 'user' },
|
||||
{ key: 'user_follow_s', label: '启用关注功能', type: 'switch', default: true },
|
||||
|
||||
Reference in New Issue
Block a user