Merge branch 'dev' into test
This commit is contained in:
commit
175812c1a1
5 files changed
+62
-503
No files matched your search
Vendored
+2
-2
@@ -10,8 +10,8 @@
|
|||||||
<meta name="apple-mobile-web-app-title" content="AI工作台" />
|
<meta name="apple-mobile-web-app-title" content="AI工作台" />
|
||||||
<link rel="manifest" href="/manifest.webmanifest" />
|
<link rel="manifest" href="/manifest.webmanifest" />
|
||||||
<title>AI工作台</title>
|
<title>AI工作台</title>
|
||||||
<script type="module" crossorigin src="/assets/index-g1xHTgxZ.js"></script>
|
<script type="module" crossorigin src="/assets/index-C27ubssp.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-DMUyZ52-.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-Cf26xMBx.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>␍
|
<div id="app"></div>␍
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import { createRouter, createWebHistory } from 'vue-router';
|
|||||||
import WorkspaceView from '../views/WorkspaceView.vue';
|
import WorkspaceView from '../views/WorkspaceView.vue';
|
||||||
import ChatView from '../views/ChatView.vue';
|
import ChatView from '../views/ChatView.vue';
|
||||||
import AdminView from '../views/AdminView.vue';
|
import AdminView from '../views/AdminView.vue';
|
||||||
import ProfileView from '../views/ProfileView.vue';
|
|
||||||
import ResetPasswordView from '../views/ResetPasswordView.vue';
|
import ResetPasswordView from '../views/ResetPasswordView.vue';
|
||||||
import KbWorkspaceView from '../views/KbWorkspaceView.vue';
|
import KbWorkspaceView from '../views/KbWorkspaceView.vue';
|
||||||
import KbAdminView from '../views/KbAdminView.vue';
|
import KbAdminView from '../views/KbAdminView.vue';
|
||||||
@@ -27,11 +26,6 @@ const routes = [
|
|||||||
name: 'CasdoorCallback',
|
name: 'CasdoorCallback',
|
||||||
component: WorkspaceView
|
component: WorkspaceView
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/profile',
|
|
||||||
name: 'Profile',
|
|
||||||
component: ProfileView
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: '/reset-password',
|
path: '/reset-password',
|
||||||
name: 'ResetPassword',
|
name: 'ResetPassword',
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
|
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useChat } from '../composables/useChat';
|
import { useChat } from '../composables/useChat';
|
||||||
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Heart, Bell, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, UserCircle, Menu } from 'lucide-vue-next';
|
import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Heart, Bell, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid, UserCircle } from 'lucide-vue-next';
|
||||||
import { marked } from 'marked';
|
import { marked } from 'marked';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
@@ -1873,7 +1873,7 @@ const showChatRating = ref(false);
|
|||||||
<div class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-sky-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20">AI</div>
|
<div class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-sky-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20">AI</div>
|
||||||
<span class="text-sm font-semibold text-slate-800 dark:text-slate-100">{{ currentAgent?.name || 'AI' }}</span>
|
<span class="text-sm font-semibold text-slate-800 dark:text-slate-100">{{ currentAgent?.name || 'AI' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<button @click="router.push('/profile')" class="flex h-9 w-9 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800" title="个人设置">
|
<button @click="router.push('/workspace?view=profile')" class="flex h-9 w-9 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800" title="个人设置">
|
||||||
<UserCircle class="h-6 w-6" />
|
<UserCircle class="h-6 w-6" />
|
||||||
</button>
|
</button>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -1,485 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import { ref, onMounted, computed } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useRouter } from 'vue-router';
|
|
||||||
import { useTheme } from '../composables/useTheme';
|
|
||||||
import { useIsMobile } from '../composables/useIsMobile';
|
|
||||||
import type { ThemePreference } from '../composables/useTheme';
|
|
||||||
import ThemeToggleButton from '../components/ThemeToggleButton.vue';
|
|
||||||
import { useGlobalMessageDialog } from '../composables/useGlobalMessageDialog';
|
|
||||||
import { getAuthHeaders } from '../utils/auth';
|
|
||||||
import {
|
|
||||||
User,
|
|
||||||
Mail,
|
|
||||||
Building,
|
|
||||||
CreditCard,
|
|
||||||
Shield,
|
|
||||||
Globe,
|
|
||||||
LogOut,
|
|
||||||
Save,
|
|
||||||
ChevronLeft,
|
|
||||||
X,
|
|
||||||
Palette
|
|
||||||
} from 'lucide-vue-next';
|
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
|
||||||
const { showMessageDialog } = useGlobalMessageDialog();
|
|
||||||
const router = useRouter();
|
|
||||||
const { setThemePreference, appliedTheme } = useTheme();
|
|
||||||
const { isMobile } = useIsMobile();
|
|
||||||
|
|
||||||
interface ProfileForm {
|
|
||||||
id: number;
|
|
||||||
username: string;
|
|
||||||
real_name: string;
|
|
||||||
email: string;
|
|
||||||
phone_number: string;
|
|
||||||
department: string;
|
|
||||||
role: string;
|
|
||||||
employee_id: string;
|
|
||||||
language: string;
|
|
||||||
theme_preference: ThemePreference;
|
|
||||||
}
|
|
||||||
|
|
||||||
// State
|
|
||||||
const isLoading = ref(true);
|
|
||||||
const isSaving = ref(false);
|
|
||||||
const user = ref<ProfileForm>({
|
|
||||||
id: 0,
|
|
||||||
username: '',
|
|
||||||
real_name: '',
|
|
||||||
email: '',
|
|
||||||
phone_number: '',
|
|
||||||
department: '',
|
|
||||||
role: '',
|
|
||||||
employee_id: '',
|
|
||||||
language: 'zh-CN',
|
|
||||||
theme_preference: 'system' as ThemePreference
|
|
||||||
});
|
|
||||||
const originalProfile = ref<ProfileForm | null>(null);
|
|
||||||
|
|
||||||
const isEditing = ref(false);
|
|
||||||
const passwordForm = ref({
|
|
||||||
current: '',
|
|
||||||
new: '',
|
|
||||||
confirm: ''
|
|
||||||
});
|
|
||||||
|
|
||||||
const themeOptions: Array<{ value: ThemePreference; label: () => string }> = [
|
|
||||||
{ value: 'light', label: () => t('theme.light') || 'Light' },
|
|
||||||
{ value: 'dark', label: () => t('theme.dark') || 'Dark' },
|
|
||||||
{ value: 'system', label: () => t('theme.system') || 'Follow System' },
|
|
||||||
];
|
|
||||||
|
|
||||||
const hasUnsavedChanges = computed(() => {
|
|
||||||
if (!originalProfile.value) return false;
|
|
||||||
return (
|
|
||||||
user.value.real_name !== originalProfile.value.real_name ||
|
|
||||||
user.value.phone_number !== originalProfile.value.phone_number ||
|
|
||||||
user.value.language !== originalProfile.value.language ||
|
|
||||||
user.value.theme_preference !== originalProfile.value.theme_preference ||
|
|
||||||
user.value.email !== originalProfile.value.email ||
|
|
||||||
user.value.employee_id !== originalProfile.value.employee_id ||
|
|
||||||
user.value.department !== originalProfile.value.department
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const captureOriginalProfile = () => {
|
|
||||||
originalProfile.value = { ...user.value };
|
|
||||||
};
|
|
||||||
|
|
||||||
const startEditing = () => {
|
|
||||||
isEditing.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const cancelEditing = () => {
|
|
||||||
if (originalProfile.value) {
|
|
||||||
user.value = { ...originalProfile.value };
|
|
||||||
locale.value = user.value.language;
|
|
||||||
setThemePreference(user.value.theme_preference);
|
|
||||||
}
|
|
||||||
isEditing.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Methods
|
|
||||||
const fetchProfile = async () => {
|
|
||||||
isLoading.value = true;
|
|
||||||
try {
|
|
||||||
const res = await fetch('/api/user/profile', { headers: getAuthHeaders() });
|
|
||||||
if (res.ok) {
|
|
||||||
const data = await res.json();
|
|
||||||
user.value = { ...user.value, ...data };
|
|
||||||
if (data.language) locale.value = data.language;
|
|
||||||
if (data.theme_preference) {
|
|
||||||
setThemePreference(data.theme_preference);
|
|
||||||
} else {
|
|
||||||
user.value.theme_preference = appliedTheme.value;
|
|
||||||
}
|
|
||||||
captureOriginalProfile();
|
|
||||||
isEditing.value = false;
|
|
||||||
} else {
|
|
||||||
console.error('Failed to load profile');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
} finally {
|
|
||||||
isLoading.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const showPasswordModal = ref(false);
|
|
||||||
|
|
||||||
const parseErrorMessage = async (res: Response) => {
|
|
||||||
try {
|
|
||||||
const data = await res.json();
|
|
||||||
return data?.error || data?.message || '';
|
|
||||||
} catch {
|
|
||||||
try {
|
|
||||||
return await res.text();
|
|
||||||
} catch {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSaveProfile = async () => {
|
|
||||||
if (!hasUnsavedChanges.value) {
|
|
||||||
isEditing.value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
real_name: user.value.real_name,
|
|
||||||
phone_number: user.value.phone_number,
|
|
||||||
language: user.value.language,
|
|
||||||
theme_preference: user.value.theme_preference,
|
|
||||||
email: user.value.email,
|
|
||||||
employee_id: user.value.employee_id,
|
|
||||||
department: user.value.department
|
|
||||||
};
|
|
||||||
|
|
||||||
// Apply UI state first so theme switch always takes effect immediately.
|
|
||||||
locale.value = user.value.language;
|
|
||||||
setThemePreference(user.value.theme_preference);
|
|
||||||
|
|
||||||
try {
|
|
||||||
isSaving.value = true;
|
|
||||||
let res = await fetch('/api/user/profile', {
|
|
||||||
method: 'PUT',
|
|
||||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
|
||||||
body: JSON.stringify(payload)
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!res.ok) {
|
|
||||||
// Backward compatibility: older backend may not support theme_preference yet.
|
|
||||||
const fallbackPayload = {
|
|
||||||
real_name: user.value.real_name,
|
|
||||||
phone_number: user.value.phone_number,
|
|
||||||
language: user.value.language,
|
|
||||||
email: user.value.email,
|
|
||||||
employee_id: user.value.employee_id,
|
|
||||||
department: user.value.department
|
|
||||||
};
|
|
||||||
res = await fetch('/api/user/profile', {
|
|
||||||
method: 'PUT',
|
|
||||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
|
||||||
body: JSON.stringify(fallbackPayload)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!res.ok) {
|
|
||||||
const message = await parseErrorMessage(res);
|
|
||||||
showMessageDialog('error', message || 'Failed to save profile');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
showMessageDialog('success', t('profile.saveSuccess') || 'Profile saved successfully');
|
|
||||||
captureOriginalProfile();
|
|
||||||
isEditing.value = false;
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
showMessageDialog('error', 'Failed to save profile');
|
|
||||||
} finally {
|
|
||||||
isSaving.value = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleChangePassword = async () => {
|
|
||||||
if (passwordForm.value.new !== passwordForm.value.confirm) {
|
|
||||||
showMessageDialog('warning', t('profile.passwordMismatch') || 'Passwords do not match');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const res = await fetch('/api/user/change-password', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
|
||||||
body: JSON.stringify({
|
|
||||||
current_password: passwordForm.value.current,
|
|
||||||
new_password: passwordForm.value.new
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = await res.json();
|
|
||||||
if (res.ok) {
|
|
||||||
showMessageDialog('success', t('profile.passwordChanged') || 'Password changed successfully');
|
|
||||||
passwordForm.value = { current: '', new: '', confirm: '' };
|
|
||||||
showPasswordModal.value = false;
|
|
||||||
} else {
|
|
||||||
showMessageDialog('error', data.error || 'Failed to change password');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
showMessageDialog('error', 'Error changing password');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleLogout = () => {
|
|
||||||
localStorage.removeItem('hxops_user');
|
|
||||||
sessionStorage.removeItem('hxops_user');
|
|
||||||
sessionStorage.removeItem('hxops_wecom_state');
|
|
||||||
router.replace('/');
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
fetchProfile();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<div class="min-h-screen bg-slate-50 dark:bg-slate-950 pb-20">
|
|
||||||
<!-- Header -->
|
|
||||||
<header class="bg-white dark:bg-slate-900 border-b border-slate-200 dark:border-slate-700 sticky top-0 z-30">
|
|
||||||
<div class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 h-16 flex items-center justify-between">
|
|
||||||
<div class="flex items-center gap-4">
|
|
||||||
<button @click="router.push(isMobile ? '/chat/16' : '/workspace')" class="p-2 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-full text-slate-500 dark:text-slate-300 transition-colors">
|
|
||||||
<ChevronLeft class="w-5 h-5" />
|
|
||||||
</button>
|
|
||||||
<h1 class="text-xl font-bold text-slate-900 dark:text-slate-100">{{ $t('profile.title') || 'My Profile' }}</h1>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<ThemeToggleButton />
|
|
||||||
<button @click="handleLogout" class="text-sm font-medium text-red-600 hover:text-red-700 flex items-center gap-2 px-3 py-1.5 hover:bg-red-50 rounded-lg transition-colors">
|
|
||||||
<LogOut class="w-4 h-4" />
|
|
||||||
<span class="hidden sm:inline">{{ $t('workspace.logout') }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<main class="max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
||||||
<div v-if="isLoading" class="flex justify-center py-20">
|
|
||||||
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-else class="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
|
||||||
<!-- Left Column: User Card -->
|
|
||||||
<div class="lg:col-span-1 space-y-6">
|
|
||||||
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700 p-6 text-center">
|
|
||||||
<div class="w-24 h-24 bg-brand-100 rounded-full mx-auto flex items-center justify-center text-brand-600 mb-4 text-3xl font-bold">
|
|
||||||
{{ user.real_name ? user.real_name.charAt(0).toUpperCase() : user.username.charAt(0).toUpperCase() }}
|
|
||||||
</div>
|
|
||||||
<h2 class="text-xl font-bold text-slate-900 dark:text-slate-100">{{ user.real_name || user.username }}</h2>
|
|
||||||
<p class="text-slate-500 dark:text-slate-400 text-sm mt-1">{{ user.email }}</p>
|
|
||||||
<div class="mt-4 inline-flex items-center px-3 py-1 rounded-full bg-slate-100 dark:bg-slate-800 text-slate-600 dark:text-slate-300 text-xs font-medium">
|
|
||||||
{{ user.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700 p-6">
|
|
||||||
<h3 class="font-semibold text-slate-900 dark:text-slate-100 mb-4 flex items-center gap-2">
|
|
||||||
<Shield class="w-4 h-4 text-brand-500" />
|
|
||||||
{{ $t('profile.security') || 'Security' }}
|
|
||||||
</h3>
|
|
||||||
<button @click="showPasswordModal = true" class="btn-primary w-full py-2 text-sm flex items-center justify-center gap-2">
|
|
||||||
<Shield class="w-4 h-4" />
|
|
||||||
{{ $t('profile.changePassword') || 'Change Password' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Right Column: Details & Settings -->
|
|
||||||
<div class="lg:col-span-2 space-y-6">
|
|
||||||
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700 p-4">
|
|
||||||
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
|
||||||
<div>
|
|
||||||
<div class="text-sm font-semibold text-slate-900 dark:text-slate-100">
|
|
||||||
{{ isEditing ? ($t('profile.edit') || 'Edit') : ($t('profile.personalInfo') || 'Personal Information') }}
|
|
||||||
</div>
|
|
||||||
<div class="text-xs text-slate-500 dark:text-slate-400">
|
|
||||||
{{ isEditing ? ($t('profile.unsavedChanges') || 'You have unsaved changes') : ($t('profile.editHint') || 'Switch to edit mode to update profile details') }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<button v-if="!isEditing" @click="startEditing" class="btn-secondary text-sm px-4 py-2">
|
|
||||||
{{ $t('profile.edit') || 'Edit' }}
|
|
||||||
</button>
|
|
||||||
<template v-else>
|
|
||||||
<button @click="cancelEditing" class="btn-secondary text-sm px-4 py-2">
|
|
||||||
{{ $t('profile.cancel') || 'Cancel' }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
@click="handleSaveProfile"
|
|
||||||
:disabled="isSaving || !hasUnsavedChanges"
|
|
||||||
class="btn-primary text-sm px-4 py-2 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
||||||
>
|
|
||||||
<Save class="w-4 h-4" />
|
|
||||||
<span>{{ isSaving ? 'Saving...' : ($t('workspace.save') || 'Save') }}</span>
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700 p-6 md:p-8">
|
|
||||||
<div class="flex justify-between items-center mb-6">
|
|
||||||
<h3 class="text-lg font-bold text-slate-900 dark:text-slate-100 flex items-center gap-2">
|
|
||||||
<User class="w-5 h-5 text-brand-500" />
|
|
||||||
{{ $t('profile.personalInfo') || 'Personal Information' }}
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase flex items-center gap-1.5 mb-1.5">
|
|
||||||
<User class="w-3.5 h-3.5" /> {{ $t('login.username') }}
|
|
||||||
</label>
|
|
||||||
<div class="p-2.5 bg-slate-50 dark:bg-slate-800 rounded-lg text-slate-700 dark:text-slate-300 border border-slate-200 dark:border-slate-700 text-sm font-medium cursor-not-allowed">
|
|
||||||
{{ user.username }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase flex items-center gap-1.5 mb-1.5">
|
|
||||||
<CreditCard class="w-3.5 h-3.5" /> {{ $t('register.fields.employeeId') || 'Employee ID' }}
|
|
||||||
</label>
|
|
||||||
<input v-if="isEditing" v-model="user.employee_id" type="text" class="input-field" />
|
|
||||||
<div v-else class="p-2.5 bg-slate-50 dark:bg-slate-800 rounded-lg text-slate-700 dark:text-slate-300 border border-slate-200 dark:border-slate-700 text-sm font-medium">
|
|
||||||
{{ user.employee_id || '-' }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase flex items-center gap-1.5 mb-1.5">
|
|
||||||
<User class="w-3.5 h-3.5" /> {{ $t('register.fields.realName') || 'Real Name' }}
|
|
||||||
</label>
|
|
||||||
<input v-if="isEditing" v-model="user.real_name" type="text" class="input-field" />
|
|
||||||
<div v-else class="p-2.5 bg-white dark:bg-slate-900 rounded-lg text-slate-900 dark:text-slate-100 border border-transparent text-sm font-medium">
|
|
||||||
{{ user.real_name || '-' }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase flex items-center gap-1.5 mb-1.5">
|
|
||||||
<Building class="w-3.5 h-3.5" /> {{ $t('profile.department') || 'Department' }}
|
|
||||||
</label>
|
|
||||||
<input v-if="isEditing" v-model="user.department" type="text" class="input-field" />
|
|
||||||
<div v-else class="p-2.5 bg-slate-50 dark:bg-slate-800 rounded-lg text-slate-700 dark:text-slate-300 border border-slate-200 dark:border-slate-700 text-sm font-medium">
|
|
||||||
{{ user.department || '-' }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase flex items-center gap-1.5 mb-1.5">
|
|
||||||
<Mail class="w-3.5 h-3.5" /> {{ $t('register.email') }}
|
|
||||||
</label>
|
|
||||||
<input v-if="isEditing" v-model="user.email" type="email" class="input-field" />
|
|
||||||
<div v-else class="p-2.5 bg-slate-50 dark:bg-slate-800 rounded-lg text-slate-700 dark:text-slate-300 border border-slate-200 dark:border-slate-700 text-sm font-medium">
|
|
||||||
{{ user.email }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase flex items-center gap-1.5 mb-1.5">
|
|
||||||
<Globe class="w-3.5 h-3.5" /> {{ $t('register.fields.phone') || 'Phone' }}
|
|
||||||
</label>
|
|
||||||
<input v-if="isEditing" v-model="user.phone_number" type="text" class="input-field" />
|
|
||||||
<div v-else class="p-2.5 bg-white dark:bg-slate-900 rounded-lg text-slate-900 dark:text-slate-100 border border-transparent text-sm font-medium">
|
|
||||||
{{ user.phone_number || '-' }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-sm border border-slate-100 dark:border-slate-700 p-6 md:p-8">
|
|
||||||
<h3 class="text-lg font-bold text-slate-900 dark:text-slate-100 mb-6 flex items-center gap-2">
|
|
||||||
<Globe class="w-5 h-5 text-brand-500" />
|
|
||||||
{{ $t('profile.preferences') || 'Preferences' }}
|
|
||||||
</h3>
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase mb-1.5 block">{{ $t('profile.language') || 'Language' }}</label>
|
|
||||||
<select
|
|
||||||
v-model="user.language"
|
|
||||||
:disabled="!isEditing"
|
|
||||||
class="input-field appearance-none bg-no-repeat bg-right pr-8"
|
|
||||||
:class="{ 'bg-slate-50 dark:bg-slate-800': !isEditing }"
|
|
||||||
>
|
|
||||||
<option value="en">English</option>
|
|
||||||
<option value="zh-CN">简体中文</option>
|
|
||||||
<option value="zh-TW">繁體中文</option>
|
|
||||||
<option value="th">ไทย</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase mb-1.5 flex items-center gap-1.5">
|
|
||||||
<Palette class="w-3.5 h-3.5" /> {{ $t('theme.label') || 'Theme' }}
|
|
||||||
</label>
|
|
||||||
<div class="grid grid-cols-3 gap-2">
|
|
||||||
<button
|
|
||||||
v-for="item in themeOptions"
|
|
||||||
:key="item.value"
|
|
||||||
type="button"
|
|
||||||
:disabled="!isEditing"
|
|
||||||
@click="user.theme_preference = item.value"
|
|
||||||
class="px-3 py-2 rounded-lg border text-xs font-medium transition-colors"
|
|
||||||
:class="user.theme_preference === item.value
|
|
||||||
? 'border-brand-500 bg-brand-50 text-brand-700 dark:bg-brand-900/30 dark:text-brand-200'
|
|
||||||
: 'border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-900 text-slate-600 dark:text-slate-300'"
|
|
||||||
>
|
|
||||||
{{ item.label() }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
<div v-if="showPasswordModal" class="fixed inset-0 z-50 flex items-center justify-center bg-black/50 dark:bg-slate-950/70 backdrop-blur-sm p-4">
|
|
||||||
<div class="bg-white dark:bg-slate-900 rounded-2xl shadow-xl w-full max-w-md p-6 animate-fade-in-up border border-slate-200 dark:border-slate-700">
|
|
||||||
<div class="flex justify-between items-center mb-6">
|
|
||||||
<h3 class="text-lg font-bold text-slate-900 dark:text-slate-100">{{ $t('profile.changePassword') || 'Change Password' }}</h3>
|
|
||||||
<button @click="showPasswordModal = false" class="p-1 hover:bg-slate-100 dark:hover:bg-slate-800 rounded-full transition-colors">
|
|
||||||
<X class="w-5 h-5 text-slate-500 dark:text-slate-300" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<form @submit.prevent="handleChangePassword" class="space-y-4">
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase">{{ $t('profile.currentPassword') || 'Current Password' }}</label>
|
|
||||||
<input v-model="passwordForm.current" type="password" class="input-field mt-1" required />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase">{{ $t('profile.newPassword') || 'New Password' }}</label>
|
|
||||||
<input v-model="passwordForm.new" type="password" class="input-field mt-1" required />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="text-xs font-medium text-slate-500 uppercase">{{ $t('profile.confirmPassword') || 'Confirm Password' }}</label>
|
|
||||||
<input v-model="passwordForm.confirm" type="password" class="input-field mt-1" required />
|
|
||||||
</div>
|
|
||||||
<div class="flex gap-3 pt-2">
|
|
||||||
<button type="button" @click="showPasswordModal = false" class="flex-1 px-4 py-2 border border-slate-200 dark:border-slate-700 rounded-lg text-slate-600 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800 font-medium transition-colors">
|
|
||||||
{{ $t('profile.cancel') || 'Cancel' }}
|
|
||||||
</button>
|
|
||||||
<button type="submit" class="flex-1 btn-primary py-2 text-sm">
|
|
||||||
{{ $t('profile.changePassword') || 'Update' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
* 引用文件:vue, vue-router, lucide-vue-next, 后端 /api/user 接口
|
* 引用文件:vue, vue-router, lucide-vue-next, 后端 /api/user 接口
|
||||||
*/
|
*/
|
||||||
import { ref, onMounted, computed, watch, nextTick } from 'vue';
|
import { ref, onMounted, computed, watch, nextTick } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter, useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { config } from '../config';
|
import { config } from '../config';
|
||||||
import { useTheme } from '../composables/useTheme';
|
import { useTheme } from '../composables/useTheme';
|
||||||
@@ -48,7 +48,8 @@ import {
|
|||||||
Megaphone,
|
Megaphone,
|
||||||
X,
|
X,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
ChevronUp
|
ChevronUp,
|
||||||
|
MessageCircle
|
||||||
} from 'lucide-vue-next';
|
} from 'lucide-vue-next';
|
||||||
|
|
||||||
import KbWorkspaceView from './KbWorkspaceView.vue';
|
import KbWorkspaceView from './KbWorkspaceView.vue';
|
||||||
@@ -58,6 +59,7 @@ import { Clock, Download, Search, RefreshCw } from 'lucide-vue-next';
|
|||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const { showMessageDialog } = useGlobalMessageDialog();
|
const { showMessageDialog } = useGlobalMessageDialog();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const route = useRoute();
|
||||||
const { setThemePreference, appliedTheme } = useTheme();
|
const { setThemePreference, appliedTheme } = useTheme();
|
||||||
const { isMobile } = useIsMobile();
|
const { isMobile } = useIsMobile();
|
||||||
const loginBackgroundStyle = {
|
const loginBackgroundStyle = {
|
||||||
@@ -812,6 +814,30 @@ const hasProfileUnsavedChanges = computed(() => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const mobileTabActive = computed({
|
||||||
|
get: () => {
|
||||||
|
if (activeSidebarItem.value === 'profile') return 'profile';
|
||||||
|
if (activeSidebarItem.value === 'feedback') return 'feedback';
|
||||||
|
return 'applications';
|
||||||
|
},
|
||||||
|
set: (tab: string) => {
|
||||||
|
if (tab === 'profile') {
|
||||||
|
activeSidebarItem.value = 'profile';
|
||||||
|
if (!profileUser.value.id) fetchProfile();
|
||||||
|
} else if (tab === 'feedback') {
|
||||||
|
activeSidebarItem.value = 'feedback';
|
||||||
|
} else {
|
||||||
|
activeSidebarItem.value = 'applications';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const mobileTabTitle = computed(() => {
|
||||||
|
if (mobileTabActive.value === 'profile') return '我的';
|
||||||
|
if (mobileTabActive.value === 'feedback') return '意见反馈';
|
||||||
|
return '应用管理';
|
||||||
|
});
|
||||||
|
|
||||||
const handleLogout = () => {
|
const handleLogout = () => {
|
||||||
localStorage.removeItem('hxops_user');
|
localStorage.removeItem('hxops_user');
|
||||||
sessionStorage.removeItem('hxops_user');
|
sessionStorage.removeItem('hxops_user');
|
||||||
@@ -1304,6 +1330,14 @@ onMounted(async () => {
|
|||||||
if (currentUser.value && currentUser.value.role !== 'guest') {
|
if (currentUser.value && currentUser.value.role !== 'guest') {
|
||||||
await fetchHome();
|
await fetchHome();
|
||||||
await handleWecomDeeplinkContext();
|
await handleWecomDeeplinkContext();
|
||||||
|
const viewParam = route.query.view as string;
|
||||||
|
const validViews: string[] = ['profile', 'applications', 'feedback', 'updates', 'knowledge_base', 'schedule_runs'];
|
||||||
|
if (viewParam && validViews.includes(viewParam)) {
|
||||||
|
activeSidebarItem.value = viewParam as typeof activeSidebarItem.value;
|
||||||
|
if (viewParam === 'profile' && !profileUser.value.id) {
|
||||||
|
await fetchProfile();
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await fetchPublicAgents();
|
await fetchPublicAgents();
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
@@ -1471,12 +1505,9 @@ onMounted(async () => {
|
|||||||
<div v-else class="min-h-screen animate-fade-in">
|
<div v-else class="min-h-screen animate-fade-in">
|
||||||
<header v-if="isMobile" class="sticky top-0 z-30 flex items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-slate-800 dark:bg-slate-950">
|
<header v-if="isMobile" class="sticky top-0 z-30 flex items-center justify-between border-b border-slate-200 bg-white px-4 py-2.5 dark:border-slate-800 dark:bg-slate-950">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<div class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20">AI</div>
|
<button @click="router.push('/chat/16')" class="flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-brand-500 via-brand-600 to-purple-600 text-xs font-bold text-white shadow-sm shadow-brand-500/20" title="返回聊天">AI</button>
|
||||||
<span class="text-sm font-semibold text-slate-800 dark:text-slate-100">和信AI</span>
|
<span class="text-sm font-semibold text-slate-800 dark:text-slate-100">{{ mobileTabTitle }}</span>
|
||||||
</div>
|
</div>
|
||||||
<button @click="router.push('/profile')" class="flex h-9 w-9 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-800" title="个人设置">
|
|
||||||
<User class="h-5 w-5" />
|
|
||||||
</button>
|
|
||||||
</header>
|
</header>
|
||||||
<div class="grid min-h-screen gap-0 lg:grid-cols-[232px_minmax(0,1fr)]">
|
<div class="grid min-h-screen gap-0 lg:grid-cols-[232px_minmax(0,1fr)]">
|
||||||
<aside v-if="!isMobile" class="lg:sticky lg:top-0 lg:h-screen">
|
<aside v-if="!isMobile" class="lg:sticky lg:top-0 lg:h-screen">
|
||||||
@@ -1577,7 +1608,7 @@ onMounted(async () => {
|
|||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<section class="min-w-0 space-y-6 bg-gray-50 px-4 py-6 md:px-6 md:py-8 lg:px-8">
|
<section class="min-w-0 space-y-6 bg-gray-50 px-4 py-6 md:px-6 md:py-8 lg:px-8" :class="isMobile ? 'pb-20' : ''">
|
||||||
<template v-if="activeSidebarItem === 'profile'">
|
<template v-if="activeSidebarItem === 'profile'">
|
||||||
<div v-if="isProfileLoading" class="flex justify-center py-20">
|
<div v-if="isProfileLoading" class="flex justify-center py-20">
|
||||||
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"></div>
|
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-brand-600"></div>
|
||||||
@@ -2032,6 +2063,25 @@ onMounted(async () => {
|
|||||||
</template>
|
</template>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<nav v-if="isMobile" class="fixed bottom-0 left-0 right-0 z-40 border-t border-slate-200 bg-white dark:border-slate-800 dark:bg-slate-950 safe-bottom">
|
||||||
|
<div class="flex h-14 items-center justify-around">
|
||||||
|
<button
|
||||||
|
v-for="tab in [
|
||||||
|
{ key: 'applications', icon: LayoutGrid, label: '应用管理' },
|
||||||
|
{ key: 'feedback', icon: MessageCircle, label: '意见反馈' },
|
||||||
|
{ key: 'profile', icon: User, label: '我的' },
|
||||||
|
]"
|
||||||
|
:key="tab.key"
|
||||||
|
@click="mobileTabActive = tab.key"
|
||||||
|
class="flex flex-1 flex-col items-center justify-center gap-0.5 py-1 transition-colors"
|
||||||
|
:class="mobileTabActive === tab.key ? 'text-brand-600 dark:text-brand-400' : 'text-slate-400 dark:text-slate-500'"
|
||||||
|
>
|
||||||
|
<component :is="tab.icon" class="h-5 w-5" />
|
||||||
|
<span class="text-[10px] font-medium">{{ tab.label }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
<!-- Forgot Password Modal -->
|
<!-- Forgot Password Modal -->
|
||||||
<div v-if="showForgotPasswordModal" class="fixed inset-0 bg-slate-900/40 dark:bg-slate-950/70 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-fade-in">
|
<div v-if="showForgotPasswordModal" class="fixed inset-0 bg-slate-900/40 dark:bg-slate-950/70 backdrop-blur-sm flex items-center justify-center z-50 p-4 animate-fade-in">
|
||||||
|
|||||||
Reference in new issue
Block a user