fix: 支持原文件下载,同时将postgres地址由localhost变更为8.152.207.171
This commit is contained in:
1 parent
70f95e9f5c
commit
c380248502
12 files changed
+1273
-273
No files matched your search
@@ -1,8 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* WorkspaceView.vue
|
||||
* 文件用途:用户工作台,支持自定义布局、收藏、嵌入 Agent
|
||||
* 引用文件:vue, vue-router, lucide-vue-next, 后端 /api/user 接口
|
||||
* 鏂囦欢鐢ㄩ€旓細鐢ㄦ埛宸ヤ綔鍙帮紝鏀寔鑷畾涔夊竷灞€銆佹敹钘忋€佸祵鍏?Agent
|
||||
* 寮曠敤鏂囦欢锛歷ue, vue-router, lucide-vue-next, 鍚庣 /api/user 鎺ュ彛
|
||||
*/
|
||||
import { ref, onMounted, computed, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
Edit,
|
||||
ExternalLink,
|
||||
Bot,
|
||||
Lock,
|
||||
User,
|
||||
LogOut,
|
||||
Megaphone,
|
||||
@@ -120,7 +121,7 @@ const isWecomLoggingIn = ref(false);
|
||||
|
||||
const handleForgotPassword = async () => {
|
||||
if (!forgotPasswordForm.value.email) {
|
||||
alert(t('register.email') + ' is required');
|
||||
alert(t('register.emailRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,21 +134,21 @@ const handleForgotPassword = async () => {
|
||||
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
alert(t('login.passwordResetEmailSent') || 'If the account exists, a reset link has been sent to your email.');
|
||||
alert(t('login.passwordResetEmailSent'));
|
||||
showForgotPasswordModal.value = false;
|
||||
forgotPasswordForm.value = { email: '' };
|
||||
} else {
|
||||
alert(data.error || 'Failed to request password reset');
|
||||
alert(data.error || t('login.passwordResetRequestFailed'));
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Password reset error', e);
|
||||
alert('An error occurred');
|
||||
alert(t('common.errorOccurred'));
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
const showLoginTip = () => {
|
||||
alert(t('login.pleaseLoginFirst') || 'Please login to access this agent.');
|
||||
alert(t('login.pleaseLoginFirst'));
|
||||
};
|
||||
*/
|
||||
const userReport = ref<any>(null);
|
||||
@@ -399,11 +400,11 @@ const handleLogin = async () => {
|
||||
const err = await res.json();
|
||||
// Handle specific error messages if needed, or just alert
|
||||
let msg = err.error || t('login.failed');
|
||||
if (err.error === 'User not found') msg = t('login.userNotFound') || 'User not found';
|
||||
if (err.error === 'Incorrect password') msg = t('login.incorrectPassword') || 'Incorrect password';
|
||||
if (err.error === 'Account is disabled') msg = t('login.accountDisabled') || 'Account is disabled';
|
||||
if (err.error === 'Database connection failed') msg = t('login.dbConnectionFailed') || 'Database connection failed';
|
||||
if (err.error === 'Internal server error') msg = t('login.internalError') || 'Internal server error';
|
||||
if (err.error === 'User not found') msg = t('login.userNotFound');
|
||||
if (err.error === 'Incorrect password') msg = t('login.incorrectPassword');
|
||||
if (err.error === 'Account is disabled') msg = t('login.accountDisabled');
|
||||
if (err.error === 'Database connection failed') msg = t('login.dbConnectionFailed');
|
||||
if (err.error === 'Internal server error') msg = t('login.internalError');
|
||||
|
||||
alert(msg);
|
||||
return;
|
||||
@@ -426,7 +427,7 @@ const handleLogin = async () => {
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert(t('login.requestFailed') || 'Login request failed. Please check your network or server status.');
|
||||
alert(t('login.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -438,7 +439,7 @@ const handleWecomLogin = async () => {
|
||||
const res = await fetch(`${api}?redirect_uri=${encodeURIComponent(redirectUri)}`);
|
||||
const data = await res.json();
|
||||
if (!res.ok || !data.url) {
|
||||
alert(data.error || 'Failed to start WeCom login');
|
||||
alert(data.error || t('login.wecomStartFailed'));
|
||||
return;
|
||||
}
|
||||
if (data.state) {
|
||||
@@ -447,7 +448,7 @@ const handleWecomLogin = async () => {
|
||||
window.location.href = data.url;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('Failed to start WeCom login');
|
||||
alert(t('login.wecomStartFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -461,7 +462,7 @@ const tryWecomCallbackLogin = async () => {
|
||||
|
||||
const expectedState = sessionStorage.getItem('hxops_wecom_state');
|
||||
if (expectedState && state && state !== expectedState) {
|
||||
alert('Invalid WeCom login state');
|
||||
alert(t('login.wecomInvalidState'));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -476,13 +477,13 @@ const tryWecomCallbackLogin = async () => {
|
||||
const data = await res.json();
|
||||
if (!res.ok) {
|
||||
const rawError = String(data.error || '');
|
||||
let friendly = rawError || 'WeCom login failed';
|
||||
let friendly = rawError || t('login.wecomLoginFailed');
|
||||
if (rawError.includes('Invalid or expired WeCom state')) {
|
||||
friendly = '企业微信登录会话已过期,请重新点击企业微信登录';
|
||||
friendly = t('login.wecomStateExpired');
|
||||
} else if (rawError.includes('bind WeCom account') || rawError.includes('No linked account found')) {
|
||||
friendly = '当前企业微信账号未绑定本系统用户,请联系管理员在后台完成绑定';
|
||||
friendly = t('login.wecomBindRequired');
|
||||
} else if (rawError.includes('Account is disabled')) {
|
||||
friendly = '账号已被禁用,请联系管理员';
|
||||
friendly = t('login.wecomAccountDisabled');
|
||||
}
|
||||
alert(friendly);
|
||||
return true;
|
||||
@@ -495,7 +496,7 @@ const tryWecomCallbackLogin = async () => {
|
||||
return true;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert('WeCom login failed');
|
||||
alert(t('login.wecomLoginFailed'));
|
||||
return true;
|
||||
} finally {
|
||||
isWecomLoggingIn.value = false;
|
||||
@@ -587,7 +588,7 @@ const toggleFavorite = async (agentId: number) => {
|
||||
// Quick Questions
|
||||
const getAgentName = (agentId: number) => {
|
||||
const agent = agents.value.find(a => a.id === agentId);
|
||||
return agent ? agent.name : t('workspace.unknownAgent', 'Unknown Agent');
|
||||
return agent ? agent.name : t('workspace.unknownAgent');
|
||||
};
|
||||
|
||||
const openAddQuestionForm = () => {
|
||||
@@ -614,7 +615,7 @@ const cancelAddQuestion = () => {
|
||||
|
||||
const saveQuickQuestion = async () => {
|
||||
if (!newQuestion.value.title || !newQuestion.value.question || !newQuestion.value.agent_id) {
|
||||
alert(t('workspace.quickQuestions.addTitle') + ' (Please fill all fields)');
|
||||
alert(t('workspace.quickQuestions.msg.fillAll'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -737,7 +738,7 @@ onMounted(async () => {
|
||||
<button @click="showUserDropdown = !showUserDropdown" class="flex items-center gap-3 pl-3 pr-2 py-1.5 rounded-full hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors border border-transparent hover:border-slate-200 dark:hover:border-slate-700">
|
||||
<div class="text-right hidden sm:block">
|
||||
<div class="text-sm font-bold text-slate-900 dark:text-slate-100 leading-tight">{{ currentUser?.username }}</div>
|
||||
<div class="text-[10px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide">{{ currentUser?.role === 'admin' ? 'Admin' : 'User' }}</div>
|
||||
<div class="text-[10px] font-medium text-slate-500 dark:text-slate-400 uppercase tracking-wide">{{ currentUser?.role }}</div>
|
||||
</div>
|
||||
<div class="w-9 h-9 bg-brand-100 rounded-full flex items-center justify-center text-brand-600 font-bold border-2 border-white shadow-sm">
|
||||
{{ (currentUser?.username || 'U').charAt(0).toUpperCase() }}
|
||||
@@ -755,7 +756,7 @@ onMounted(async () => {
|
||||
|
||||
<button @click="navigateToProfile" class="w-full text-left px-4 py-2 text-sm text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-brand-600 flex items-center gap-2">
|
||||
<User class="w-4 h-4" />
|
||||
{{ $t('profile.title') || 'My Profile' }}
|
||||
{{ $t('profile.title') }}
|
||||
</button>
|
||||
|
||||
<button v-if="currentUser?.role === 'admin'" @click="router.push('/admin')" class="w-full text-left px-4 py-2 text-sm text-slate-700 dark:text-slate-300 hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-brand-600 flex items-center gap-2">
|
||||
@@ -795,21 +796,21 @@ onMounted(async () => {
|
||||
<span class="animate-ping absolute inline-flex h-full w-full rounded-full bg-brand-400 opacity-75"></span>
|
||||
<span class="relative inline-flex rounded-full h-2 w-2 bg-brand-500"></span>
|
||||
</span>
|
||||
Enterprise AI Gateway
|
||||
{{ $t('title') }}
|
||||
</div>
|
||||
<h1 class="text-5xl font-bold text-slate-900 leading-tight">
|
||||
Unleash the Power of <br/>
|
||||
<span class="text-transparent bg-clip-text bg-gradient-to-r from-brand-600 to-purple-600">Generative AI</span>
|
||||
{{ $t('landing.hero.prefix') }} <br/>
|
||||
<span class="text-transparent bg-clip-text bg-gradient-to-r from-brand-600 to-purple-600">{{ $t('landing.hero.highlight') }}</span>
|
||||
</h1>
|
||||
<p class="text-lg text-slate-600 max-w-md leading-relaxed">
|
||||
Access a suite of powerful AI agents tailored for your enterprise needs. Secure, scalable, and intelligent.
|
||||
{{ $t('landing.hero.subtitle') }}
|
||||
</p>
|
||||
|
||||
<!-- Announcements List -->
|
||||
<div v-if="announcements.length > 0" class="bg-white/60 dark:bg-slate-900/70 backdrop-blur-sm rounded-2xl border border-slate-100 dark:border-slate-700 p-6 shadow-sm">
|
||||
<h3 class="text-sm font-bold text-slate-900 mb-4 flex items-center gap-2">
|
||||
<Megaphone class="w-4 h-4 text-brand-600" />
|
||||
{{ $t('login.announcements') || 'Announcements' }}
|
||||
{{ $t('login.announcements') }}
|
||||
</h3>
|
||||
<div class="space-y-3">
|
||||
<div v-for="ann in announcements.slice(0, 3)" :key="ann.id"
|
||||
@@ -832,7 +833,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="truncate">
|
||||
<div class="font-semibold text-slate-900 text-sm truncate">{{ agent.name }}</div>
|
||||
<div class="text-xs text-slate-500 truncate">AI Assistant</div>
|
||||
<div class="text-xs text-slate-500 truncate">{{ $t('landing.agent.role') }}</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -864,7 +865,7 @@ onMounted(async () => {
|
||||
|
||||
<div class="flex items-center gap-2 mt-2">
|
||||
<input type="checkbox" id="rememberMe" v-model="rememberMe" class="rounded border-slate-300 text-brand-600 focus:ring-brand-500 w-4 h-4" />
|
||||
<label for="rememberMe" class="text-sm text-slate-600 cursor-pointer select-none">{{ $t('login.rememberMe') || 'Remember me for 30 days' }}</label>
|
||||
<label for="rememberMe" class="text-sm text-slate-600 cursor-pointer select-none">{{ $t('login.rememberMe') }}</label>
|
||||
</div>
|
||||
|
||||
<button @click="handleLogin" class="btn-primary w-full py-3 text-base shadow-brand-500/40 hover:shadow-brand-500/50 transform hover:-translate-y-0.5 transition-all mt-4">
|
||||
@@ -877,7 +878,7 @@ onMounted(async () => {
|
||||
:disabled="isWecomLoggingIn"
|
||||
class="btn-secondary w-full py-3 text-base mt-3 disabled:opacity-60 disabled:cursor-not-allowed"
|
||||
>
|
||||
{{ isWecomLoggingIn ? ($t('login.wecomConnecting') || 'Connecting to WeCom...') : ($t('login.wecomLogin') || 'Login with WeCom') }}
|
||||
{{ isWecomLoggingIn ? $t('login.wecomConnecting') : $t('login.wecomLogin') }}
|
||||
</button>
|
||||
|
||||
<div class="flex justify-between items-center pt-4 mt-2 border-t border-slate-100/50">
|
||||
@@ -1097,7 +1098,7 @@ onMounted(async () => {
|
||||
<Lock class="w-6 h-6" />
|
||||
</div>
|
||||
<h3 class="text-xl font-bold text-slate-900 dark:text-slate-100">{{ $t('login.forgotPassword') }}</h3>
|
||||
<p class="text-slate-500 dark:text-slate-400 text-sm mt-2">{{ $t('login.forgotPasswordDesc') || 'Enter your email to reset your password' }}</p>
|
||||
<p class="text-slate-500 dark:text-slate-400 text-sm mt-2">{{ $t('login.forgotPasswordDesc') }}</p>
|
||||
</div>
|
||||
|
||||
<div class="space-y-4">
|
||||
@@ -1107,7 +1108,7 @@ onMounted(async () => {
|
||||
|
||||
<div class="flex justify-end gap-3 mt-8">
|
||||
<button @click="showForgotPasswordModal = false" class="btn-secondary flex-1">{{ $t('register.cancel') }}</button>
|
||||
<button @click="handleForgotPassword" class="btn-primary flex-1">{{ $t('login.findPassword') || 'Find Password' }}</button>
|
||||
<button @click="handleForgotPassword" class="btn-primary flex-1">{{ $t('login.findPassword') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user