增加主题及企微
This commit is contained in:
1 parent
42e29fd747
commit
20271ada61
35 files changed
+2424
-523
No files matched your search
@@ -13,6 +13,7 @@ import { ref, onMounted, watch, computed } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { config } from '../config';
|
||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
||||
import { loadReportLayoutPref, saveReportLayoutPref } from '../composables/useReportLayoutStorage';
|
||||
import {
|
||||
ArrowLeft,
|
||||
@@ -34,7 +35,10 @@ import {
|
||||
Building,
|
||||
MessageCircleQuestion,
|
||||
Settings2,
|
||||
Megaphone
|
||||
Megaphone,
|
||||
Link2,
|
||||
Unlink2,
|
||||
RefreshCw
|
||||
} from 'lucide-vue-next';
|
||||
import * as XLSX from 'xlsx';
|
||||
|
||||
@@ -49,6 +53,7 @@ const sidebarItems = computed(() => {
|
||||
{ id: 'agents', icon: Bot, label: t('admin.nav.agents') },
|
||||
{ id: 'announcements', icon: Megaphone, label: t('admin.nav.announcements') },
|
||||
{ id: 'questions', icon: MessageCircleQuestion, label: t('admin.nav.questions') },
|
||||
{ id: 'wecom', icon: Link2, label: t('admin.nav.wecom') },
|
||||
{ id: 'permissions', icon: Users, label: t('admin.nav.permissions') },
|
||||
{ id: 'requests', icon: ShieldCheck, label: t('admin.nav.requests'), badge: permissionRequests.value.filter(r => r.status === 'pending').length },
|
||||
{ id: 'reports', icon: BarChart2, label: t('admin.nav.reports') },
|
||||
@@ -130,11 +135,36 @@ interface FeedbackReport {
|
||||
distribution: { score: number; count: number }[];
|
||||
}
|
||||
|
||||
interface WecomBindingRow {
|
||||
id: number;
|
||||
username: string;
|
||||
real_name?: string;
|
||||
email: string;
|
||||
role: string;
|
||||
status: string;
|
||||
wecom_userid?: string | null;
|
||||
wecom_unionid?: string | null;
|
||||
bound: boolean;
|
||||
}
|
||||
|
||||
interface LoginAuditRow {
|
||||
id: number;
|
||||
user_id?: number | null;
|
||||
username?: string | null;
|
||||
source: string;
|
||||
status: string;
|
||||
reason?: string | null;
|
||||
wecom_userid?: string | null;
|
||||
ip?: string | null;
|
||||
user_agent?: string | null;
|
||||
created_at?: string | null;
|
||||
}
|
||||
|
||||
// 获取路由实例,用于页面跳转
|
||||
const router = useRouter();
|
||||
|
||||
// 当前左侧菜单激活的模块:dashboard / agents / permissions
|
||||
const activeModule = ref<'dashboard' | 'agents' | 'announcements' | 'permissions' | 'requests' | 'reports' | 'approvals' | 'users' | 'departments' | 'questions'>('dashboard');
|
||||
const activeModule = ref<'dashboard' | 'agents' | 'announcements' | 'permissions' | 'requests' | 'reports' | 'approvals' | 'users' | 'departments' | 'questions' | 'wecom'>('dashboard');
|
||||
const expandedReports = ref(true);
|
||||
|
||||
// agents:管理员视角下的所有 Agent 列表
|
||||
@@ -276,6 +306,17 @@ const saveUser = async () => {
|
||||
const permissionRequests = ref<PermissionRequestRow[]>([]);
|
||||
const usageReport = ref<UsageReport | null>(null);
|
||||
const feedbackReport = ref<FeedbackReport | null>(null);
|
||||
const wecomBindings = ref<WecomBindingRow[]>([]);
|
||||
const wecomLoginAudits = ref<LoginAuditRow[]>([]);
|
||||
const wecomBindForm = ref({
|
||||
user_id: '' as string | number,
|
||||
wecom_userid: '',
|
||||
wecom_unionid: '',
|
||||
});
|
||||
const wecomBoundOnly = ref(false);
|
||||
const wecomAuditSourceFilter = ref<'all' | 'wecom' | 'password'>('all');
|
||||
const wecomAuditStatusFilter = ref<'all' | 'success' | 'failed'>('all');
|
||||
const filteredWecomLoginAudits = computed(() => wecomLoginAudits.value);
|
||||
|
||||
// Batch Operation Refs
|
||||
const selectedUserIds = ref<number[]>([]);
|
||||
@@ -680,6 +721,116 @@ const loadReports = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const loadWecomBindings = async () => {
|
||||
try {
|
||||
const boundOnly = wecomBoundOnly.value ? 'true' : 'false';
|
||||
const res = await fetch(`/api/admin/wecom/bindings?bound_only=${boundOnly}`, { headers: getAuthHeaders() });
|
||||
if (res.ok) {
|
||||
wecomBindings.value = await res.json();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error loading WeCom bindings:', e);
|
||||
}
|
||||
};
|
||||
|
||||
const loadWecomAudits = async () => {
|
||||
try {
|
||||
const params = new URLSearchParams({ limit: '200' });
|
||||
if (wecomAuditSourceFilter.value !== 'all') {
|
||||
params.set('source', wecomAuditSourceFilter.value);
|
||||
}
|
||||
if (wecomAuditStatusFilter.value !== 'all') {
|
||||
params.set('status', wecomAuditStatusFilter.value);
|
||||
}
|
||||
const res = await fetch(`/api/admin/wecom/login-audits?${params.toString()}`, { headers: getAuthHeaders() });
|
||||
if (res.ok) {
|
||||
wecomLoginAudits.value = await res.json();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error loading WeCom login audits:', e);
|
||||
}
|
||||
};
|
||||
|
||||
const refreshWecomData = async () => {
|
||||
await Promise.all([loadWecomBindings(), loadWecomAudits()]);
|
||||
};
|
||||
|
||||
const bindWecomUser = async () => {
|
||||
if (!wecomBindForm.value.user_id || !wecomBindForm.value.wecom_userid.trim()) {
|
||||
alert(t('admin.wecom.msg.bindInputRequired'));
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
const res = await fetch('/api/admin/wecom/bind', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify({
|
||||
user_id: Number(wecomBindForm.value.user_id),
|
||||
wecom_userid: wecomBindForm.value.wecom_userid.trim(),
|
||||
wecom_unionid: wecomBindForm.value.wecom_unionid.trim() || undefined,
|
||||
}),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.error || t('admin.wecom.msg.bindFailed'));
|
||||
wecomBindForm.value.wecom_userid = '';
|
||||
wecomBindForm.value.wecom_unionid = '';
|
||||
await refreshWecomData();
|
||||
alert(t('admin.wecom.msg.bindSuccess'));
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
const errorMessage = e?.message || t('admin.wecom.msg.bindFailed');
|
||||
if (String(errorMessage).includes('already bound to user')) {
|
||||
alert(t('admin.wecom.msg.boundConflict', { detail: errorMessage }));
|
||||
} else {
|
||||
alert(errorMessage);
|
||||
}
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const unbindWecomUserByAdmin = async (userId: number) => {
|
||||
if (!confirm(t('admin.wecom.confirmUnbind'))) return;
|
||||
isSaving.value = true;
|
||||
try {
|
||||
const res = await fetch('/api/admin/wecom/unbind', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify({ user_id: userId }),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.error || t('admin.wecom.msg.unbindFailed'));
|
||||
await refreshWecomData();
|
||||
} catch (e: any) {
|
||||
console.error(e);
|
||||
alert(e.message || t('admin.wecom.msg.unbindFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const exportWecomAudits = () => {
|
||||
if (filteredWecomLoginAudits.value.length === 0) {
|
||||
alert(t('admin.wecom.noAuditData'));
|
||||
return;
|
||||
}
|
||||
const rows = filteredWecomLoginAudits.value.map((row) => ({
|
||||
Time: row.created_at || '',
|
||||
Source: row.source || '',
|
||||
Username: row.username || '',
|
||||
Status: row.status || '',
|
||||
Reason: row.reason || '',
|
||||
IP: row.ip || '',
|
||||
WecomUserId: row.wecom_userid || '',
|
||||
UserAgent: row.user_agent || '',
|
||||
}));
|
||||
const ws = XLSX.utils.json_to_sheet(rows);
|
||||
const wb = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(wb, ws, 'wecom_login_audits');
|
||||
XLSX.writeFile(wb, `wecom_login_audits_${new Date().toISOString().split('T')[0]}.xlsx`);
|
||||
};
|
||||
|
||||
// Quick Questions Logic
|
||||
interface QuickQuestion {
|
||||
id: number;
|
||||
@@ -850,7 +1001,9 @@ onMounted(async () => {
|
||||
loadPermissionRequests(),
|
||||
loadDepartments(),
|
||||
loadAnnouncementsAdmin(),
|
||||
loadQuickQuestions()
|
||||
loadQuickQuestions(),
|
||||
loadWecomBindings(),
|
||||
loadWecomAudits()
|
||||
]);
|
||||
isLoading.value = false;
|
||||
});
|
||||
@@ -871,6 +1024,9 @@ watch(activeModule, async (value) => {
|
||||
if (value === 'departments') {
|
||||
await loadDepartments();
|
||||
}
|
||||
if (value === 'wecom') {
|
||||
await refreshWecomData();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -1582,6 +1738,18 @@ watch(columnFilters, () => {
|
||||
reportCurrentPage.value = 1;
|
||||
}, { deep: true });
|
||||
|
||||
watch(wecomBoundOnly, async () => {
|
||||
if (activeModule.value === 'wecom') {
|
||||
await loadWecomBindings();
|
||||
}
|
||||
});
|
||||
|
||||
watch([wecomAuditSourceFilter, wecomAuditStatusFilter], async () => {
|
||||
if (activeModule.value === 'wecom') {
|
||||
await loadWecomAudits();
|
||||
}
|
||||
});
|
||||
|
||||
watch([reportPageSize, sortedTableData], () => {
|
||||
if (reportCurrentPage.value > reportTotalPages.value) {
|
||||
reportCurrentPage.value = reportTotalPages.value;
|
||||
@@ -1751,20 +1919,20 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-screen bg-gray-50 font-sans text-slate-800 flex flex-col">
|
||||
<div class="min-h-screen bg-gray-50 dark:bg-slate-950 font-sans text-slate-800 dark:text-slate-200 flex flex-col">
|
||||
<!-- Header -->
|
||||
<header class="bg-white/80 backdrop-blur-md border-b border-slate-200 px-6 py-4 flex items-center justify-between sticky top-0 z-30 shadow-sm">
|
||||
<header class="bg-white/80 dark:bg-slate-900/80 backdrop-blur-md border-b border-slate-200 dark:border-slate-700 px-6 py-4 flex items-center justify-between sticky top-0 z-30 shadow-sm">
|
||||
<div class="flex items-center gap-4">
|
||||
<button
|
||||
@click="toggleSidebar"
|
||||
class="p-2 hover:bg-slate-100 rounded-xl transition-colors text-slate-500 hover:text-slate-900 md:block hidden"
|
||||
class="p-2 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-xl transition-colors text-slate-500 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100 md:block hidden"
|
||||
title="Toggle Sidebar"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><path d="M9 3v18"/></svg>
|
||||
</button>
|
||||
<button
|
||||
@click="router.push('/workspace')"
|
||||
class="p-2 hover:bg-slate-100 rounded-xl transition-colors text-slate-500 hover:text-slate-900"
|
||||
class="p-2 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-xl transition-colors text-slate-500 dark:text-slate-300 hover:text-slate-900 dark:hover:text-slate-100"
|
||||
title="Back to Workspace"
|
||||
>
|
||||
<ArrowLeft class="w-6 h-6" />
|
||||
@@ -1773,16 +1941,17 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<h1 class="text-xl md:text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-brand-600 to-indigo-600 tracking-tight">
|
||||
{{ t('admin.title') }}
|
||||
</h1>
|
||||
<span class="text-xs text-slate-400 font-medium tracking-wide">{{ t('admin.subtitle') }}</span>
|
||||
<span class="text-xs text-slate-400 dark:text-slate-500 font-medium tracking-wide">{{ t('admin.subtitle') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<ThemeToggleButton />
|
||||
<!-- Language Selector -->
|
||||
<div class="flex items-center gap-2">
|
||||
<Globe class="w-4 h-4 text-slate-400" />
|
||||
<Globe class="w-4 h-4 text-slate-400 dark:text-slate-500" />
|
||||
<select
|
||||
v-model="locale"
|
||||
class="bg-transparent border-none text-sm font-medium text-slate-600 focus:ring-0 cursor-pointer hover:text-brand-600 transition-colors"
|
||||
class="bg-transparent border-none text-sm font-medium text-slate-600 dark:text-slate-300 focus:ring-0 cursor-pointer hover:text-brand-600 transition-colors"
|
||||
>
|
||||
<option value="en">English</option>
|
||||
<option value="zh-CN">简体中文</option>
|
||||
@@ -1793,7 +1962,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
|
||||
<button
|
||||
@click="saveConfig"
|
||||
class="hidden md:flex items-center gap-2 px-5 py-2.5 bg-slate-900 text-white rounded-xl hover:bg-slate-800 transition-all shadow-lg shadow-slate-200 active:scale-95"
|
||||
class="hidden md:flex items-center gap-2 px-5 py-2.5 bg-slate-900 dark:bg-slate-700 text-white rounded-xl hover:bg-slate-800 dark:hover:bg-slate-600 transition-all shadow-lg shadow-slate-200 active:scale-95"
|
||||
>
|
||||
<Save class="w-4 h-4" />
|
||||
<span class="font-medium text-sm">{{ t('admin.save') }}</span>
|
||||
@@ -1804,7 +1973,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<main class="flex-1 w-full mx-auto px-4 md:px-8 py-6 md:py-8 flex flex-col md:flex-row gap-8 items-start">
|
||||
<!-- Sidebar Navigation -->
|
||||
<aside
|
||||
class="bg-white border border-slate-200 rounded-2xl shadow-sm h-fit md:sticky md:top-24 overflow-hidden shrink-0 z-10 transition-all duration-300"
|
||||
class="bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-700 rounded-2xl shadow-sm h-fit md:sticky md:top-24 overflow-hidden shrink-0 z-10 transition-all duration-300"
|
||||
:class="isSidebarCollapsed ? 'w-0 md:w-20' : 'w-full md:w-64'"
|
||||
>
|
||||
<nav class="flex md:flex-col p-3 gap-1 overflow-x-auto md:overflow-visible no-scrollbar">
|
||||
@@ -1812,11 +1981,11 @@ const handlePermissionImport = async (event: Event) => {
|
||||
v-for="item in sidebarItems"
|
||||
:key="item.id"
|
||||
class="group px-4 py-3 text-left text-sm font-medium rounded-xl transition-all flex items-center gap-3 relative overflow-hidden whitespace-nowrap flex-shrink-0"
|
||||
:class="activeModule === item.id ? 'bg-brand-50 text-brand-700' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900'"
|
||||
:class="activeModule === item.id ? 'bg-brand-50 text-brand-700' : 'text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-slate-100'"
|
||||
@click="activeModule = item.id as any; activeReportTabId = null"
|
||||
:title="isSidebarCollapsed ? item.label : ''"
|
||||
>
|
||||
<component :is="item.icon" class="w-5 h-5 transition-transform group-hover:scale-110 flex-shrink-0" :class="activeModule === item.id ? 'text-brand-600' : 'text-slate-400 group-hover:text-slate-600'" />
|
||||
<component :is="item.icon" class="w-5 h-5 transition-transform group-hover:scale-110 flex-shrink-0" :class="activeModule === item.id ? 'text-brand-600' : 'text-slate-400 dark:text-slate-500 group-hover:text-slate-600 dark:group-hover:text-slate-300'" />
|
||||
<span :class="isSidebarCollapsed ? 'md:hidden' : ''">{{ item.label }}</span>
|
||||
<span v-if="item.badge && !isSidebarCollapsed" class="ml-auto bg-red-500 text-white text-[10px] font-bold px-2 py-0.5 rounded-full shadow-sm">
|
||||
{{ item.badge }}
|
||||
@@ -1829,25 +1998,25 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<div v-if="config.admin.modules.reports !== false" class="flex flex-col flex-shrink-0">
|
||||
<button
|
||||
@click="expandedReports = !expandedReports"
|
||||
class="group px-4 py-3 text-left text-sm font-medium rounded-xl transition-all flex items-center justify-between gap-3 relative overflow-hidden whitespace-nowrap text-slate-600 hover:bg-slate-50 hover:text-slate-900"
|
||||
class="group px-4 py-3 text-left text-sm font-medium rounded-xl transition-all flex items-center justify-between gap-3 relative overflow-hidden whitespace-nowrap text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-slate-100"
|
||||
:title="isSidebarCollapsed ? t('admin.nav.reports') : ''"
|
||||
>
|
||||
<div class="flex items-center gap-3">
|
||||
<BarChart2 class="w-5 h-5 text-slate-400 group-hover:text-slate-600 flex-shrink-0" />
|
||||
<BarChart2 class="w-5 h-5 text-slate-400 dark:text-slate-500 group-hover:text-slate-600 dark:group-hover:text-slate-300 flex-shrink-0" />
|
||||
<span :class="isSidebarCollapsed ? 'md:hidden' : ''">{{ t('admin.nav.reports') }}</span>
|
||||
</div>
|
||||
<svg v-if="!isSidebarCollapsed" :class="expandedReports ? 'rotate-180' : ''" class="w-4 h-4 transition-transform text-slate-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<svg v-if="!isSidebarCollapsed" :class="expandedReports ? 'rotate-180' : ''" class="w-4 h-4 transition-transform text-slate-400 dark:text-slate-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div v-if="expandedReports && !isSidebarCollapsed" class="pl-4 space-y-1 mt-1 border-l-2 border-slate-100 ml-6">
|
||||
<div v-if="expandedReports && !isSidebarCollapsed" class="pl-4 space-y-1 mt-1 border-l-2 border-slate-100 dark:border-slate-700 ml-6">
|
||||
<button
|
||||
v-for="table in ['users', 'agents', 'chat_logs', 'permission_requests', 'feedbacks']"
|
||||
:key="table"
|
||||
@click="openReportTab(table)"
|
||||
class="w-full text-left px-4 py-2 text-xs font-medium rounded-lg transition-colors flex items-center gap-2"
|
||||
:class="(activeModule === 'reports' && currentTable === table) ? 'bg-brand-50 text-brand-700' : 'text-slate-500 hover:bg-slate-50 hover:text-slate-900'"
|
||||
:class="(activeModule === 'reports' && currentTable === table) ? 'bg-brand-50 text-brand-700' : 'text-slate-500 dark:text-slate-400 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-slate-900 dark:hover:text-slate-100'"
|
||||
>
|
||||
<div class="w-1.5 h-1.5 rounded-full" :class="(activeModule === 'reports' && currentTable === table) ? 'bg-brand-600' : 'bg-slate-300'"></div>
|
||||
{{ table.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase()) }}
|
||||
@@ -1868,7 +2037,7 @@ const handlePermissionImport = async (event: Event) => {
|
||||
<!-- Dashboard Overview -->
|
||||
<section v-else-if="activeModule === 'dashboard'" class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-6 animate-fade-in-up">
|
||||
<div
|
||||
class="bg-white p-6 rounded-2xl border border-slate-100 shadow-soft hover:shadow-lg transition-all group cursor-pointer"
|
||||
class="bg-white dark:bg-slate-900 p-6 rounded-2xl border border-slate-100 dark:border-slate-700 shadow-soft hover:shadow-lg transition-all group cursor-pointer"
|
||||
@click="activeModule = 'agents'"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
@@ -1877,12 +2046,12 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
<span class="text-xs font-medium text-green-600 bg-green-50 px-2 py-1 rounded-full">+2 new</span>
|
||||
</div>
|
||||
<div class="text-3xl font-bold text-slate-900 mb-1">{{ agents.length }}</div>
|
||||
<div class="text-sm text-slate-500 font-medium">{{ t('admin.dash.activeAgents') }}</div>
|
||||
<div class="text-3xl font-bold text-slate-900 dark:text-slate-100 mb-1">{{ agents.length }}</div>
|
||||
<div class="text-sm text-slate-500 dark:text-slate-400 font-medium">{{ t('admin.dash.activeAgents') }}</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="bg-white p-6 rounded-2xl border border-slate-100 shadow-soft hover:shadow-lg transition-all group cursor-pointer"
|
||||
class="bg-white dark:bg-slate-900 p-6 rounded-2xl border border-slate-100 dark:border-slate-700 shadow-soft hover:shadow-lg transition-all group cursor-pointer"
|
||||
@click="activeModule = 'permissions'"
|
||||
>
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
@@ -2226,8 +2395,8 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
|
||||
<!-- Add Agent Form -->
|
||||
<div class="px-8 py-8 border-b border-gray-100 bg-gray-50/50">
|
||||
<h3 class="text-base font-bold text-gray-800 mb-6">{{ isEditingAgent ? t('admin.agent.edit') : t('admin.agent.create') }}</h3>
|
||||
<div class="px-8 py-8 border-b border-gray-100 dark:border-slate-700 bg-white dark:bg-slate-900">
|
||||
<h3 class="text-base font-bold text-gray-800 dark:text-slate-100 mb-6">{{ isEditingAgent ? t('admin.agent.edit') : t('admin.agent.create') }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
||||
<div class="space-y-2">
|
||||
<label class="text-xs font-bold text-gray-500 uppercase tracking-wider">{{ t('admin.agent.fields.name') }}</label>
|
||||
@@ -2619,6 +2788,140 @@ const handlePermissionImport = async (event: Event) => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- WeCom Management -->
|
||||
<section v-else-if="activeModule === 'wecom'" class="space-y-6 animate-fade-in-up">
|
||||
<div class="flex flex-col md:flex-row items-start md:items-center justify-between gap-4">
|
||||
<div>
|
||||
<h2 class="text-xl font-bold text-gray-900">{{ t('admin.wecom.title') }}</h2>
|
||||
<p class="text-sm text-gray-500 mt-1">{{ t('admin.wecom.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
@click="refreshWecomData"
|
||||
class="inline-flex items-center gap-2 px-4 py-2 bg-white border border-gray-200 text-gray-700 rounded-xl hover:bg-gray-50 transition-all shadow-sm"
|
||||
>
|
||||
<RefreshCw class="w-4 h-4" />
|
||||
{{ t('admin.wecom.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl border border-gray-100 shadow-sm p-5 space-y-4">
|
||||
<h3 class="font-semibold text-gray-900">{{ t('admin.wecom.quickBind') }}</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-3">
|
||||
<input v-model="wecomBindForm.user_id" type="number" :placeholder="t('admin.wecom.fields.userId')" class="input-field" />
|
||||
<input v-model="wecomBindForm.wecom_userid" :placeholder="t('admin.wecom.fields.wecomUserId')" class="input-field md:col-span-2" />
|
||||
<input v-model="wecomBindForm.wecom_unionid" :placeholder="t('admin.wecom.fields.wecomUnionId')" class="input-field" />
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button @click="bindWecomUser" :disabled="isSaving" class="btn-primary px-5 py-2 disabled:opacity-60">
|
||||
<Link2 class="w-4 h-4" /> {{ t('admin.wecom.bind') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden">
|
||||
<div class="px-5 py-4 border-b border-gray-100 flex items-center justify-between">
|
||||
<h3 class="font-semibold text-gray-900">{{ t('admin.wecom.bindingList') }}</h3>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-gray-600">
|
||||
<input type="checkbox" v-model="wecomBoundOnly" class="w-4 h-4 rounded text-blue-600 border-gray-300" />
|
||||
{{ t('admin.wecom.boundOnly') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-left">
|
||||
<thead class="bg-gray-50 border-b border-gray-100">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.headers.user') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.headers.roleStatus') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.headers.wecomUserId') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.headers.unionId') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase text-right">{{ t('admin.wecom.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
<tr v-if="wecomBindings.length === 0">
|
||||
<td colspan="5" class="px-4 py-8 text-center text-sm text-gray-400">{{ t('admin.wecom.noData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="u in wecomBindings" :key="u.id" class="hover:bg-gray-50">
|
||||
<td class="px-4 py-3">
|
||||
<div class="text-sm font-medium text-gray-900">{{ u.username }} <span class="text-gray-500">(#{{ u.id }})</span></div>
|
||||
<div class="text-xs text-gray-500">{{ u.real_name || '-' }} · {{ u.email }}</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-600">{{ t('admin.role.' + u.role) }} / {{ t('admin.status.' + u.status) }}</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-700 font-mono">{{ u.wecom_userid || '-' }}</td>
|
||||
<td class="px-4 py-3 text-sm text-gray-700 font-mono">{{ u.wecom_unionid || '-' }}</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<button
|
||||
v-if="u.wecom_userid"
|
||||
@click="unbindWecomUserByAdmin(u.id)"
|
||||
class="inline-flex items-center gap-1 px-3 py-1.5 text-xs text-red-600 bg-red-50 rounded-lg hover:bg-red-100"
|
||||
>
|
||||
<Unlink2 class="w-3.5 h-3.5" />
|
||||
{{ t('admin.wecom.unbind') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-2xl border border-gray-100 shadow-sm overflow-hidden">
|
||||
<div class="px-5 py-4 border-b border-gray-100 flex flex-col md:flex-row md:items-center md:justify-between gap-3">
|
||||
<h3 class="font-semibold text-gray-900">{{ t('admin.wecom.auditTitle') }}</h3>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<select v-model="wecomAuditSourceFilter" class="px-3 py-2 border border-gray-200 rounded-lg text-sm bg-white">
|
||||
<option value="all">{{ t('admin.wecom.filters.allSources') }}</option>
|
||||
<option value="wecom">{{ t('admin.wecom.sources.wecom') }}</option>
|
||||
<option value="password">{{ t('admin.wecom.sources.password') }}</option>
|
||||
</select>
|
||||
<select v-model="wecomAuditStatusFilter" class="px-3 py-2 border border-gray-200 rounded-lg text-sm bg-white">
|
||||
<option value="all">{{ t('admin.wecom.filters.allStatus') }}</option>
|
||||
<option value="success">{{ t('admin.wecom.auditStatus.success') }}</option>
|
||||
<option value="failed">{{ t('admin.wecom.auditStatus.failed') }}</option>
|
||||
</select>
|
||||
<button
|
||||
@click="exportWecomAudits"
|
||||
class="inline-flex items-center gap-2 px-3 py-2 border border-gray-200 rounded-lg text-sm text-gray-700 bg-white hover:bg-gray-50"
|
||||
>
|
||||
<Download class="w-4 h-4" />
|
||||
{{ t('admin.wecom.exportAudit') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="overflow-x-auto max-h-[420px]">
|
||||
<table class="w-full text-left">
|
||||
<thead class="bg-gray-50 border-b border-gray-100 sticky top-0 z-10">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.auditHeaders.time') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.auditHeaders.source') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.auditHeaders.user') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.auditHeaders.status') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.auditHeaders.reason') }}</th>
|
||||
<th class="px-4 py-3 text-xs font-semibold text-gray-500 uppercase">{{ t('admin.wecom.auditHeaders.ip') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100">
|
||||
<tr v-if="filteredWecomLoginAudits.length === 0">
|
||||
<td colspan="6" class="px-4 py-8 text-center text-sm text-gray-400">{{ t('admin.wecom.noAuditData') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in filteredWecomLoginAudits" :key="row.id" class="hover:bg-gray-50">
|
||||
<td class="px-4 py-3 text-xs text-gray-600 whitespace-nowrap">{{ row.created_at || '-' }}</td>
|
||||
<td class="px-4 py-3 text-xs text-gray-700">{{ t('admin.wecom.sources.' + row.source) }}</td>
|
||||
<td class="px-4 py-3 text-xs text-gray-700">{{ row.username || '-' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span class="inline-flex px-2 py-0.5 rounded-full text-[11px] font-medium" :class="row.status === 'success' ? 'bg-green-50 text-green-700' : 'bg-red-50 text-red-700'">
|
||||
{{ t('admin.wecom.auditStatus.' + row.status) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-gray-600 max-w-[360px] truncate" :title="row.reason || ''">{{ row.reason || '-' }}</td>
|
||||
<td class="px-4 py-3 text-xs text-gray-600 font-mono">{{ row.ip || '-' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Requests -->
|
||||
<section
|
||||
v-if="activeModule === 'requests'"
|
||||
|
||||
Reference in new issue
Block a user