feat(admin): 添加域名白名单功能并支持Artalk导入

- 在评论设置中添加域名白名单配置,限制组件调用
- 支持从Artalk系统导入评论数据
- 完善Twikoo和Artalk数据结构的映射处理
- 在组件端实现域名白名单检查逻辑
This commit is contained in:
anghunk
2026-01-20 14:58:27 +08:00
parent 976a38c5f3
commit 05b9425245
6 changed files with 119 additions and 15 deletions

View File

@@ -31,6 +31,15 @@
<label class="form-label">头像前缀默认https://gravatar.com/avatar</label>
<input v-model="avatarPrefix" class="form-input" type="text" />
</div>
<div class="form-item">
<label class="form-label">允许调用的域名多个域名用逗号分隔留空则不限制</label>
<textarea
v-model="allowedDomains"
class="form-input"
rows="3"
placeholder="例如: example.com, test.com"
></textarea>
</div>
<div class="card-actions">
<button class="card-button" :disabled="savingComment" @click="saveComment">
<span v-if="savingComment">保存中...</span>
@@ -134,6 +143,7 @@ const commentAdminEmail = ref("");
const commentAdminBadge = ref("");
const avatarPrefix = ref("");
const commentAdminEnabled = ref(false);
const allowedDomains = ref("");
const savingEmail = ref(false);
const testingEmail = ref(false);
const savingComment = ref(false);
@@ -181,6 +191,7 @@ async function load() {
commentAdminBadge.value = commentRes.adminBadge || "博主";
avatarPrefix.value = commentRes.avatarPrefix || "";
commentAdminEnabled.value = !!commentRes.adminEnabled;
allowedDomains.value = commentRes.allowedDomains ? commentRes.allowedDomains.join(", ") : "";
emailGlobalEnabled.value = !!emailNotifyRes.globalEnabled;
if (emailNotifyRes.smtp) {
@@ -287,6 +298,7 @@ async function saveComment() {
adminBadge: commentAdminBadge.value,
avatarPrefix: avatarPrefix.value,
adminEnabled: commentAdminEnabled.value,
allowedDomains: allowedDomains.value.split(/[,\n]/).map(d => d.trim()).filter(Boolean)
});
showToast(res.message || "保存成功", "success");
} catch (e: any) {