Merge branch 'dev' of https://gitee.com/justop/hxops into dev
This commit is contained in:
commit
97e482fb74
9 files changed
+412
-97
No files matched your search
+19
-4
@@ -5,7 +5,12 @@ import { watch, onMounted, onBeforeUnmount } from 'vue';
|
||||
import { useTheme } from './composables/useTheme';
|
||||
import LevelMessageDialog from './components/LevelMessageDialog.vue';
|
||||
import { useGlobalMessageDialog } from './composables/useGlobalMessageDialog';
|
||||
import { getAuthHeaders, clearAuthUser } from './utils/auth';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { getAuthHeaders, logoutAuth } from './utils/auth';
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const PUBLIC_PATHS = ['/', '/workspace', '/casdoor-callback', '/reset-password'];
|
||||
|
||||
const { locale } = useI18n();
|
||||
const { themePreference, initTheme, setThemePreference } = useTheme();
|
||||
@@ -58,14 +63,23 @@ watch(themePreference, (newTheme) => {
|
||||
|
||||
const onUnauthorized = () => {
|
||||
showMessageDialog('error', '认证已过期或无效,请重新登录');
|
||||
clearAuthUser();
|
||||
if (window.location.pathname !== '/') {
|
||||
window.location.href = '/';
|
||||
logoutAuth();
|
||||
};
|
||||
|
||||
const onLogout = (event: Event) => {
|
||||
const detail = (event as CustomEvent<{ remote?: boolean }>).detail;
|
||||
if (detail?.remote) {
|
||||
showMessageDialog('info', '您已在其他标签页退出登录');
|
||||
}
|
||||
const path = router.currentRoute.value.path;
|
||||
if (!PUBLIC_PATHS.includes(path)) {
|
||||
router.push('/workspace');
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
window.addEventListener('hxops:unauthorized', onUnauthorized as EventListener);
|
||||
window.addEventListener('hxops:logout', onLogout as EventListener);
|
||||
|
||||
initTheme();
|
||||
|
||||
@@ -90,6 +104,7 @@ onMounted(async () => {
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('hxops:unauthorized', onUnauthorized as EventListener);
|
||||
window.removeEventListener('hxops:logout', onLogout as EventListener);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1266,6 +1266,7 @@ const messages = {
|
||||
leaveBalanceTableUsed: 'Used',
|
||||
leaveBalanceTableRemaining: 'Remaining',
|
||||
leaveBalanceContactHr: 'If needed, please contact HR to confirm leave data.',
|
||||
durationExceedsBalance: '{label}申请时长({requested})超出剩余额度({remaining}),无法提交。',
|
||||
leaveConfirmPrompt: 'Please confirm the following leave information before submitting to OA.',
|
||||
oaLeaveSubmitFailed: 'OA leave submission failed, please try again later.',
|
||||
leaveSubmitFailedPrefix: 'Leave submission failed: {error}',
|
||||
@@ -2699,6 +2700,7 @@ const messages = {
|
||||
leaveBalanceTableUsed: '已休',
|
||||
leaveBalanceTableRemaining: '当前剩余',
|
||||
leaveBalanceContactHr: '如有疑问,请联系人事部门确认假期数据。',
|
||||
durationExceedsBalance: '{label}申请时长({requested})超出剩余额度({remaining}),无法提交。',
|
||||
leaveConfirmPrompt: '请确认以下请假信息,确认无误后再提交到 OA。',
|
||||
oaLeaveSubmitFailed: 'OA 请假提交失败,请稍后重试。',
|
||||
leaveSubmitFailedPrefix: '请假单提交失败:{error}',
|
||||
@@ -3991,6 +3993,7 @@ const messages = {
|
||||
leaveBalanceTableUsed: '已休',
|
||||
leaveBalanceTableRemaining: '目前剩餘',
|
||||
leaveBalanceContactHr: '如有疑問,請聯繫人事部門確認假期資料。',
|
||||
durationExceedsBalance: '{label}申請時長({requested})超出剩餘額度({remaining}),無法提交。',
|
||||
leaveConfirmPrompt: '請確認以下請假資訊,確認無誤後再提交到 OA。',
|
||||
oaLeaveSubmitFailed: 'OA 請假提交失敗,請稍後重試。',
|
||||
leaveSubmitFailedPrefix: '請假單提交失敗:{error}',
|
||||
@@ -5200,6 +5203,7 @@ const messages = {
|
||||
leaveBalanceTableUsed: 'ใช้ไปแล้ว',
|
||||
leaveBalanceTableRemaining: 'คงเหลือปัจจุบัน',
|
||||
leaveBalanceContactHr: 'หากมีข้อสงสัย โปรดติดต่อฝ่ายบุคคลเพื่อตรวจสอบข้อมูลวันลา',
|
||||
durationExceedsBalance: '{label}ระยะเวลาที่ขอ({requested})เกินยอดคงเหลือ({remaining}) ไม่สามารถส่งได้',
|
||||
leaveConfirmPrompt: 'โปรดยืนยันข้อมูลการลาพนักงานก่อนส่งไปยัง OA',
|
||||
oaLeaveSubmitFailed: 'ส่งคำขอลา OA ไม่สำเร็จ กรุณาลองใหม่อีกครั้ง',
|
||||
leaveSubmitFailedPrefix: 'ส่งใบลาล้มเหลว: {error}',
|
||||
|
||||
@@ -4,7 +4,11 @@ import App from './App.vue'
|
||||
import router from './router'
|
||||
import i18n from './i18n'
|
||||
import { config } from './config'
|
||||
import { refreshAccessToken, getAuthToken } from './utils/auth'
|
||||
import { refreshAccessToken, getAuthToken, initAuthSync } from './utils/auth'
|
||||
import { initAgentTabSync } from './utils/agentTabs'
|
||||
|
||||
initAuthSync();
|
||||
initAgentTabSync();
|
||||
|
||||
// Set document title from config
|
||||
document.title = config.appTitle || 'AI工作台';
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
const agentWindowName = (agentId: number): string => `hxops_agent_${agentId}`;
|
||||
|
||||
const isBlankWindow = (win: Window): boolean => {
|
||||
try {
|
||||
const href = win.location.href;
|
||||
return href === 'about:blank' || href.endsWith('about:blank');
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
/** Mark this browser tab as the chat window for an agent (used by window.open target name). */
|
||||
export const registerOpenAgentId = (agentId: number | null): void => {
|
||||
if (agentId && Number.isFinite(agentId) && agentId > 0) {
|
||||
window.name = agentWindowName(agentId);
|
||||
return;
|
||||
}
|
||||
if (window.name.startsWith('hxops_agent_')) {
|
||||
window.name = '';
|
||||
}
|
||||
};
|
||||
|
||||
/** App startup hook (kept for compatibility). */
|
||||
export const initAgentTabSync = (): void => {
|
||||
// Named-window focus does not require background listeners.
|
||||
};
|
||||
|
||||
/**
|
||||
* Focus an existing same-agent tab without reload, or open a new one.
|
||||
*
|
||||
* Per HTML: window.open('', target) focuses an existing named window and
|
||||
* ignores the URL, so the page is not refreshed.
|
||||
*/
|
||||
export const openAgentChatTab = (url: string, agentId: number): void => {
|
||||
const target = agentWindowName(agentId);
|
||||
const existing = window.open('', target);
|
||||
|
||||
if (!existing || existing.closed) {
|
||||
const opened = window.open(url, target);
|
||||
opened?.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
existing.focus();
|
||||
|
||||
if (isBlankWindow(existing)) {
|
||||
try {
|
||||
existing.location.href = url;
|
||||
} catch {
|
||||
window.open(url, target);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -58,13 +58,86 @@ export const saveAuthUser = (user: AuthUser, remember = false): void => {
|
||||
}
|
||||
};
|
||||
|
||||
export const clearAuthUser = (): void => {
|
||||
const AUTH_LOGOUT_KEY = 'hxops_auth_logout';
|
||||
const AUTH_BC_NAME = 'hxops_auth';
|
||||
|
||||
let _authBroadcast: BroadcastChannel | null = null;
|
||||
let _authSyncInitialized = false;
|
||||
|
||||
const clearAuthStorage = (): void => {
|
||||
localStorage.removeItem('hxops_user');
|
||||
sessionStorage.removeItem('hxops_user');
|
||||
sessionStorage.removeItem('hxops_wecom_state');
|
||||
sessionStorage.removeItem('hxops_casdoor_state');
|
||||
};
|
||||
|
||||
const broadcastLogout = (): void => {
|
||||
try {
|
||||
localStorage.setItem(AUTH_LOGOUT_KEY, String(Date.now()));
|
||||
localStorage.removeItem(AUTH_LOGOUT_KEY);
|
||||
} catch {
|
||||
// ignore quota / private mode errors
|
||||
}
|
||||
try {
|
||||
if (!_authBroadcast) {
|
||||
_authBroadcast = new BroadcastChannel(AUTH_BC_NAME);
|
||||
}
|
||||
_authBroadcast.postMessage({ type: 'logout', ts: Date.now() });
|
||||
} catch {
|
||||
// BroadcastChannel may be unavailable
|
||||
}
|
||||
};
|
||||
|
||||
const dispatchLogout = (detail: Record<string, unknown> = {}): void => {
|
||||
window.dispatchEvent(new CustomEvent('hxops:logout', { detail }));
|
||||
};
|
||||
|
||||
const handleRemoteLogout = (): void => {
|
||||
if (!getStoredAuthUser()) return;
|
||||
clearAuthStorage();
|
||||
dispatchLogout({ remote: true });
|
||||
};
|
||||
|
||||
/** Clear credentials and notify other tabs in the same browser. */
|
||||
export const logoutAuth = (): void => {
|
||||
clearAuthStorage();
|
||||
broadcastLogout();
|
||||
dispatchLogout({ source: 'local' });
|
||||
};
|
||||
|
||||
export const clearAuthUser = (): void => {
|
||||
logoutAuth();
|
||||
};
|
||||
|
||||
/** Listen for logout in other tabs (storage + BroadcastChannel). */
|
||||
export const initAuthSync = (): void => {
|
||||
if (_authSyncInitialized) return;
|
||||
_authSyncInitialized = true;
|
||||
|
||||
window.addEventListener('storage', (event: StorageEvent) => {
|
||||
if (event.key === 'hxops_user' && event.newValue === null && event.oldValue != null) {
|
||||
handleRemoteLogout();
|
||||
return;
|
||||
}
|
||||
if (event.key === AUTH_LOGOUT_KEY && event.newValue != null) {
|
||||
handleRemoteLogout();
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
if (!_authBroadcast) {
|
||||
_authBroadcast = new BroadcastChannel(AUTH_BC_NAME);
|
||||
}
|
||||
_authBroadcast.onmessage = (event: MessageEvent) => {
|
||||
if (event.data?.type === 'logout') {
|
||||
handleRemoteLogout();
|
||||
}
|
||||
};
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
};
|
||||
|
||||
let _refreshing: Promise<string | null> | null = null;
|
||||
|
||||
export const refreshAccessToken = async (): Promise<string | null> => {
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
const STORAGE_KEY = 'hxops_last_chat_agent_id';
|
||||
|
||||
export function getLastChatAgentId(fallback = 16): number {
|
||||
try {
|
||||
const raw = sessionStorage.getItem(STORAGE_KEY);
|
||||
const id = Number(raw);
|
||||
return Number.isFinite(id) && id > 0 ? id : fallback;
|
||||
} catch {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
export function setLastChatAgentId(agentId: number): void {
|
||||
if (!Number.isFinite(agentId) || agentId <= 0) return;
|
||||
try {
|
||||
sessionStorage.setItem(STORAGE_KEY, String(agentId));
|
||||
} catch {
|
||||
// ignore storage failures
|
||||
}
|
||||
}
|
||||
@@ -467,9 +467,9 @@ const scheduleRunColumnDefs = ref([
|
||||
{ key: 'total_count', label: '', width: 70, min: 40 },
|
||||
{ key: 'success_count', label: '', width: 70, min: 40 },
|
||||
{ key: 'failed_count', label: '', width: 70, min: 40 },
|
||||
{ key: 'wecom_notified', label: '', width: 90, min: 50 },
|
||||
{ key: 'detail', label: '', width: 90, min: 50 },
|
||||
{ key: 'log', label: '', width: 90, min: 50 },
|
||||
{ key: 'wecom_notified', label: '', width: 100, min: 80 },
|
||||
{ key: 'detail', label: '', width: 100, min: 80 },
|
||||
{ key: 'log', label: '', width: 100, min: 80 },
|
||||
]);
|
||||
|
||||
const syncScheduleRunColumnLabels = () => {
|
||||
@@ -4587,8 +4587,8 @@ const handlePermissionImport = async (event: Event) => {
|
||||
{{ $t('admin.schedule.reset') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="overflow-x-auto rounded-xl border border-slate-100">
|
||||
<table class="w-full min-w-[920px] table-fixed text-left text-xs">
|
||||
<div class="max-h-[calc(100vh-20rem)] overflow-auto rounded-xl border border-slate-100 scrollbar-thin">
|
||||
<table class="w-full min-w-[1270px] table-fixed text-left text-xs">
|
||||
<colgroup>
|
||||
<col
|
||||
v-for="col in scheduleRunColumnDefs"
|
||||
@@ -4596,21 +4596,19 @@ const handlePermissionImport = async (event: Event) => {
|
||||
:style="{ width: `${col.width}px` }"
|
||||
/>
|
||||
</colgroup>
|
||||
<thead class="bg-slate-50">
|
||||
<thead class="sticky top-0 z-10 bg-slate-50">
|
||||
<tr class="text-slate-500">
|
||||
<th
|
||||
v-for="(col, colIndex) in scheduleRunColumnDefs"
|
||||
:key="col.key"
|
||||
class="group relative px-4 py-3 text-xs font-semibold uppercase select-none"
|
||||
class="group relative whitespace-nowrap bg-slate-50 px-4 py-3 text-xs font-semibold uppercase select-none"
|
||||
>
|
||||
<span class="whitespace-nowrap">{{ col.label }}</span>
|
||||
<span
|
||||
class="absolute inset-y-0 -right-1 z-10 w-3 cursor-col-resize"
|
||||
class="absolute inset-y-0 -right-1 z-10 w-2 cursor-col-resize"
|
||||
@mousedown.prevent="startScheduleColResize(colIndex, $event)"
|
||||
:title="$t('admin.schedule.resizeColumn', { label: col.label })"
|
||||
>
|
||||
<span class="mx-auto block h-full w-px bg-slate-300"></span>
|
||||
</span>
|
||||
></span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -4627,52 +4625,52 @@ const handlePermissionImport = async (event: Event) => {
|
||||
:key="r.id"
|
||||
class="text-slate-700 transition hover:bg-slate-50"
|
||||
>
|
||||
<td class="truncate px-4 py-2.5" :title="r.run_no">{{ r.run_no }}</td>
|
||||
<td class="truncate px-4 py-2.5" :title="formatDateTime(r.started_at)">{{ formatDateTime(r.started_at) }}</td>
|
||||
<td class="truncate px-4 py-2.5" :title="formatDateTime(r.finished_at)">{{ formatDateTime(r.finished_at) }}</td>
|
||||
<td class="truncate px-4 py-2.5">
|
||||
<td class="whitespace-nowrap px-4 py-2.5" :title="r.run_no">{{ r.run_no }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-2.5" :title="formatDateTime(r.started_at)">{{ formatDateTime(r.started_at) }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-2.5" :title="formatDateTime(r.finished_at)">{{ formatDateTime(r.finished_at) }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-2.5">
|
||||
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="getScheduleRunStatusBadge(r.status).cls">
|
||||
{{ getScheduleRunStatusBadge(r.status).label }}
|
||||
</span>
|
||||
<span v-if="r.error_message" class="ml-1 text-xs text-slate-400" :title="r.error_message">...</span>
|
||||
</td>
|
||||
<td class="truncate px-4 py-2.5">{{ r.total_count }}</td>
|
||||
<td class="truncate px-4 py-2.5">{{ r.success_count }}</td>
|
||||
<td class="truncate px-4 py-2.5">{{ r.failed_count }}</td>
|
||||
<td class="truncate px-4 py-2.5">
|
||||
<span v-if="r.wecom_notified" class="inline-flex items-center gap-1 text-xs text-emerald-600">
|
||||
<svg class="h-3.5 w-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg>
|
||||
<td class="whitespace-nowrap px-4 py-2.5">{{ r.total_count }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-2.5">{{ r.success_count }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-2.5">{{ r.failed_count }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-2.5">
|
||||
<span v-if="r.wecom_notified" class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs text-emerald-600">
|
||||
<svg class="h-3.5 w-3.5 shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" /></svg>
|
||||
{{ $t('admin.schedule.notified') }}
|
||||
</span>
|
||||
<span v-else-if="r.wecom_notify_error" class="text-xs text-amber-500" :title="r.wecom_notify_error">{{ $t('admin.schedule.notifyError') }}</span>
|
||||
<span v-else-if="r.wecom_notify_error" class="whitespace-nowrap text-xs text-amber-500" :title="r.wecom_notify_error">{{ $t('admin.schedule.notifyError') }}</span>
|
||||
<span v-else class="text-xs text-slate-300">-</span>
|
||||
</td>
|
||||
<td class="px-4 py-2.5">
|
||||
<td class="whitespace-nowrap px-4 py-2.5">
|
||||
<div class="flex items-center">
|
||||
<a
|
||||
v-if="r.total_count > 0"
|
||||
href="#"
|
||||
@click.prevent="downloadScheduleExcel(r.id)"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-slate-200 px-2 py-1 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-lg border border-slate-200 px-2 py-1 text-xs font-medium text-slate-600 transition-colors hover:bg-slate-50"
|
||||
>
|
||||
<Download class="h-3 w-3" />
|
||||
<Download class="h-3 w-3 shrink-0" />
|
||||
{{ $t('admin.schedule.download') }}
|
||||
</a>
|
||||
<span v-if="r.total_count === 0" class="text-slate-300">-</span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-2.5">
|
||||
<td class="whitespace-nowrap px-4 py-2.5">
|
||||
<div class="flex items-center">
|
||||
<button
|
||||
v-if="(r.step_logs && r.step_logs.length > 0) || r.dify_execution_snapshot"
|
||||
@click="expandedScheduleRunId = expandedScheduleRunId === r.id ? null : r.id"
|
||||
class="inline-flex items-center gap-1 rounded-lg border border-blue-200 px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50"
|
||||
class="inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded-lg border border-blue-200 px-2 py-1 text-xs font-medium text-blue-600 transition-colors hover:bg-blue-50"
|
||||
>
|
||||
<Eye class="h-3 w-3" />
|
||||
<Eye class="h-3 w-3 shrink-0" />
|
||||
{{ $t('admin.schedule.log') }}
|
||||
<ChevronDown v-if="expandedScheduleRunId !== r.id" class="h-3 w-3" />
|
||||
<ChevronUp v-else class="h-3 w-3" />
|
||||
<ChevronDown v-if="expandedScheduleRunId !== r.id" class="h-3 w-3 shrink-0" />
|
||||
<ChevronUp v-else class="h-3 w-3 shrink-0" />
|
||||
</button>
|
||||
<span v-else class="text-slate-300">-</span>
|
||||
</div>
|
||||
|
||||
+158
-26
@@ -23,8 +23,10 @@ import GeneralFeedbackDialog from '../components/GeneralFeedbackDialog.vue';
|
||||
import { useMessage } from '../composables/useMessage';
|
||||
import { useIsMobile } from '../composables/useIsMobile';
|
||||
import { useTheme } from '../composables/useTheme';
|
||||
import { getAuthHeaders, getStoredAuthUser, clearAuthUser } from '../utils/auth';
|
||||
import { getAuthHeaders, getStoredAuthUser, logoutAuth } from '../utils/auth';
|
||||
import { copyTextToClipboard } from '../utils/clipboard';
|
||||
import { setLastChatAgentId } from '../utils/lastChatAgent';
|
||||
import { openAgentChatTab, registerOpenAgentId } from '../utils/agentTabs';
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { appliedTheme, toggleLightDark } = useTheme();
|
||||
@@ -95,8 +97,13 @@ const handleDocumentPointerDown = (event: MouseEvent | TouchEvent) => {
|
||||
}
|
||||
};
|
||||
|
||||
const onAuthLogout = () => {
|
||||
currentUser.value = null;
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
clearAuthUser();
|
||||
logoutAuth();
|
||||
onAuthLogout();
|
||||
router.push('/');
|
||||
};
|
||||
|
||||
@@ -916,6 +923,10 @@ const parseDateTime = (value: string) => {
|
||||
return Number.isNaN(date.getTime()) ? null : date;
|
||||
};
|
||||
|
||||
const LEAVE_TYPE_BY_DAY = new Set(['010', '007', '401', '402', '403', '406', 'ZZ07', 'ZZ08', 'ZZ09', 'ZZ10']);
|
||||
|
||||
const isLeaveTypeByDay = (leaveType: string) => LEAVE_TYPE_BY_DAY.has(leaveType);
|
||||
|
||||
const calculateDurationHours = (startTime: string, endTime: string) => {
|
||||
const start = parseDateTime(startTime);
|
||||
const end = parseDateTime(endTime);
|
||||
@@ -923,8 +934,12 @@ const calculateDurationHours = (startTime: string, endTime: string) => {
|
||||
return Number((((end.getTime() - start.getTime()) / 1000 / 60 / 60)).toFixed(2));
|
||||
};
|
||||
|
||||
const formatDurationLabel = (hours: number) => {
|
||||
if (!hours) return `0 ${t('chat.hourUnit')}`;
|
||||
const formatDurationLabel = (hours: number, leaveType?: string) => {
|
||||
if (!hours) return `0 ${isLeaveTypeByDay(leaveType || '') ? t('chat.dayUnit') : t('chat.hourUnit')}`;
|
||||
if (isLeaveTypeByDay(leaveType || '')) {
|
||||
const days = Math.round(hours / 8);
|
||||
return `${days} ${t('chat.dayUnit')}`;
|
||||
}
|
||||
return `${hours} ${t('chat.hourUnit')}`;
|
||||
};
|
||||
|
||||
@@ -1062,7 +1077,18 @@ const extractLeaveInfoFromIntent = (content: string): ExtractedLeaveInfo | null
|
||||
}
|
||||
|
||||
if (startTime && endTime) {
|
||||
durationHours = durationHours || calculateDurationHours(startTime, endTime);
|
||||
if (isLeaveTypeByDay(leaveType)) {
|
||||
const s = parseDateTime(startTime);
|
||||
const e = parseDateTime(endTime);
|
||||
if (s && e && e.getTime() > s.getTime()) {
|
||||
const sd = new Date(s.getFullYear(), s.getMonth(), s.getDate());
|
||||
const ed = new Date(e.getFullYear(), e.getMonth(), e.getDate());
|
||||
const days = Math.max(1, Math.round((ed.getTime() - sd.getTime()) / (24 * 3600 * 1000)) + 1);
|
||||
durationHours = days * 8;
|
||||
}
|
||||
} else {
|
||||
durationHours = durationHours || calculateDurationHours(startTime, endTime);
|
||||
}
|
||||
}
|
||||
|
||||
if (!leaveType && !startTime) return null;
|
||||
@@ -1077,13 +1103,31 @@ const extractLeaveInfoFromIntent = (content: string): ExtractedLeaveInfo | null
|
||||
|
||||
const createLeaveFormData = (content?: string, extractedInfo?: ExtractedLeaveInfo | null): LeaveRequestFormData => {
|
||||
const now = new Date();
|
||||
const initialLeaveType = extractedInfo?.leaveType || extractLeaveTypeFromIntent(content || '');
|
||||
const isByDay = isLeaveTypeByDay(initialLeaveType);
|
||||
const sameDayEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 18, 0);
|
||||
const oneHourLater = new Date(now.getTime() + 60 * 60 * 1000);
|
||||
const defaultStart = formatDateTime(now);
|
||||
const defaultEnd = formatDateTime(oneHourLater);
|
||||
const initialLeaveType = extractedInfo?.leaveType || extractLeaveTypeFromIntent(content || '');
|
||||
const defaultEnd = isByDay ? formatDateTime(sameDayEnd) : formatDateTime(oneHourLater);
|
||||
const startTime = extractedInfo?.startTime || defaultStart;
|
||||
const endTime = extractedInfo?.endTime || defaultEnd;
|
||||
const durationHours = extractedInfo?.durationHours || calculateDurationHours(startTime, endTime);
|
||||
let durationHours: number;
|
||||
if (isByDay) {
|
||||
const start = parseDateTime(startTime);
|
||||
const end = parseDateTime(endTime);
|
||||
if (start && end && end.getTime() > start.getTime()) {
|
||||
const startDate = new Date(start.getFullYear(), start.getMonth(), start.getDate());
|
||||
const endDate = new Date(end.getFullYear(), end.getMonth(), end.getDate());
|
||||
const days = Math.max(1, Math.round((endDate.getTime() - startDate.getTime()) / (24 * 3600 * 1000)) + 1);
|
||||
durationHours = days * 8;
|
||||
} else {
|
||||
durationHours = 8;
|
||||
}
|
||||
} else if (extractedInfo?.durationHours) {
|
||||
durationHours = extractedInfo.durationHours;
|
||||
} else {
|
||||
durationHours = calculateDurationHours(startTime, endTime);
|
||||
}
|
||||
return {
|
||||
applicantName: currentUserDisplayName.value,
|
||||
employeeId: currentUserEmployeeId.value,
|
||||
@@ -1108,7 +1152,20 @@ const newLocalMessageId = (prefix: string) => {
|
||||
};
|
||||
|
||||
const syncLeaveDuration = (form: LeaveRequestFormData) => {
|
||||
form.durationHours = calculateDurationHours(form.startTime, form.endTime);
|
||||
if (isLeaveTypeByDay(form.leaveType)) {
|
||||
const start = parseDateTime(form.startTime);
|
||||
const end = parseDateTime(form.endTime);
|
||||
if (!start || !end || end.getTime() <= start.getTime()) {
|
||||
form.durationHours = 0;
|
||||
return;
|
||||
}
|
||||
const startDate = new Date(start.getFullYear(), start.getMonth(), start.getDate());
|
||||
const endDate = new Date(end.getFullYear(), end.getMonth(), end.getDate());
|
||||
const days = Math.max(1, Math.round((endDate.getTime() - startDate.getTime()) / (24 * 3600 * 1000)) + 1);
|
||||
form.durationHours = days * 8;
|
||||
} else {
|
||||
form.durationHours = calculateDurationHours(form.startTime, form.endTime);
|
||||
}
|
||||
};
|
||||
|
||||
const getLeaveIntentNormalized = (content: string) => (content || '').replace(/\s+/g, '');
|
||||
@@ -1598,12 +1655,13 @@ const validateLeaveForm = (form: LeaveRequestFormData) => {
|
||||
if (!form.agentUid.trim()) return t('chat.leaveAgentRequired');
|
||||
if (!parseDateTime(form.startTime)) return t('chat.startTimeRequired');
|
||||
if (!parseDateTime(form.endTime)) return t('chat.endTimeRequired');
|
||||
if (calculateDurationHours(form.startTime, form.endTime) <= 0) return t('chat.durationInvalid');
|
||||
syncLeaveDuration(form);
|
||||
if (form.durationHours <= 0) return t('chat.durationInvalid');
|
||||
return '';
|
||||
};
|
||||
|
||||
const submitLeaveForm = (msg: any) => {
|
||||
const payload = getLeaveFormPayload(msg);
|
||||
const submitLeaveForm = async (chatMsg: any) => {
|
||||
const payload = getLeaveFormPayload(chatMsg);
|
||||
if (!payload) return;
|
||||
syncLeaveDuration(payload.form);
|
||||
const error = validateLeaveForm(payload.form);
|
||||
@@ -1612,6 +1670,26 @@ const submitLeaveForm = (msg: any) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NEED_BALANCE_CHECK_TYPES.has(payload.form.leaveType)) {
|
||||
const balance = await checkLeaveBalance(payload.form.leaveType);
|
||||
if (balance && balance.remaining_hours !== null && balance.remaining_hours !== undefined) {
|
||||
const requestedHours = payload.form.durationHours;
|
||||
if (requestedHours > balance.remaining_hours) {
|
||||
const isByDay = isLeaveTypeByDay(payload.form.leaveType);
|
||||
const unit = isByDay ? t('chat.dayUnit') : t('chat.hourUnit');
|
||||
const requestedDisplay = isByDay ? Math.round(requestedHours / 8) : requestedHours;
|
||||
const remainingDisplay = isByDay ? Math.round(balance.remaining_hours / 8) : balance.remaining_hours;
|
||||
const label = getLeaveTypeLabel(payload.form.leaveType);
|
||||
msg.warning(t('chat.durationExceedsBalance', {
|
||||
label,
|
||||
requested: `${requestedDisplay}${unit}`,
|
||||
remaining: `${remainingDisplay}${unit}`,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const existingConfirmIndex = messages.value.findIndex((item: any) => item?.type === 'leave-confirmation' && item?.payload?.formId === payload.formId);
|
||||
if (existingConfirmIndex >= 0) {
|
||||
messages.value.splice(existingConfirmIndex, 1);
|
||||
@@ -1633,13 +1711,12 @@ const submitLeaveForm = (msg: any) => {
|
||||
};
|
||||
messages.value.push(confirmMsg);
|
||||
|
||||
// 保存更新后的表单消息和新的确认消息
|
||||
saveLocalMessageToBackend(msg);
|
||||
saveLocalMessageToBackend(chatMsg);
|
||||
saveLocalMessageToBackend(confirmMsg);
|
||||
};
|
||||
|
||||
const editLeaveConfirmation = (msg: any, index: number) => {
|
||||
const payload = getLeaveConfirmationPayload(msg);
|
||||
const editLeaveConfirmation = (chatMsg: any, index: number) => {
|
||||
const payload = getLeaveConfirmationPayload(chatMsg);
|
||||
if (!payload) return;
|
||||
const sourceIndex = findMessageIndexByLocalId(payload.formId);
|
||||
if (sourceIndex >= 0) {
|
||||
@@ -1657,9 +1734,30 @@ const editLeaveConfirmation = (msg: any, index: number) => {
|
||||
messages.value.splice(index, 1);
|
||||
};
|
||||
|
||||
const confirmLeaveSubmission = async (msg: any) => {
|
||||
const payload = getLeaveConfirmationPayload(msg);
|
||||
const confirmLeaveSubmission = async (chatMsg: any) => {
|
||||
const payload = getLeaveConfirmationPayload(chatMsg);
|
||||
if (!payload || payload.submitting) return;
|
||||
|
||||
if (NEED_BALANCE_CHECK_TYPES.has(payload.form.leaveType)) {
|
||||
const balance = await checkLeaveBalance(payload.form.leaveType);
|
||||
if (balance && balance.remaining_hours !== null && balance.remaining_hours !== undefined) {
|
||||
const requestedHours = payload.form.durationHours;
|
||||
if (requestedHours > balance.remaining_hours) {
|
||||
const isByDay = isLeaveTypeByDay(payload.form.leaveType);
|
||||
const unit = isByDay ? t('chat.dayUnit') : t('chat.hourUnit');
|
||||
const requestedDisplay = isByDay ? Math.round(requestedHours / 8) : requestedHours;
|
||||
const remainingDisplay = isByDay ? Math.round(balance.remaining_hours / 8) : balance.remaining_hours;
|
||||
const label = getLeaveTypeLabel(payload.form.leaveType);
|
||||
msg.warning(t('chat.durationExceedsBalance', {
|
||||
label,
|
||||
requested: `${requestedDisplay}${unit}`,
|
||||
remaining: `${remainingDisplay}${unit}`,
|
||||
}));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
payload.submitting = true;
|
||||
|
||||
const sourceIndex = findMessageIndexByLocalId(payload.formId);
|
||||
@@ -1701,8 +1799,8 @@ const confirmLeaveSubmission = async (msg: any) => {
|
||||
};
|
||||
messages.value.push(resultMsg);
|
||||
payload.confirmed = true;
|
||||
payload.submitting = false; // Add this line to immediately clear submitting state on success
|
||||
saveLocalMessageToBackend(msg);
|
||||
payload.submitting = false;
|
||||
saveLocalMessageToBackend(chatMsg);
|
||||
saveLocalMessageToBackend(resultMsg);
|
||||
} catch (error: any) {
|
||||
const errorMessage = error?.message || t('chat.oaLeaveSubmitFailed');
|
||||
@@ -1876,18 +1974,40 @@ const loadUserAgents = async () => {
|
||||
|
||||
const switchToAgent = (agent: { id: number; name: string }) => {
|
||||
if (agent.id === agentId) return;
|
||||
setLastChatAgentId(agent.id);
|
||||
const url = router.resolve(`/chat/${agent.id}`).href;
|
||||
window.open(url, '_blank');
|
||||
openAgentChatTab(url, agent.id);
|
||||
};
|
||||
|
||||
const syncOpenAgentRegistration = () => {
|
||||
const id = Number(route.params.agentId);
|
||||
registerOpenAgentId(Number.isFinite(id) && id > 0 ? id : null);
|
||||
};
|
||||
|
||||
const onPageHide = () => {
|
||||
registerOpenAgentId(null);
|
||||
};
|
||||
|
||||
const goToWorkspace = (view?: string) => {
|
||||
setLastChatAgentId(Number(route.params.agentId));
|
||||
registerOpenAgentId(null);
|
||||
const query: Record<string, string> = { no_redirect: '1' };
|
||||
if (view) query.view = view;
|
||||
router.push({ path: '/workspace', query });
|
||||
};
|
||||
|
||||
// 组件挂载时,如果存在预设问题,则自动触发一次发送
|
||||
onMounted(async () => {
|
||||
syncOpenAgentRegistration();
|
||||
window.addEventListener('pagehide', onPageHide);
|
||||
window.addEventListener('hxops:logout', onAuthLogout);
|
||||
document.addEventListener('mousedown', handleDocumentPointerDown);
|
||||
document.addEventListener('touchstart', handleDocumentPointerDown, { passive: true });
|
||||
document.addEventListener('mousedown', handleMobileAgentPopoverClickOutside);
|
||||
document.addEventListener('touchstart', handleMobileAgentPopoverClickOutside, { passive: true });
|
||||
window.addEventListener('resize', syncViewportWidth);
|
||||
await syncCurrentUserProfile();
|
||||
setLastChatAgentId(Number(route.params.agentId));
|
||||
await loadAgent();
|
||||
await loadUserAgents();
|
||||
|
||||
@@ -1907,7 +2027,18 @@ onMounted(async () => {
|
||||
scheduleScrollChatToBottom();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route.params.agentId,
|
||||
(id) => {
|
||||
const nextId = Number(id);
|
||||
if (Number.isFinite(nextId) && nextId > 0) setLastChatAgentId(nextId);
|
||||
syncOpenAgentRegistration();
|
||||
}
|
||||
);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('pagehide', onPageHide);
|
||||
window.removeEventListener('hxops:logout', onAuthLogout);
|
||||
document.removeEventListener('mousedown', handleDocumentPointerDown);
|
||||
document.removeEventListener('touchstart', handleDocumentPointerDown);
|
||||
document.removeEventListener('mousedown', handleMobileAgentPopoverClickOutside);
|
||||
@@ -1983,7 +2114,7 @@ const showChatRating = ref(false);
|
||||
{{ (currentUser?.username || 'I').charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><MessageSquareText class="h-5 w-5" /></button>
|
||||
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('workspace.title')"><Briefcase class="h-5 w-5" /></button>
|
||||
<button @click="goToWorkspace()" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('workspace.title')"><Briefcase class="h-5 w-5" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -2104,7 +2235,7 @@ const showChatRating = ref(false);
|
||||
<Moon v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<button @click="showGeneralFeedbackDialog = true" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('chat.generalFeedback')"><MessageSquareText class="h-4 w-4" /></button>
|
||||
<button @click="router.push('/workspace?no_redirect=1')" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('workspace.title')"><Briefcase class="h-4 w-4" /></button>
|
||||
<button @click="goToWorkspace()" class="transition-colors hover:text-slate-600 dark:hover:text-slate-200" :title="$t('workspace.title')"><Briefcase class="h-4 w-4" /></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2122,7 +2253,7 @@ const showChatRating = ref(false);
|
||||
<button @click="toggleMobileAgentPopover" 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="$t('chat.agents')">
|
||||
<LayoutGrid class="h-5 w-5" />
|
||||
</button>
|
||||
<button @click="router.push('/workspace?view=history')" 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="$t('chat.history')">
|
||||
<button @click="goToWorkspace('history')" 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="$t('chat.history')">
|
||||
<History class="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
@@ -2236,6 +2367,7 @@ const showChatRating = ref(false);
|
||||
v-model="getLeaveFormPayload(msg)!.form.leaveType"
|
||||
class="w-full rounded-xl border border-slate-200 px-3 py-2 text-sm text-slate-700 outline-none transition focus:border-blue-400 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-100"
|
||||
:disabled="getLeaveFormPayload(msg)!.submitting || getLeaveFormPayload(msg)!.confirmationGenerated"
|
||||
@change="syncLeaveDuration(getLeaveFormPayload(msg)!.form)"
|
||||
>
|
||||
<option value="" disabled>{{ $t('chat.selectLeaveType') }}</option>
|
||||
<option v-for="leaveType in LEAVE_TYPES" :key="leaveType.value" :value="leaveType.value">{{ leaveType.label }}</option>
|
||||
@@ -2310,7 +2442,7 @@ const showChatRating = ref(false);
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-slate-500 dark:text-slate-400">{{ $t('chat.duration') }}</span>
|
||||
<input
|
||||
:value="formatDurationLabel(getLeaveFormPayload(msg)!.form.durationHours)"
|
||||
:value="formatDurationLabel(getLeaveFormPayload(msg)!.form.durationHours, getLeaveFormPayload(msg)!.form.leaveType)"
|
||||
type="text"
|
||||
class="w-full rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm text-slate-500 outline-none dark:border-slate-700 dark:bg-slate-950/60 dark:text-slate-400"
|
||||
disabled
|
||||
@@ -2379,7 +2511,7 @@ const showChatRating = ref(false);
|
||||
<div v-if="getLeaveConfirmationPayload(msg)!.form.agentDepartmentName || getLeaveConfirmationPayload(msg)!.form.agentDepartmentId"><span class="text-slate-500 dark:text-slate-400">{{ $t('chat.leaveAgentDept') }}:</span>{{ getLeaveConfirmationPayload(msg)!.form.agentDepartmentName || getLeaveConfirmationPayload(msg)!.form.agentDepartmentId }}</div>
|
||||
<div v-if="getLeaveConfirmationPayload(msg)!.form.agentSubCompanyName || getLeaveConfirmationPayload(msg)!.form.agentSubCompanyId1"><span class="text-slate-500 dark:text-slate-400">{{ $t('chat.leaveAgentCompany') }}:</span>{{ getLeaveConfirmationPayload(msg)!.form.agentSubCompanyName || getLeaveConfirmationPayload(msg)!.form.agentSubCompanyId1 }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">{{ $t('chat.leaveType') }}:</span>{{ getLeaveTypeLabel(getLeaveConfirmationPayload(msg)!.form.leaveType) }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">{{ $t('chat.duration') }}:</span>{{ formatDurationLabel(getLeaveConfirmationPayload(msg)!.form.durationHours) }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">{{ $t('chat.duration') }}:</span>{{ formatDurationLabel(getLeaveConfirmationPayload(msg)!.form.durationHours, getLeaveConfirmationPayload(msg)!.form.leaveType) }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">{{ $t('chat.startTime') }}:</span>{{ getLeaveConfirmationPayload(msg)!.form.startTime.replace('T', ' ') }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">{{ $t('chat.endTime') }}:</span>{{ getLeaveConfirmationPayload(msg)!.form.endTime.replace('T', ' ') }}</div>
|
||||
<div><span class="text-slate-500 dark:text-slate-400">{{ $t('chat.isOutOfOffice') }}:</span>{{ formatYesNoLabel(getLeaveConfirmationPayload(msg)!.form.isOutOfOffice) }}</div>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* 文件用途:用户工作台,支持自定义布局、收藏、嵌入 Agent
|
||||
* 引用文件:vue, vue-router, lucide-vue-next, 后端 /api/user 接口
|
||||
*/
|
||||
import { ref, onMounted, computed, watch, nextTick } from 'vue';
|
||||
import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { config } from '../config';
|
||||
@@ -24,7 +24,9 @@ import {
|
||||
type WecomLoginDialogContent,
|
||||
type WecomMatchField,
|
||||
} from '../utils/wecom';
|
||||
import { getAuthHeaders, getStoredAuthUser, saveAuthUser } from '../utils/auth';
|
||||
import { getAuthHeaders, getStoredAuthUser, saveAuthUser, logoutAuth } from '../utils/auth';
|
||||
import { getLastChatAgentId } from '../utils/lastChatAgent';
|
||||
import { openAgentChatTab } from '../utils/agentTabs';
|
||||
import {
|
||||
Settings,
|
||||
LayoutGrid,
|
||||
@@ -404,7 +406,10 @@ const loadAuthUser = () => {
|
||||
stored = sessionStorage.getItem('hxops_user');
|
||||
}
|
||||
|
||||
if (!stored) return;
|
||||
if (!stored) {
|
||||
currentUser.value = null;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const user = getStoredAuthUser();
|
||||
@@ -846,10 +851,7 @@ const mobileTabTitle = computed(() => {
|
||||
return t('workspace.mobileTabs.applications');
|
||||
});
|
||||
|
||||
const handleLogout = () => {
|
||||
localStorage.removeItem('hxops_user');
|
||||
sessionStorage.removeItem('hxops_user');
|
||||
sessionStorage.removeItem('hxops_wecom_state');
|
||||
const applyLoggedOutState = () => {
|
||||
currentUser.value = null;
|
||||
agents.value = [];
|
||||
quickQuestions.value = [];
|
||||
@@ -857,9 +859,18 @@ const handleLogout = () => {
|
||||
embeddedAgents.value = [];
|
||||
userReport.value = null;
|
||||
fetchPublicAgents();
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
logoutAuth();
|
||||
applyLoggedOutState();
|
||||
router.push('/');
|
||||
};
|
||||
|
||||
const onAuthLogout = () => {
|
||||
applyLoggedOutState();
|
||||
};
|
||||
|
||||
const captureOriginalProfile = () => {
|
||||
originalProfile.value = { ...profileUser.value };
|
||||
};
|
||||
@@ -1163,7 +1174,7 @@ const loadChatHistories = async () => {
|
||||
};
|
||||
|
||||
const navigateToGeneralChat = () => {
|
||||
router.push(`/chat/${DEFAULT_POST_LOGIN_AGENT_ID}`);
|
||||
router.push(`/chat/${getLastChatAgentId(DEFAULT_POST_LOGIN_AGENT_ID)}`);
|
||||
};
|
||||
|
||||
const openAdminPanel = () => {
|
||||
@@ -1177,7 +1188,7 @@ const navigateToChat = (id: number) => {
|
||||
return;
|
||||
}
|
||||
const url = router.resolve(`/chat/${id}`).href;
|
||||
window.open(url, '_blank');
|
||||
openAgentChatTab(url, id);
|
||||
};
|
||||
|
||||
const navigateWithQuickQuestion = (agentId: number, question: string) => {
|
||||
@@ -1190,7 +1201,7 @@ const navigateWithQuickQuestion = (agentId: number, question: string) => {
|
||||
path: `/chat/${agentId}`,
|
||||
query: { preset: question },
|
||||
}).href;
|
||||
window.open(url, '_blank');
|
||||
openAgentChatTab(url, agentId);
|
||||
};
|
||||
|
||||
const handleWecomDeeplinkContext = async () => {
|
||||
@@ -1223,7 +1234,7 @@ const handleWecomDeeplinkContext = async () => {
|
||||
path: `/chat/${agentId}`,
|
||||
query: preset ? { preset } : {},
|
||||
}).href;
|
||||
window.open(url, '_blank');
|
||||
openAgentChatTab(url, agentId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1361,6 +1372,7 @@ const openAnnouncement = (ann: Announcement) => {
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
window.addEventListener('hxops:logout', onAuthLogout);
|
||||
loadLanguagePreference();
|
||||
fetchAnnouncements();
|
||||
const handledCasdoor = await tryCasdoorCallbackLogin();
|
||||
@@ -1391,6 +1403,10 @@ onMounted(async () => {
|
||||
isLoading.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('hxops:logout', onAuthLogout);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -1553,7 +1569,7 @@ onMounted(async () => {
|
||||
<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">
|
||||
<div class="flex items-center gap-2">
|
||||
<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="$t('workspace.nav.backToChat')">AI</button>
|
||||
<button @click="navigateToGeneralChat" 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="$t('workspace.nav.backToChat')">AI</button>
|
||||
<span class="text-sm font-semibold text-slate-800 dark:text-slate-100">{{ mobileTabTitle }}</span>
|
||||
</div>
|
||||
</header>
|
||||
@@ -1929,44 +1945,44 @@ onMounted(async () => {
|
||||
<div v-if="workspaceScheduleLoading" class="rounded-2xl border border-dashed border-slate-200 py-10 text-center text-sm text-slate-400 dark:border-slate-800 dark:text-slate-500">{{ $t('workspace.schedule.loading') }}</div>
|
||||
<div v-else-if="workspaceScheduleRuns.length === 0" class="rounded-2xl border border-dashed border-slate-200 py-10 text-center text-sm text-slate-400 dark:border-slate-800 dark:text-slate-500">{{ $t('workspace.schedule.empty') }}</div>
|
||||
<div v-else class="overflow-hidden rounded-2xl border border-slate-200 bg-white dark:border-slate-700 dark:bg-slate-800">
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full text-sm">
|
||||
<thead>
|
||||
<tr class="border-b border-slate-100 bg-slate-50/60 dark:border-slate-700 dark:bg-slate-900/60">
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.name') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.runNo') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.triggerType') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.start') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.end') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.duration') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.status') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.total') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.success') }}</th>
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.failed') }}</th>
|
||||
<div class="max-h-[calc(100vh-17rem)] overflow-auto scrollbar-thin">
|
||||
<table class="w-full min-w-[1080px] text-sm">
|
||||
<thead class="sticky top-0 z-10">
|
||||
<tr class="border-b border-slate-100 bg-slate-50 dark:border-slate-700 dark:bg-slate-900">
|
||||
<th class="min-w-[120px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.name') }}</th>
|
||||
<th class="min-w-[168px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.runNo') }}</th>
|
||||
<th class="min-w-[72px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.triggerType') }}</th>
|
||||
<th class="min-w-[152px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.start') }}</th>
|
||||
<th class="min-w-[152px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.end') }}</th>
|
||||
<th class="min-w-[64px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.duration') }}</th>
|
||||
<th class="min-w-[88px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.status') }}</th>
|
||||
<th class="min-w-[72px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.total') }}</th>
|
||||
<th class="min-w-[72px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.success') }}</th>
|
||||
<th class="min-w-[72px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.failed') }}</th>
|
||||
|
||||
<th class="px-4 py-3 text-left font-semibold text-slate-600 dark:text-slate-400">{{ $t('workspace.schedule.columns.detail') }}</th>
|
||||
<th class="min-w-[72px] whitespace-nowrap bg-slate-50 px-4 py-3 text-left font-semibold text-slate-600 dark:bg-slate-900 dark:text-slate-400">{{ $t('workspace.schedule.columns.detail') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="r in workspaceScheduleRuns" :key="r.id" class="border-b border-slate-50 transition-colors hover:bg-slate-50/50 dark:border-slate-700/80 dark:hover:bg-slate-700/40">
|
||||
<td class="px-4 py-3 font-medium text-slate-900 dark:text-slate-100">{{ r.schedule_name || '-' }}</td>
|
||||
<td class="px-4 py-3 font-mono text-xs text-slate-500 dark:text-slate-400">{{ r.run_no }}</td>
|
||||
<td class="px-4 py-3 text-slate-500 dark:text-slate-400">{{ r.trigger_type === 'manual' ? $t('workspace.schedule.trigger.manual') : r.trigger_type === 'test' ? $t('workspace.schedule.trigger.test') : $t('workspace.schedule.trigger.timed') }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 font-medium text-slate-900 dark:text-slate-100">{{ r.schedule_name || '-' }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 font-mono text-xs text-slate-500 dark:text-slate-400">{{ r.run_no }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-slate-500 dark:text-slate-400">{{ r.trigger_type === 'manual' ? $t('workspace.schedule.trigger.manual') : r.trigger_type === 'test' ? $t('workspace.schedule.trigger.test') : $t('workspace.schedule.trigger.timed') }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-slate-500 dark:text-slate-400">{{ formatDateTime(r.started_at) }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-slate-500 dark:text-slate-400">{{ formatDateTime(r.finished_at) }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-slate-500 dark:text-slate-400">{{ r.duration_ms != null ? (r.duration_ms >= 1000 ? (r.duration_ms / 1000).toFixed(1) + 's' : r.duration_ms + 'ms') : '-' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<td class="whitespace-nowrap px-4 py-3">
|
||||
<span class="inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-1 text-xs font-semibold" :class="getWsScheduleStatusBadge(r.status).cls">
|
||||
{{ getWsScheduleStatusBadge(r.status).label }}
|
||||
</span>
|
||||
<span v-if="r.error_message && r.error_message !== '无待处理数据'" class="ml-1 text-xs text-slate-400 dark:text-slate-500" :title="r.error_message">...</span>
|
||||
<span v-else-if="r.error_message === '无待处理数据'" class="ml-1 text-xs text-slate-400 dark:text-slate-500">({{ $t('workspace.schedule.noPendingData') }})</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-slate-500 dark:text-slate-400">{{ r.total_count || 0 }}</td>
|
||||
<td class="px-4 py-3 font-medium text-emerald-600 dark:text-emerald-400">{{ r.success_count ?? 0 }}</td>
|
||||
<td class="px-4 py-3 font-medium text-rose-600 dark:text-rose-400">{{ r.failed_count ?? 0 }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-slate-500 dark:text-slate-400">{{ r.total_count || 0 }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 font-medium text-emerald-600 dark:text-emerald-400">{{ r.success_count ?? 0 }}</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 font-medium text-rose-600 dark:text-rose-400">{{ r.failed_count ?? 0 }}</td>
|
||||
|
||||
<td class="px-4 py-3">
|
||||
<td class="whitespace-nowrap px-4 py-3">
|
||||
<a
|
||||
v-if="r.total_count > 0 && r.excel_file_name"
|
||||
href="#"
|
||||
|
||||
Reference in new issue
Block a user