refactor(chat + workspace): chat和workspace重构,子路由、懒加载等

This commit is contained in:
sophie committed 2026-06-10 16:39:05 +08:00
1 parent 0a647a0b79
commit 1f1f7236b0
57 files changed
+4356 -3798

No files matched your search

@@ -0,0 +1,12 @@
<script setup lang="ts">
/**
* features/workspace/pages/FeedbackPage.vue
* 意见反馈占位页;进入路由时由编排层打开 GeneralFeedbackDialog。
*/
</script>
<template>
<div class="flex flex-col items-center justify-center py-20 text-muted">
<p class="text-sm">{{ $t('workspace.nav.feedback') }}</p>
</div>
</template>
@@ -0,0 +1,10 @@
<script setup lang="ts">
/**
* @deprecated 请使用 @/features/chat/pages/HistoryPage.vue
*/
import HistoryPage from '@/features/chat/pages/HistoryPage.vue';
</script>
<template>
<HistoryPage />
</template>
@@ -0,0 +1,192 @@
<script setup lang="ts">
/**
* features/workspace/pages/HomePage.vue
* 应用管理 / 最近更新:收藏应用、快捷问题、嵌入 Agent、公告与应用列表。
*/
import { inject } from 'vue';
import {
LayoutGrid, Star, GripVertical, Plus, Trash2, Edit, ExternalLink,
Bot, Megaphone, ChevronDown, ChevronUp,
} from 'lucide-vue-next';
import { WORKSPACE_KEY } from '../composables/workspace.context';
const ws = inject(WORKSPACE_KEY)! as any;
</script>
<template>
<div v-if="ws.wecomEntryHint" class="rounded-2xl border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-700">
{{ ws.wecomEntryHint }}
</div>
<div
v-for="(section, index) in ws.layoutSections"
:id="`workspace-section-${section.id}`"
:key="section.id"
class="bg-transparent md:bg-surface md:rounded-3xl md:border md:border-subtle md:p-8 md:shadow-soft relative group transition-all scroll-mt-6"
:class="{ 'opacity-50 border-brand-300 border-dashed': ws.draggedSectionIndex === index }"
draggable="true"
@dragstart="ws.onDragStart(index)"
@dragover="ws.onDragOver"
@drop="ws.onDrop(index)"
>
<div class="absolute left-2 top-8 cursor-move opacity-0 group-hover:opacity-100 p-2 text-slate-300 hover:text-muted transition-opacity hidden md:block">
<GripVertical class="w-5 h-5" />
</div>
<div class="md:pl-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-lg md:text-xl font-semibold text-primary flex items-center gap-2.5 cursor-pointer select-none" @click="ws.toggleSectionCollapse(section)">
<div class="p-2 rounded-lg" :class="{
'bg-emerald-50 text-emerald-600': section.id === 'announcements',
'bg-yellow-50 text-yellow-600': section.id === 'favorites',
'bg-brand-50 text-brand-600': section.id === 'quick_questions',
'bg-purple-50 text-purple-600': section.id === 'embedded',
'bg-slate-100 text-secondary': section.id === 'all_agents'
}">
<component :is="section.id === 'announcements' ? Megaphone : (section.id === 'favorites' ? Star : (section.id === 'embedded' ? Bot : LayoutGrid))" class="w-5 h-5" />
</div>
{{ $t(ws.getSectionTitleKey(section.id)) }}
<component :is="section.collapsed ? ChevronDown : ChevronUp" class="w-4 h-4 text-muted" />
</h2>
<button v-if="section.id === 'quick_questions' && !ws.isAddingQuestion && !section.collapsed" @click="ws.openAddQuestionForm" class="btn-ghost text-sm text-brand-600 hover:text-brand-700 hover:bg-brand-50">
<Plus class="w-4 h-4" /> {{ $t('workspace.quickQuestions.add') }}
</button>
</div>
<div v-show="!section.collapsed" class="animate-fade-in">
<!-- Content: Announcements -->
<div v-if="section.id === 'announcements'">
<div v-if="ws.announcements.length === 0" class="text-muted text-sm italic py-8 text-center bg-surface-soft rounded-xl border border-dashed border-default">{{ $t('workspace.announcements.noData') }}</div>
<div v-else class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
<div
v-for="ann in ws.announcements"
:key="ann.id"
class="group border border-default rounded-2xl bg-surface p-5 hover:border-emerald-300 hover:shadow-md transition-all cursor-pointer"
@click="ws.openAnnouncement(ann)"
>
<div class="flex items-start justify-between gap-3 mb-2">
<h4 class="font-bold text-primary line-clamp-2 group-hover:text-emerald-700 transition-colors">{{ ann.title }}</h4>
<span class="text-[10px] font-semibold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-full whitespace-nowrap">{{ new Date(ann.created_at).toLocaleDateString() }}</span>
</div>
<p class="text-sm text-secondary line-clamp-3">{{ ann.content }}</p>
</div>
</div>
</div>
<!-- Content: Favorites -->
<div v-if="section.id === 'favorites'">
<div v-if="ws.favoriteAgents.length === 0" class="text-muted text-sm italic py-4 bg-surface-soft rounded-xl text-center border border-dashed border-default">{{ $t('workspace.noFavorites') }}</div>
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-6">
<div v-for="agent in ws.favoriteAgents" :key="agent.id" @click="ws.navigateToChat(agent.id)"
class="card p-4 sm:p-5 cursor-pointer relative group/card hover:-translate-y-1 hover:shadow-lg hover:border-brand-200 bg-gradient-to-br from-white to-slate-50/50">
<div class="w-8 h-8 sm:w-12 sm:h-12 bg-brand-100 rounded-xl flex items-center justify-center text-brand-600 mb-3 sm:mb-4 shadow-sm group-hover/card:scale-110 transition-transform duration-300">
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-5 h-5 sm:w-7 sm:h-7" />
<Bot v-else class="w-5 h-5 sm:w-7 sm:h-7" />
</div>
<div class="text-[15px] sm:text-base font-semibold text-primary mb-1 group-hover/card:text-brand-700 transition-colors truncate">{{ agent.name }}</div>
<div class="text-[13px] sm:text-xs text-muted truncate">{{ agent.description }}</div>
<button @click.stop="ws.toggleFavorite(agent.id)" class="absolute top-3 right-3 text-yellow-400 hover:text-yellow-500 hover:scale-110 transition-all opacity-0 group-hover/card:opacity-100">
<Star class="w-5 h-5 fill-current" />
</button>
</div>
</div>
</div>
<!-- Content: Quick Questions -->
<div v-if="section.id === 'quick_questions'">
<!-- Add Question Form -->
<div v-if="ws.isAddingQuestion" class="mb-6 p-6 bg-surface-soft border border-default rounded-2xl space-y-4 animate-fade-in">
<h3 class="font-bold text-primary">{{ ws.editingQuestionId ? $t('workspace.quickQuestions.edit') : $t('workspace.quickQuestions.addNew') }}</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-5">
<div class="space-y-1.5">
<label class="text-xs font-semibold text-muted uppercase">{{ $t('workspace.quickQuestions.fields.title') }}</label>
<input v-model="ws.newQuestion.title" class="input-field" :placeholder="$t('workspace.quickQuestions.fields.titlePlaceholder')" />
</div>
<div class="space-y-1.5">
<label class="text-xs font-semibold text-muted uppercase">{{ $t('workspace.quickQuestions.fields.targetAgent') }}</label>
<select v-model="ws.newQuestion.agent_id" class="input-field" :disabled="ws.agents.length === 0">
<option :value="null" disabled>{{ ws.agents.length === 0 ? $t('workspace.noAgents') : $t('workspace.quickQuestions.fields.selectAgent') }}</option>
<option v-for="agent in ws.agents" :key="agent.id" :value="agent.id">{{ agent.name }}</option>
</select>
</div>
<div class="col-span-1 md:col-span-2 space-y-1.5">
<label class="text-xs font-semibold text-muted uppercase">{{ $t('workspace.quickQuestions.fields.content') }}</label>
<textarea v-model="ws.newQuestion.question" rows="3" class="input-field" :placeholder="$t('workspace.quickQuestions.fields.contentPlaceholder')"></textarea>
</div>
</div>
<div class="flex justify-end gap-3 pt-2">
<button @click="ws.cancelAddQuestion" class="btn-secondary">{{ $t('workspace.cancel') }}</button>
<button @click="ws.saveQuickQuestion" class="btn-primary">{{ $t('workspace.save') }}</button>
</div>
</div>
<div v-if="ws.filteredQuickQuestions.length === 0 && !ws.isAddingQuestion" class="text-muted text-sm italic py-8 text-center bg-surface-soft rounded-xl border border-dashed border-default">{{ $t('workspace.quickQuestions.noDefined') }}</div>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
<div v-for="qq in ws.filteredQuickQuestions" :key="qq.id"
@click="ws.navigateWithQuickQuestion(qq.agent_id, qq.question)"
class="group/item p-4 bg-surface border border-default rounded-xl hover:border-brand-500 hover:shadow-md transition-all cursor-pointer flex flex-col gap-3 relative h-full">
<div class="flex justify-between items-start">
<h4 class="font-bold text-primary group-hover/item:text-brand-600 transition-colors">{{ qq.title }}</h4>
<span class="text-[10px] font-bold px-2 py-0.5 bg-slate-100 text-secondary rounded-full uppercase tracking-wide">
{{ ws.getAgentName(qq.agent_id) }}
</span>
</div>
<p class="text-sm text-secondary line-clamp-2 leading-relaxed">{{ qq.question }}</p>
<div class="absolute top-2 right-2 flex gap-1 opacity-0 group-hover/item:opacity-100 transition-opacity bg-surface/90 backdrop-blur-sm p-1 rounded-lg">
<button @click.stop="ws.editQuickQuestion(qq)" class="p-1.5 rounded-lg text-muted hover:text-brand-600 hover:bg-brand-50 transition-colors">
<Edit class="w-4 h-4" />
</button>
<button @click.stop="ws.removeQuickQuestion(qq.id)" class="p-1.5 rounded-lg text-muted hover:text-red-600 hover:bg-red-50 transition-colors">
<Trash2 class="w-4 h-4" />
</button>
</div>
</div>
</div>
</div>
<!-- Content: Embedded Agents -->
<div v-if="section.id === 'embedded'">
<div v-if="ws.embeddedAgents.length === 0" class="text-muted text-sm italic py-4 bg-surface-soft rounded-xl text-center border border-dashed border-default">{{ $t('workspace.embedded.noData') }}</div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div v-for="agent in ws.embeddedAgents" :key="agent.id" class="border border-default rounded-2xl overflow-hidden bg-surface shadow-sm hover:shadow-md transition-shadow h-[500px] flex flex-col">
<div class="bg-surface-soft px-4 py-3 text-sm font-bold text-secondary flex justify-between items-center border-b border-subtle">
<span>{{ agent.name }}</span>
<a :href="`/chat/${agent.id}`" target="_blank" class="text-brand-600 hover:text-brand-700 hover:bg-brand-50 p-1.5 rounded-lg transition-colors"><ExternalLink class="w-4 h-4"/></a>
</div>
<iframe v-if="agent.iframe_url" :src="agent.iframe_url" class="w-full flex-1 border-none bg-surface"></iframe>
<div v-else class="flex items-center justify-center flex-1 text-muted bg-surface-soft/50">{{ $t('workspace.embedded.noUrl') }}</div>
</div>
</div>
</div>
<!-- Content: All Agents -->
<div v-if="section.id === 'all_agents'">
<div class="mb-6">
<input v-model="ws.searchQuery" type="text" :placeholder="$t('workspace.search')" class="input-field max-w-md shadow-sm" />
</div>
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 sm:gap-6">
<div v-for="agent in ws.otherAgents" :key="agent.id"
@click="ws.navigateToChat(agent.id)"
class="card card-mobile-compact cursor-pointer relative group/card hover:-translate-y-1 hover:border-brand-200">
<div class="flex items-start justify-between mb-2 sm:mb-4">
<div class="w-8 h-8 sm:w-10 sm:h-10 bg-surface-soft rounded-xl flex items-center justify-center text-muted group-hover/card:bg-brand-50 group-hover/card:text-brand-600 transition-colors">
<img v-if="agent.icon_url" :src="agent.icon_url" class="w-4 h-4 sm:w-6 sm:h-6" />
<Bot v-else class="w-4 h-4 sm:w-6 sm:h-6" />
</div>
<button @click.stop="ws.toggleFavorite(agent.id)" class="text-slate-200 hover:text-yellow-400 transition-colors">
<Star class="w-5 h-5" :class="{ 'fill-yellow-400 text-yellow-400': ws.favoriteAgentIds.includes(agent.id) }" />
</button>
</div>
<h3 class="text-[15px] sm:text-base font-semibold text-primary mb-1 group-hover/card:text-brand-700 transition-colors line-clamp-1 sm:line-clamp-2 leading-tight">{{ agent.name }}</h3>
<p class="text-[13px] sm:text-xs text-muted line-clamp-1 sm:line-clamp-2 h-4 sm:h-8 leading-relaxed">{{ agent.description }}</p>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
@@ -0,0 +1,11 @@
<script setup lang="ts">
/**
* features/workspace/pages/KnowledgeBasePage.vue
* 知识库管理嵌入页,复用 KbWorkspaceView 的 embedded 模式。
*/
import KbWorkspaceView from '@/views/KbWorkspaceView.vue';
</script>
<template>
<KbWorkspaceView :embedded="true" />
</template>
@@ -0,0 +1,199 @@
<script setup lang="ts">
/**
* features/workspace/pages/ProfilePage.vue
* 个人中心:用户资料展示与编辑、语言/主题偏好、修改密码入口。
*/
import { inject } from 'vue';
import {
User, Mail, Building, CreditCard, Globe, Save, Palette,
} from 'lucide-vue-next';
import { WORKSPACE_KEY } from '../composables/workspace.context';
const ws = inject(WORKSPACE_KEY)! as any;
</script>
<template>
<div v-if="ws.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>
<div v-else class="space-y-6">
<div class="rounded-3xl border border-default bg-surface px-6 py-6 shadow-sm md:px-8">
<div class="flex flex-col gap-6 lg:flex-row lg:items-start lg:justify-between">
<div class="flex flex-1 flex-col gap-6 sm:flex-row sm:items-center sm:justify-start">
<div class="flex h-24 w-24 shrink-0 items-center justify-center rounded-full bg-brand-100 text-4xl font-bold text-brand-600" :class="ws.isMobile ? 'h-14 w-14 text-2xl' : ''">
{{ (ws.profileUser.real_name || ws.profileUser.username || 'U').charAt(0).toUpperCase() }}
</div>
<div class="grid flex-1 text-left" :class="ws.isMobile ? 'grid-cols-2 gap-x-4 gap-y-1' : 'grid-cols-1 gap-x-12 gap-y-3 sm:grid-cols-2'">
<div :class="ws.isMobile ? '' : ''">
<div :class="ws.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ ws.isMobile ? $t('profile.realName') : (ws.profileUser.username || '-') }}</div>
<div v-if="ws.isMobile" class="text-sm font-medium text-primary truncate">{{ ws.profileUser.real_name || ws.profileUser.username || '-' }}</div>
</div>
<div>
<div :class="ws.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ ws.isMobile ? $t('profile.employeeId') : (ws.profileUser.employee_id || '-') }}</div>
<div v-if="ws.isMobile" class="text-sm font-medium text-primary truncate">{{ ws.profileUser.employee_id || '-' }}</div>
</div>
<div>
<div :class="ws.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ ws.isMobile ? $t('profile.department') : (ws.profileUser.department || '-') }}</div>
<div v-if="ws.isMobile" class="text-sm font-medium text-primary truncate">{{ ws.profileUser.department || '-' }}</div>
</div>
<div>
<div :class="ws.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ ws.isMobile ? $t('profile.role') : (ws.profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User')) }}</div>
<div v-if="ws.isMobile" class="text-sm font-medium text-primary truncate">{{ ws.profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User') }}</div>
</div>
<div :class="ws.isMobile ? 'col-span-2' : 'sm:col-span-2'">
<div :class="ws.isMobile ? 'text-xs text-muted' : 'break-all text-lg font-semibold text-primary'">{{ ws.isMobile ? $t('profile.email') : (ws.profileUser.email || '-') }}</div>
<div v-if="ws.isMobile" class="text-sm font-medium text-primary truncate">{{ ws.profileUser.email || '-' }}</div>
</div>
</div>
</div>
<div v-if="!ws.isMobile" class="flex shrink-0 items-center gap-2 self-start lg:ml-6">
<button @click="ws.handleChangePasswordClick" class="btn-primary px-6 py-3 text-base">
{{ $t('profile.changePassword') }}
</button>
</div>
</div>
<div v-if="ws.isMobile" class="mt-4 flex items-center justify-center gap-4">
<button @click="ws.handleChangePasswordClick" class="btn-primary flex-1 py-2.5 text-sm text-center">
{{ $t('profile.changePassword') }}
</button>
<button @click="ws.handleLogout" class="btn-secondary flex-1 py-2.5 text-sm text-center text-red-600 hover:bg-red-50">
{{ $t('workspace.nav.logout') }}
</button>
</div>
</div>
<div class="space-y-6">
<div class="rounded-3xl border border-default bg-surface p-8 shadow-sm" :class="ws.isMobile ? 'p-4' : ''">
<div class="mb-8 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" :class="ws.isMobile ? 'mb-4 gap-2' : ''">
<div class="flex items-center" :class="ws.isMobile ? 'w-full justify-center gap-2' : ''">
<h3 class="flex items-center gap-3 text-3xl font-bold text-primary" :class="ws.isMobile ? 'text-lg gap-2' : ''">
<User class="h-6 w-6 text-brand-500" :class="ws.isMobile ? 'h-4 w-4' : ''" />
{{ $t('profile.basicInfo') }}
</h3>
<button v-if="ws.isMobile && !ws.isProfileEditing" @click="ws.startProfileEditing" class="btn-secondary px-3 py-1 text-xs">
{{ $t('profile.edit') }}
</button>
</div>
<p v-if="!ws.isMobile" class="mt-2 text-sm text-muted">
{{ ws.isProfileEditing ? $t('profile.directEditHint') : $t('profile.switchEditHint') }}
</p>
<div v-if="!ws.isMobile" class="flex items-center gap-2">
<button v-if="!ws.isProfileEditing" @click="ws.startProfileEditing" class="btn-secondary px-5 py-2.5 text-sm">
{{ $t('profile.edit') }}
</button>
<template v-else>
<button @click="ws.cancelProfileEditing" class="btn-secondary px-5 py-2.5 text-sm">
{{ $t('profile.cancel') || 'Cancel' }}
</button>
<button
@click="ws.saveProfile"
:disabled="ws.isProfileSaving || !ws.hasProfileUnsavedChanges"
class="btn-primary px-5 py-2.5 text-sm disabled:opacity-50 disabled:cursor-not-allowed"
>
<Save class="w-4 h-4" />
<span>{{ ws.isProfileSaving ? $t('profile.saving') : $t('workspace.save') }}</span>
</button>
</template>
</div>
</div>
<div class="grid grid-cols-1 gap-5 md:grid-cols-2" :class="ws.isMobile ? 'gap-3' : ''">
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="ws.isMobile ? 'text-xs mb-1' : ''">
<User class="h-4 w-4" /> {{ $t('profile.username') }}
</label>
<div class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="ws.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
{{ ws.profileUser.username || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="ws.isMobile ? 'text-xs mb-1' : ''">
<CreditCard class="h-4 w-4" /> {{ $t('profile.employeeId') }}
</label>
<input v-if="ws.isProfileEditing" v-model="ws.profileUser.employee_id" type="text" class="input-field" :class="ws.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="ws.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
{{ ws.profileUser.employee_id || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="ws.isMobile ? 'text-xs mb-1' : ''">
<User class="h-4 w-4" /> {{ $t('profile.realName') }}
</label>
<input v-if="ws.isProfileEditing" v-model="ws.profileUser.real_name" type="text" class="input-field" :class="ws.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="ws.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
{{ ws.profileUser.real_name || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="ws.isMobile ? 'text-xs mb-1' : ''">
<Building class="h-4 w-4" /> {{ $t('profile.department') }}
</label>
<input v-if="ws.isProfileEditing" v-model="ws.profileUser.department" type="text" class="input-field" :class="ws.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="ws.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
{{ ws.profileUser.department || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="ws.isMobile ? 'text-xs mb-1' : ''">
<Mail class="h-4 w-4" /> {{ $t('profile.email') }}
</label>
<input v-if="ws.isProfileEditing" v-model="ws.profileUser.email" type="email" class="input-field" :class="ws.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="ws.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
{{ ws.profileUser.email || '-' }}
</div>
</div>
<div>
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="ws.isMobile ? 'text-xs mb-1' : ''">
<Globe class="h-4 w-4" /> {{ $t('profile.phoneNumber') }}
</label>
<input v-if="ws.isProfileEditing" v-model="ws.profileUser.phone_number" type="text" class="input-field" :class="ws.isMobile ? 'h-10 text-sm' : 'h-[58px]'" />
<div v-else class="rounded-2xl border border-default bg-surface-soft px-4 py-4 text-lg font-medium text-secondary" :class="ws.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
{{ ws.profileUser.phone_number || '-' }}
</div>
</div>
</div>
</div>
<div class="rounded-3xl border border-default bg-surface p-8 shadow-sm">
<h3 class="mb-6 flex items-center gap-3 text-2xl font-bold text-primary">
<Palette class="h-5 w-5 text-brand-500" />
{{ $t('profile.preferences') }}
</h3>
<div class="grid grid-cols-1 gap-6 md:grid-cols-2">
<div>
<label class="mb-2 block text-sm font-medium text-muted">{{ $t('workspace.languageLabel') }}</label>
<select v-model="ws.profileUser.language" :disabled="!ws.isProfileEditing" class="input-field h-[58px]">
<option value="en">English</option>
<option value="zh-CN">{{ $t('workspace.lang.zhCN') }}</option>
<option value="zh-TW">{{ $t('workspace.lang.zhTW') }}</option>
<option value="th">ไทย</option>
</select>
</div>
<div>
<label class="mb-2 block text-sm font-medium text-muted">{{ $t('profile.theme') }}</label>
<div
class="segment-control segment-control--cols-3 segment-control--md"
role="radiogroup"
:aria-label="$t('profile.theme')"
>
<button
v-for="item in ws.themeOptions"
:key="item.value"
type="button"
role="radio"
:aria-checked="ws.profileUser.theme_preference === item.value"
:disabled="!ws.isProfileEditing"
class="segment-item"
:class="ws.profileUser.theme_preference === item.value ? 'segment-item--active' : ''"
@click="ws.profileUser.theme_preference = item.value"
>
{{ item.label() }}
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
@@ -0,0 +1,116 @@
<script setup lang="ts">
/**
* features/workspace/pages/ScheduleRunsPage.vue
* 排程执行记录:筛选、列表展示与结果 Excel 下载。
*/
import { inject } from 'vue';
import { RefreshCw, Search, Download } from 'lucide-vue-next';
import { WORKSPACE_KEY } from '../composables/workspace.context';
const ws = inject(WORKSPACE_KEY)! as any;
</script>
<template>
<div class="space-y-5 animate-fade-in-up">
<div class="flex items-center justify-between">
<h2 class="text-2xl font-bold text-primary">{{ $t('workspace.schedule.title') }}</h2>
<button
@click="ws.loadWorkspaceScheduleRuns"
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
>
<RefreshCw class="h-3.5 w-3.5" />
{{ $t('workspace.schedule.refresh') }}
</button>
</div>
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default/80 bg-surface/70 px-4 py-3 shadow-sm">
<div>
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.schedule.filters.name') }}</label>
<input type="text" v-model="ws.wsScheduleNameFilter" :placeholder="$t('workspace.schedule.filters.namePlaceholder')" :class="['!w-[150px]', ws.wsScheduleFilterInputClass]" />
</div>
<div>
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.schedule.filters.start') }}</label>
<input type="datetime-local" step="1" v-model="ws.wsScheduleStartedAfter" :class="['!w-[170px]', ws.wsScheduleFilterInputClass]" />
</div>
<div>
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.schedule.filters.end') }}</label>
<input type="datetime-local" step="1" v-model="ws.wsScheduleStartedBefore" :class="['!w-[170px]', ws.wsScheduleFilterInputClass]" />
</div>
<div>
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.schedule.filters.status') }}</label>
<select v-model="ws.wsScheduleStatusFilter" :class="['!w-[120px]', ws.wsScheduleFilterInputClass]">
<option v-for="o in ws.wsScheduleStatusOptions" :key="o.value" :value="o.value">{{ o.label }}</option>
</select>
</div>
<button
@click="ws.loadWorkspaceScheduleRuns"
class="inline-flex items-center gap-1 rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-brand-700"
>
<Search class="h-3.5 w-3.5" />
{{ $t('workspace.schedule.search') }}
</button>
<button
@click="ws.resetWsScheduleFilters"
class="rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary transition-colors hover:bg-surface-soft"
>
{{ $t('workspace.schedule.reset') }}
</button>
</div>
<div v-if="ws.workspaceScheduleLoading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">{{ $t('workspace.schedule.loading') }}</div>
<div v-else-if="ws.workspaceScheduleRuns.length === 0" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">{{ $t('workspace.schedule.empty') }}</div>
<div v-else class="overflow-hidden rounded-2xl border border-default bg-surface">
<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-subtle bg-surface-soft">
<th class="min-w-[120px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.name') }}</th>
<th class="min-w-[168px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.runNo') }}</th>
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.triggerType') }}</th>
<th class="min-w-[152px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.start') }}</th>
<th class="min-w-[152px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.end') }}</th>
<th class="min-w-[64px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.duration') }}</th>
<th class="min-w-[88px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.status') }}</th>
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.total') }}</th>
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.success') }}</th>
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.failed') }}</th>
<th class="min-w-[72px] whitespace-nowrap bg-surface-soft px-4 py-3 text-left font-semibold text-secondary">{{ $t('workspace.schedule.columns.detail') }}</th>
</tr>
</thead>
<tbody>
<tr v-for="r in ws.workspaceScheduleRuns" :key="r.id" class="border-b border-slate-50 transition-colors hover:bg-surface-soft/50">
<td class="whitespace-nowrap px-4 py-3 font-medium text-primary">{{ r.schedule_name || '-' }}</td>
<td class="whitespace-nowrap px-4 py-3 font-mono text-xs text-muted">{{ r.run_no }}</td>
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ 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-muted">{{ ws.formatDateTime(r.started_at) }}</td>
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ ws.formatDateTime(r.finished_at) }}</td>
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ r.duration_ms != null ? (r.duration_ms >= 1000 ? (r.duration_ms / 1000).toFixed(1) + 's' : r.duration_ms + 'ms') : '-' }}</td>
<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="ws.getWsScheduleStatusBadge(r.status).cls">
{{ ws.getWsScheduleStatusBadge(r.status).label }}
</span>
<span v-if="r.error_message && r.error_message !== '无待处理数据'" class="ml-1 text-xs text-muted" :title="r.error_message">...</span>
<span v-else-if="r.error_message === '无待处理数据'" class="ml-1 text-xs text-muted">({{ $t('workspace.schedule.noPendingData') }})</span>
</td>
<td class="whitespace-nowrap px-4 py-3 text-muted">{{ r.total_count || 0 }}</td>
<td class="whitespace-nowrap px-4 py-3 font-medium text-emerald-600">{{ r.success_count ?? 0 }}</td>
<td class="whitespace-nowrap px-4 py-3 font-medium text-rose-600">{{ r.failed_count ?? 0 }}</td>
<td class="whitespace-nowrap px-4 py-3">
<a
v-if="r.total_count > 0 && r.excel_file_name"
href="#"
@click.prevent="ws.downloadWsScheduleExcel(r.id)"
class="inline-flex items-center gap-1 rounded-lg border border-default px-2 py-1 text-xs font-medium text-secondary transition-colors hover:bg-surface-soft"
>
<Download class="h-3 w-3" />
{{ $t('workspace.schedule.download') }}
</a>
<span v-else class="text-xs text-slate-300">-</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
@@ -0,0 +1,11 @@
<script setup lang="ts">
/**
* features/workspace/pages/ShippingNoticePage.vue
* 货代发货通知嵌入页,复用 ShippingNoticeView 的 embedded 模式。
*/
import ShippingNoticeView from '@/views/ShippingNoticeView.vue';
</script>
<template>
<ShippingNoticeView :embedded="true" />
</template>