fix(auth): 重构登录认证,并支持跳转到关联服务如图纸标注
This commit is contained in:
1 parent
ce1fd59f61
commit
affe139bf9
51 files changed
+1939
-132
No files matched your search
@@ -2,6 +2,8 @@
|
||||
/**
|
||||
* App.vue
|
||||
* 根组件:主题初始化、全局消息弹窗、401 登出监听、html lang 与 i18n locale 同步。
|
||||
* 依赖:useTheme、useGlobalMessageDialog、auth、linked-nav.store。
|
||||
* 逻辑:已登录时预取关联服务侧栏入口,避免页面切换后入口后闪现。
|
||||
*/
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { watch, onMounted, onBeforeUnmount } from 'vue';
|
||||
@@ -11,6 +13,7 @@ import { useGlobalMessageDialog } from '@/shared/composables/useGlobalMessageDia
|
||||
import { useRouter } from 'vue-router';
|
||||
import { getAuthHeaders, logoutAuth } from '@/shared/utils/auth';
|
||||
import { isPublicPath } from '@/shared/constants/routes';
|
||||
import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store';
|
||||
|
||||
const router = useRouter();
|
||||
const { locale, t } = useI18n();
|
||||
@@ -64,18 +67,20 @@ watch(themePreference, (newTheme) => {
|
||||
|
||||
/**
|
||||
* 处理接口返回未登录状态,提示用户重新登录并清理失效的本地登录信息。
|
||||
* 核心逻辑:忽略可选的 SSO 应用目录请求;其余未授权请求统一展示易懂提示,再执行登出。
|
||||
* 核心逻辑:忽略可选的关联服务/SSO 目录请求;其余未授权请求统一展示易懂提示,再执行登出。
|
||||
* @param event - 包含请求地址和状态码的全局未授权事件。
|
||||
*/
|
||||
const onUnauthorized = (event: Event) => {
|
||||
const url = String((event as CustomEvent<{ url?: string }>).detail?.url || '');
|
||||
// 外部应用目录是可选导航能力,加载失败只能隐藏入口,不能清除有效 HXOPS 登录态。
|
||||
// 侧栏入口目录是可选导航能力,加载失败只能隐藏入口,不能清除有效 HXOPS 登录态。
|
||||
if (/\/api\/sso\/apps(?:\?|$)/.test(url)) return;
|
||||
if (/\/api\/linked-services(?:\?|$)/.test(url)) return;
|
||||
showMessageDialog('error', t('login.sessionExpiredHint'), t('login.sessionExpired'));
|
||||
logoutAuth();
|
||||
};
|
||||
|
||||
const onLogout = (event: Event) => {
|
||||
useLinkedNavStore().reset();
|
||||
const detail = (event as CustomEvent<{ remote?: boolean }>).detail;
|
||||
if (detail?.remote) {
|
||||
showMessageDialog('info', '您已在其他标签页退出登录');
|
||||
@@ -94,6 +99,8 @@ onMounted(async () => {
|
||||
|
||||
const headers = getAuthHeaders();
|
||||
if (Object.keys(headers).length > 0) {
|
||||
// 尽早预取侧栏关联服务,避免进入 Chat/工作台后入口后加载闪现。
|
||||
void useLinkedNavStore().ensureLoaded();
|
||||
try {
|
||||
const res = await fetch('/api/user/home', { headers });
|
||||
if (res.ok) {
|
||||
|
||||
@@ -45,6 +45,9 @@ const WecomSettingsPage = () => import("@/features/admin/modules/wecom/pages/Wec
|
||||
const WecomBindingsPage = () => import("@/features/admin/modules/wecom/pages/WecomBindingsPage.vue");
|
||||
const WecomAuditsPage = () => import("@/features/admin/modules/wecom/pages/WecomAuditsPage.vue");
|
||||
|
||||
const LinkedServicesPage = () =>
|
||||
import("@/features/admin/modules/linked-services/LinkedServicesPage.vue");
|
||||
|
||||
const ReportsPage = () =>
|
||||
import("@/features/admin/modules/reports/ReportsPage.vue");
|
||||
|
||||
@@ -169,6 +172,16 @@ export const adminRoutes: RouteRecordRaw[] = [
|
||||
title: "常用问题",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "linked-services",
|
||||
name: "AdminLinkedServices",
|
||||
component: LinkedServicesPage,
|
||||
meta: {
|
||||
requiresAdmin: true,
|
||||
adminModule: "linked_services",
|
||||
title: "关联服务",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "requests",
|
||||
name: "AdminRequests",
|
||||
|
||||
@@ -58,6 +58,7 @@ export const config = {
|
||||
announcements: true, // 公告管理
|
||||
questions: true, // 常用问题
|
||||
wecom: true, // 企业微信
|
||||
linked_services: true, // 关联服务(侧栏跳转入口)
|
||||
permissions: true, // 应用权限
|
||||
platform_apps: true, // 平台应用说明
|
||||
requests: true, // 审批权限
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
/**
|
||||
* features/admin/api/admin.api.ts
|
||||
* 管理后台 HTTP API:用户、部门、Agent、权限、报表、企业微信、公告等。
|
||||
* 管理后台 HTTP API:用户、部门、Agent、权限、报表、企业微信、公告、关联服务等。
|
||||
*/
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import type { AdminUserRow } from '../types/admin.types';
|
||||
import type { AdminDashboardBadges, AdminDashboardSummary } from '../types/dashboard.types';
|
||||
import type { PaginatedResult } from '@/shared/types/pagination.types';
|
||||
import type { AdminLinkedServiceRow } from '../types/linked-service.types';
|
||||
import type {
|
||||
ApplicationReport,
|
||||
ApplicationSortKey,
|
||||
@@ -394,6 +395,16 @@ export const updateAnnouncement = (id: number, payload: Record<string, unknown>)
|
||||
export const deleteAnnouncement = (id: number) =>
|
||||
requestJson(`/api/admin/announcements/${id}`, { method: 'DELETE', ...auth() });
|
||||
|
||||
// Linked services(关联服务:侧栏跳转入口)
|
||||
export const listLinkedServices = () =>
|
||||
requestJson<AdminLinkedServiceRow[]>('/api/admin/linked-services', auth());
|
||||
export const createLinkedService = (payload: Record<string, unknown>) =>
|
||||
requestJson('/api/admin/linked-services', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const updateLinkedService = (id: number, payload: Record<string, unknown>) =>
|
||||
requestJson(`/api/admin/linked-services/${id}`, { method: 'PUT', ...jsonAuth(), body: JSON.stringify(payload) });
|
||||
export const deleteLinkedService = (id: number) =>
|
||||
requestJson(`/api/admin/linked-services/${id}`, { method: 'DELETE', ...auth() });
|
||||
|
||||
// Quick questions
|
||||
export const listAdminQuickQuestions = () => requestJson<any[]>('/api/admin/quick-questions', auth());
|
||||
export const saveAdminQuickQuestion = (url: string, method: string, payload: Record<string, unknown>) =>
|
||||
|
||||
@@ -11,7 +11,7 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
LayoutDashboard, UserPlus, UserCog, Building, Bot, FileText,
|
||||
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, ShieldCheck, BarChart2, AppWindow,
|
||||
ScrollText,
|
||||
ScrollText, ExternalLink,
|
||||
} from 'lucide-vue-next';
|
||||
import type { Component } from 'vue';
|
||||
import { config } from '@/config';
|
||||
@@ -35,6 +35,7 @@ const iconMap: Record<AdminModuleId, Component> = {
|
||||
announcements: Megaphone,
|
||||
questions: MessageCircleQuestion,
|
||||
wecom: Link2,
|
||||
linked_services: ExternalLink,
|
||||
permissions: Users,
|
||||
platform_apps: AppWindow,
|
||||
procurement_contract: ScrollText,
|
||||
|
||||
@@ -15,7 +15,7 @@ export interface AdminModuleMeta {
|
||||
|
||||
/** 已独立拆分的模块(全部 admin 模块均已拆分) */
|
||||
export const STANDALONE_ADMIN_MODULES = new Set<AdminModuleId>([
|
||||
'dashboard', 'agents', 'users', 'departments', 'approvals', 'announcements', 'questions', 'requests', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'platform_apps', 'procurement_contract', 'reports',
|
||||
'dashboard', 'agents', 'users', 'departments', 'approvals', 'announcements', 'questions', 'requests', 'permissions', 'schedules', 'knowledge_base', 'wecom', 'linked_services', 'platform_apps', 'procurement_contract', 'reports',
|
||||
]);
|
||||
|
||||
export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
@@ -29,6 +29,7 @@ export const ADMIN_MODULE_METAS: AdminModuleMeta[] = [
|
||||
{ id: 'announcements', routeName: 'AdminAnnouncements', path: 'announcements', labelKey: 'admin.nav.announcements', configKey: 'announcements' },
|
||||
{ id: 'questions', routeName: 'AdminQuestions', path: 'questions', labelKey: 'admin.nav.questions', configKey: 'questions' },
|
||||
{ id: 'wecom', routeName: 'AdminWecom', path: 'wecom', labelKey: 'admin.nav.wecom', configKey: 'wecom' },
|
||||
{ id: 'linked_services', routeName: 'AdminLinkedServices', path: 'linked-services', labelKey: 'admin.nav.linkedServices', configKey: 'linked_services' },
|
||||
{ id: 'permissions', routeName: 'AdminPermissions', path: 'permissions', labelKey: 'admin.nav.permissions', configKey: 'permissions' },
|
||||
{ id: 'platform_apps', routeName: 'AdminPlatformApps', path: 'platform-apps', labelKey: 'admin.nav.platformApps', configKey: 'platform_apps' },
|
||||
{ id: 'procurement_contract', routeName: 'AdminProcurementContract', path: 'procurement-contract', labelKey: 'admin.nav.procurementContract', configKey: 'procurement_contract' },
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/LinkedServicesPage.vue
|
||||
* 关联服务管理独立页面:表格列表 + 新增/编辑弹窗。
|
||||
* 依赖:useLinkedServicesAdmin、LinkedServiceFormModal、DeleteConfirmDialog。
|
||||
* 逻辑:路由 /admin/linked-services;启用项自动出现在 Chat/工作台侧栏底部。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Edit, Plus, Trash2 } from 'lucide-vue-next';
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
import LinkedServiceFormModal from './components/LinkedServiceFormModal.vue';
|
||||
import { useLinkedServicesAdmin } from './composables/useLinkedServicesAdmin';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const {
|
||||
services,
|
||||
form,
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
closeFormModal,
|
||||
saveService,
|
||||
toggleEnabled,
|
||||
deleteServiceItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
} = useLinkedServicesAdmin();
|
||||
|
||||
onMounted(() => {
|
||||
void loadAll();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="admin-table-section animate-fade-in-up">
|
||||
<div v-if="isLoading" class="flex items-center justify-center py-20">
|
||||
<div class="animate-spin rounded-full h-10 w-10 border-b-2 border-brand-600" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div class="admin-table-header admin-table-header--stacked">
|
||||
<div>
|
||||
<h2 class="section-title">{{ t('admin.linkedServices.title') }}</h2>
|
||||
<p class="section-desc mt-1">{{ t('admin.linkedServices.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal"
|
||||
>
|
||||
<Plus class="w-4 h-4" />
|
||||
<span>{{ t('admin.linkedServices.add') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.linkedServices.headers.name') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs">{{ t('admin.linkedServices.headers.url') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-28">{{ t('admin.linkedServices.headers.status') }}</th>
|
||||
<th class="px-6 py-4 text-left text-xs w-24">{{ t('admin.linkedServices.headers.sortOrder') }}</th>
|
||||
<th class="px-6 py-4 text-right text-xs w-40">{{ t('admin.linkedServices.headers.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="services.length === 0">
|
||||
<td colspan="5" class="px-6 admin-table-empty">{{ t('admin.linkedServices.empty') }}</td>
|
||||
</tr>
|
||||
<tr v-for="row in services" :key="row.id">
|
||||
<td class="px-6 py-4 text-sm font-medium text-primary">{{ row.name }}</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary font-mono break-all">{{ row.url }}</td>
|
||||
<td class="px-6 py-4">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-full px-2.5 py-1 text-xs font-medium transition-colors"
|
||||
:class="row.is_enabled
|
||||
? 'bg-emerald-50 text-emerald-700 hover:bg-emerald-100'
|
||||
: 'bg-surface-soft text-muted hover:bg-surface'"
|
||||
@click="toggleEnabled(row)"
|
||||
>
|
||||
{{ row.is_enabled ? t('admin.linkedServices.status.enabled') : t('admin.linkedServices.status.disabled') }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-secondary">{{ row.sort_order }}</td>
|
||||
<td class="px-6 py-4 text-right">
|
||||
<div class="inline-flex items-center gap-1">
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary"
|
||||
:title="t('admin.edit')"
|
||||
@click="openEditModal(row)"
|
||||
>
|
||||
<Edit class="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="p-2 rounded-lg text-muted hover:bg-red-50 hover:text-red-600"
|
||||
:title="t('admin.delete')"
|
||||
@click="deleteServiceItem(row.id)"
|
||||
>
|
||||
<Trash2 class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<LinkedServiceFormModal
|
||||
:visible="showFormModal"
|
||||
:form="form"
|
||||
:is-saving="isSaving"
|
||||
@close="closeFormModal"
|
||||
@save="saveService"
|
||||
/>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="showDeleteConfirmDialog"
|
||||
:message="deleteConfirmMessage"
|
||||
@cancel="closeDeleteConfirm"
|
||||
@confirm="confirmDelete"
|
||||
/>
|
||||
</section>
|
||||
</template>
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/components/LinkedServiceFormModal.vue
|
||||
* 关联服务创建/编辑居中弹窗。
|
||||
* 依赖:LinkedServiceFormState、admin 通用 modal 样式。
|
||||
* 逻辑:LinkedServicesPage 打开本组件;提交时 emit save。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { LinkedServiceFormState } from '@/features/admin/types/linked-service.types';
|
||||
|
||||
defineProps<{
|
||||
visible: boolean;
|
||||
form: LinkedServiceFormState;
|
||||
isSaving: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
save: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="visible" class="admin-modal-overlay animate-fade-in items-center">
|
||||
<div class="admin-modal-panel max-w-lg max-h-[92vh] scale-100">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-7 pb-4 border-b border-subtle">
|
||||
<h3 class="section-title">
|
||||
{{ form.id ? t('admin.linkedServices.edit') : t('admin.linkedServices.add') }}
|
||||
</h3>
|
||||
<p class="section-desc mt-1">{{ t('admin.linkedServices.formHint') }}</p>
|
||||
</div>
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.name') }}</label>
|
||||
<input
|
||||
v-model="form.name"
|
||||
type="text"
|
||||
class="input-field text-sm"
|
||||
:placeholder="t('admin.linkedServices.placeholders.name')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.url') }}</label>
|
||||
<input
|
||||
v-model="form.url"
|
||||
type="url"
|
||||
class="input-field text-sm font-mono"
|
||||
:placeholder="t('admin.linkedServices.placeholders.url')"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.linkedServices.fields.sortOrder') }}</label>
|
||||
<input v-model.number="form.sort_order" type="number" class="input-field text-sm" min="0" />
|
||||
</div>
|
||||
<label class="inline-flex items-center gap-2 text-sm text-secondary cursor-pointer">
|
||||
<input v-model="form.is_enabled" type="checkbox" class="w-4 h-4 rounded text-brand-600 border-default" />
|
||||
{{ t('admin.linkedServices.fields.enabled') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="emit('close')">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-primary disabled:opacity-70" :disabled="isSaving" @click="emit('save')">
|
||||
{{ isSaving ? t('admin.save') + '...' : form.id ? t('admin.update') : t('admin.add') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+198
@@ -0,0 +1,198 @@
|
||||
/**
|
||||
* features/admin/modules/linked-services/composables/useLinkedServicesAdmin.ts
|
||||
* 关联服务管理:列表、新增/编辑弹窗、启用开关、删除。
|
||||
* 依赖:admin.api、linked-service.types、linked-nav.store、useMessage。
|
||||
* 逻辑:LinkedServicesPage 调用本 composable;保存/删除后刷新侧栏入口缓存。
|
||||
*/
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
createLinkedService,
|
||||
deleteLinkedService,
|
||||
listLinkedServices,
|
||||
updateLinkedService,
|
||||
} from '@/features/admin/api/admin.api';
|
||||
import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
createEmptyLinkedServiceForm,
|
||||
linkedServiceRowToForm,
|
||||
type AdminLinkedServiceRow,
|
||||
type LinkedServiceFormState,
|
||||
} from '@/features/admin/types/linked-service.types';
|
||||
|
||||
export function useLinkedServicesAdmin() {
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const linkedNav = useLinkedNavStore();
|
||||
|
||||
const services = ref<AdminLinkedServiceRow[]>([]);
|
||||
const form = ref<LinkedServiceFormState>(createEmptyLinkedServiceForm());
|
||||
const isLoading = ref(true);
|
||||
const isSaving = ref(false);
|
||||
const showFormModal = ref(false);
|
||||
|
||||
const showDeleteConfirmDialog = ref(false);
|
||||
const deleteConfirmMessage = ref('');
|
||||
let deleteConfirmAction: (() => Promise<void> | void) | null = null;
|
||||
|
||||
/**
|
||||
* 拉取关联服务列表。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const loadServices = async (): Promise<void> => {
|
||||
try {
|
||||
services.value = await listLinkedServices();
|
||||
} catch (e) {
|
||||
console.error('Failed to load linked services', e);
|
||||
services.value = [];
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 页面初始化:加载列表并结束 loading。
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
const loadAll = async (): Promise<void> => {
|
||||
isLoading.value = true;
|
||||
await loadServices();
|
||||
isLoading.value = false;
|
||||
};
|
||||
|
||||
/** 打开删除确认对话框。 */
|
||||
const openDeleteConfirm = (message: string, action: () => Promise<void> | void): void => {
|
||||
deleteConfirmMessage.value = message;
|
||||
deleteConfirmAction = action;
|
||||
showDeleteConfirmDialog.value = true;
|
||||
};
|
||||
|
||||
/** 关闭删除确认对话框。 */
|
||||
const closeDeleteConfirm = (): void => {
|
||||
showDeleteConfirmDialog.value = false;
|
||||
deleteConfirmAction = null;
|
||||
};
|
||||
|
||||
/** 执行删除确认动作。 */
|
||||
const confirmDelete = async (): Promise<void> => {
|
||||
if (!deleteConfirmAction) return;
|
||||
try {
|
||||
await deleteConfirmAction();
|
||||
} finally {
|
||||
closeDeleteConfirm();
|
||||
}
|
||||
};
|
||||
|
||||
/** 打开「新增关联服务」弹窗。 */
|
||||
const openCreateModal = (): void => {
|
||||
form.value = createEmptyLinkedServiceForm();
|
||||
form.value.sort_order = services.value.length;
|
||||
showFormModal.value = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* 打开「编辑关联服务」弹窗。
|
||||
* @param row - 待编辑行
|
||||
*/
|
||||
const openEditModal = (row: AdminLinkedServiceRow): void => {
|
||||
form.value = linkedServiceRowToForm(row);
|
||||
showFormModal.value = true;
|
||||
};
|
||||
|
||||
/** 关闭表单弹窗。 */
|
||||
const closeFormModal = (): void => {
|
||||
showFormModal.value = false;
|
||||
form.value = createEmptyLinkedServiceForm();
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存关联服务:有 id 则更新,否则新建。
|
||||
* 核心逻辑:校验名称与 URL → 调 API → 刷新列表。
|
||||
*/
|
||||
const saveService = async (): Promise<void> => {
|
||||
if (!form.value.name.trim() || !form.value.url.trim()) {
|
||||
msg.warning(t('admin.linkedServices.msg.fillAll'));
|
||||
return;
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
const payload = {
|
||||
name: form.value.name.trim(),
|
||||
url: form.value.url.trim(),
|
||||
is_enabled: form.value.is_enabled,
|
||||
sort_order: Number(form.value.sort_order || 0),
|
||||
};
|
||||
if (form.value.id) {
|
||||
await updateLinkedService(form.value.id, payload);
|
||||
} else {
|
||||
await createLinkedService(payload);
|
||||
}
|
||||
closeFormModal();
|
||||
await loadServices();
|
||||
void linkedNav.refresh();
|
||||
msg.success(t('admin.linkedServices.msg.saved'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
} finally {
|
||||
isSaving.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换启用状态并立即保存。
|
||||
* @param row - 目标行
|
||||
*/
|
||||
const toggleEnabled = async (row: AdminLinkedServiceRow): Promise<void> => {
|
||||
try {
|
||||
await updateLinkedService(row.id, {
|
||||
name: row.name,
|
||||
url: row.url,
|
||||
is_enabled: !row.is_enabled,
|
||||
sort_order: row.sort_order,
|
||||
});
|
||||
await loadServices();
|
||||
void linkedNav.refresh();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除指定关联服务。
|
||||
* @param id - 主键
|
||||
*/
|
||||
const deleteServiceItem = (id: number): void => {
|
||||
openDeleteConfirm(t('admin.linkedServices.confirmDelete'), async () => {
|
||||
try {
|
||||
await deleteLinkedService(id);
|
||||
await loadServices();
|
||||
void linkedNav.refresh();
|
||||
msg.success(t('admin.linkedServices.msg.deleted'));
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
msg.error((e as Error).message || t('admin.msg.requestFailed'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
services,
|
||||
form,
|
||||
isLoading,
|
||||
isSaving,
|
||||
showFormModal,
|
||||
showDeleteConfirmDialog,
|
||||
deleteConfirmMessage,
|
||||
loadAll,
|
||||
openCreateModal,
|
||||
openEditModal,
|
||||
closeFormModal,
|
||||
saveService,
|
||||
toggleEnabled,
|
||||
deleteServiceItem,
|
||||
closeDeleteConfirm,
|
||||
confirmDelete,
|
||||
};
|
||||
}
|
||||
@@ -14,6 +14,7 @@ export type AdminModuleId =
|
||||
| 'announcements'
|
||||
| 'questions'
|
||||
| 'wecom'
|
||||
| 'linked_services'
|
||||
| 'permissions'
|
||||
| 'requests'
|
||||
| 'platform_apps'
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* features/admin/types/linked-service.types.ts
|
||||
* 关联服务管理表单与行数据类型。
|
||||
*/
|
||||
|
||||
export interface AdminLinkedServiceRow {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
is_enabled: boolean;
|
||||
sort_order: number;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface LinkedServiceFormState {
|
||||
id: number | null;
|
||||
name: string;
|
||||
url: string;
|
||||
is_enabled: boolean;
|
||||
sort_order: number;
|
||||
}
|
||||
|
||||
/** 创建空的关联服务表单。 */
|
||||
export function createEmptyLinkedServiceForm(): LinkedServiceFormState {
|
||||
return {
|
||||
id: null,
|
||||
name: '',
|
||||
url: '',
|
||||
is_enabled: true,
|
||||
sort_order: 0,
|
||||
};
|
||||
}
|
||||
|
||||
/** 将列表行回填为编辑表单。 */
|
||||
export function linkedServiceRowToForm(row: AdminLinkedServiceRow): LinkedServiceFormState {
|
||||
return {
|
||||
id: row.id,
|
||||
name: row.name,
|
||||
url: row.url,
|
||||
is_enabled: Boolean(row.is_enabled),
|
||||
sort_order: Number(row.sort_order || 0),
|
||||
};
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/auth/composables/useLogin.ts
|
||||
* 登录页编排层:组合认证、公告展示与 OAuth 回调,provide 给 LoginView 子组件。
|
||||
* 依赖:auth.store、linked-nav.store、useLoginAuth、useLoginLanding。
|
||||
* 逻辑:登录成功后预取关联服务侧栏入口,减少进入 Chat/工作台后的入口闪现。
|
||||
*/
|
||||
import { onMounted, reactive } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
@@ -13,6 +15,7 @@ import loginBg from '@/assets/login-bg.png';
|
||||
import { DEFAULT_POST_LOGIN_AGENT_ID } from '@/features/workspace/types/workspace.types';
|
||||
import { useWorkspaceLocale } from '@/features/workspace/composables/useWorkspaceLocale';
|
||||
import { continuationLocation, readSsoContinuation } from '@/features/sso';
|
||||
import { useLinkedNavStore } from '@/features/sso/stores/linked-nav.store';
|
||||
import { useLoginAuth } from './useLoginAuth';
|
||||
import { useLoginLanding } from './useLoginLanding';
|
||||
|
||||
@@ -22,6 +25,7 @@ export function useLogin() {
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const authStore = useAuthStore();
|
||||
const linkedNav = useLinkedNavStore();
|
||||
const { setThemePreference, appliedTheme } = useTheme();
|
||||
|
||||
const deps = { t, locale, msg, router, route, setThemePreference, appliedTheme };
|
||||
@@ -29,6 +33,7 @@ export function useLogin() {
|
||||
|
||||
const completePasswordLogin = async () => {
|
||||
authStore.syncFromStorage();
|
||||
void linkedNav.ensureLoaded({ force: true });
|
||||
const continuation = readSsoContinuation();
|
||||
if (continuation) {
|
||||
await router.replace(continuationLocation(continuation));
|
||||
@@ -39,6 +44,7 @@ export function useLogin() {
|
||||
|
||||
const completeOAuthLogin = async () => {
|
||||
authStore.syncFromStorage();
|
||||
void linkedNav.ensureLoaded({ force: true });
|
||||
const continuation = readSsoContinuation();
|
||||
if (continuation) {
|
||||
await router.replace(continuationLocation(continuation));
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/chat/components/ChatMobileHeader.vue
|
||||
* 移动端顶栏:Agent 名称、学习之窗与 Agent 切换弹层。
|
||||
* 移动端顶栏:Agent 名称、学习之窗、关联服务入口与 Agent 切换弹层。
|
||||
* 依赖:AgentCategoryList、ExternalSystemLinks。
|
||||
* 逻辑:关联服务 compact 按钮与右侧 Agent/历史按钮同为 h-9 圆形图标。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
@@ -77,7 +79,12 @@ onBeforeUnmount(() => {
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex items-center gap-1">
|
||||
<ExternalSystemLinks compact :show-label="false" />
|
||||
<ExternalSystemLinks
|
||||
compact
|
||||
:show-label="false"
|
||||
button-class="flex h-9 w-9 items-center justify-center rounded-full text-muted transition-colors hover-surface-soft"
|
||||
icon-class="h-4 w-4 shrink-0"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="flex h-9 w-9 items-center justify-center rounded-full text-muted transition-colors hover-surface-soft"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* 依赖:lucide-vue-next、LocaleToggleButton、ExternalSystemLinks、AgentCategoryList、chat.types。
|
||||
* 逻辑:由聊天页面传入当前 Agent、历史记录与用户可用 Agent;通过事件把新会话、切换 Agent、反馈、进入管理控制台等操作回传给页面。
|
||||
* 管理员通过底部右侧工具图标进入管理控制台;用户下拉菜单仅保留退出登录。
|
||||
* 关联服务入口与主题/语言等底栏图标统一为同尺寸 inline icon 按钮,避免错位。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
@@ -129,7 +130,12 @@ const userInitial = (fallback: string) => {
|
||||
</button>
|
||||
|
||||
<div class="mt-auto flex flex-col items-center gap-6 pb-2 text-muted">
|
||||
<ExternalSystemLinks compact :show-label="false" />
|
||||
<ExternalSystemLinks
|
||||
compact
|
||||
:show-label="false"
|
||||
button-class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
icon-class="h-5 w-5 shrink-0"
|
||||
/>
|
||||
<button type="button" class="transition-colors hover:text-secondary"><Sparkles class="h-5 w-5" /></button>
|
||||
<div class="flex h-8 w-8 items-center justify-center rounded-full bg-brand-600 text-sm font-bold text-white shadow-sm shadow-brand-500/20">
|
||||
{{ userInitial('I') }}
|
||||
@@ -302,11 +308,16 @@ const userInitial = (fallback: string) => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<ExternalSystemLinks compact :show-label="false" />
|
||||
<div class="flex items-center gap-3">
|
||||
<ExternalSystemLinks
|
||||
compact
|
||||
:show-label="false"
|
||||
button-class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
icon-class="h-4 w-4 shrink-0"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="transition-colors hover:text-secondary"
|
||||
class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
:title="appliedTheme === 'dark' ? ($t('theme.switchToLight') || 'Switch to light mode') : ($t('theme.switchToDark') || 'Switch to dark mode')"
|
||||
@click="emit('toggle-theme')"
|
||||
>
|
||||
@@ -314,16 +325,16 @@ const userInitial = (fallback: string) => {
|
||||
<Moon v-else class="h-4 w-4" />
|
||||
</button>
|
||||
<LocaleToggleButton variant="sidebar" />
|
||||
<button type="button" class="transition-colors hover:text-secondary" :title="$t('chat.generalFeedback')" @click="emit('open-feedback')">
|
||||
<button type="button" class="inline-flex items-center justify-center transition-colors hover:text-secondary" :title="$t('chat.generalFeedback')" @click="emit('open-feedback')">
|
||||
<MessageSquareText class="h-4 w-4" />
|
||||
</button>
|
||||
<button type="button" class="transition-colors hover:text-secondary" :title="$t('workspace.title')" @click="emit('go-workspace')">
|
||||
<button type="button" class="inline-flex items-center justify-center transition-colors hover:text-secondary" :title="$t('workspace.title')" @click="emit('go-workspace')">
|
||||
<Briefcase class="h-4 w-4" />
|
||||
</button>
|
||||
<button
|
||||
v-if="currentUser?.role === 'admin'"
|
||||
type="button"
|
||||
class="transition-colors hover:text-secondary"
|
||||
class="inline-flex items-center justify-center transition-colors hover:text-secondary"
|
||||
:title="$t('admin.title')"
|
||||
@click="onGoAdmin"
|
||||
>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* features/sso/api/linked-services.api.ts
|
||||
* 用途:读取管理台配置的关联服务(已启用),供侧栏入口展示。
|
||||
* 依赖:shared/api/client。
|
||||
* 逻辑:ExternalSystemLinks 合并本目录与 SSO 应用目录后渲染。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
|
||||
export interface LinkedServiceItem {
|
||||
id: number;
|
||||
name: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
/** 获取当前用户可见的已启用关联服务。 */
|
||||
export async function listLinkedServices(): Promise<LinkedServiceItem[]> {
|
||||
const data = await requestJson<{ items?: LinkedServiceItem[] } | LinkedServiceItem[]>('/api/linked-services');
|
||||
if (Array.isArray(data)) return data;
|
||||
return Array.isArray(data?.items) ? data.items : [];
|
||||
}
|
||||
@@ -1,54 +1,63 @@
|
||||
<!--
|
||||
features/sso/components/ExternalSystemLinks.vue
|
||||
用途:在 HXOPS 已登录页面展示已配置产品内平级服务入口。
|
||||
依赖:SSO 应用目录 API、lucide-vue-next。
|
||||
逻辑:点击后先打开 HXOPS 同源 launch 页以继承当前登录态,再由 launch 页跳平级服务生成签名 state。
|
||||
用途:在 HXOPS 已登录页面展示关联服务与产品内 SSO 平级服务入口。
|
||||
依赖:linked-nav.store、lucide-vue-next。
|
||||
逻辑:读 Pinia 缓存即时渲染;未缓存时触发一次预取。工作台可通过 buttonClass/iconClass 对齐 ws-nav-btn。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { ExternalLink } from 'lucide-vue-next';
|
||||
import { listSsoApplications, type SsoApplication } from '../api/sso.api';
|
||||
import { useLinkedNavStore } from '../stores/linked-nav.store';
|
||||
|
||||
withDefaults(defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
compact?: boolean;
|
||||
showLabel?: boolean;
|
||||
/** 覆盖按钮样式(如工作台 ws-nav-btn),未传时用紧凑/默认样式 */
|
||||
buttonClass?: string;
|
||||
/** 覆盖图标尺寸类,未传时随 compact 变化 */
|
||||
iconClass?: string;
|
||||
}>(), {
|
||||
compact: false,
|
||||
showLabel: true,
|
||||
buttonClass: '',
|
||||
iconClass: '',
|
||||
});
|
||||
|
||||
const applications = ref<SsoApplication[]>([]);
|
||||
const linkedNav = useLinkedNavStore();
|
||||
const { items } = storeToRefs(linkedNav);
|
||||
|
||||
/** 加载已启用应用;目录不可用时隐藏入口,不阻断 HXOPS 主业务。 */
|
||||
async function loadApplications(): Promise<void> {
|
||||
try {
|
||||
applications.value = await listSsoApplications();
|
||||
} catch (error) {
|
||||
console.warn('[sso] failed to load peer services', error);
|
||||
/**
|
||||
* 解析按钮 class。
|
||||
* 核心逻辑:外部传入优先;compact 默认与 Chat 底栏图标按钮一致(无额外 36px 盒子,避免错位)。
|
||||
*/
|
||||
const resolvedButtonClass = computed(() => {
|
||||
if (props.buttonClass) return props.buttonClass;
|
||||
if (props.compact) {
|
||||
return 'inline-flex items-center justify-center transition-colors hover:text-secondary';
|
||||
}
|
||||
}
|
||||
return 'inline-flex items-center justify-center gap-2 rounded-xl px-3 py-2 text-sm text-muted transition-colors hover:bg-surface-soft hover:text-secondary min-h-9';
|
||||
});
|
||||
|
||||
/** 在新标签先打开同源中转页,确保非 remember 登录态也可继承到新标签。 */
|
||||
function openApplication(application: SsoApplication): void {
|
||||
window.open(`/sso/launch?app=${encodeURIComponent(application.key)}`, '_blank');
|
||||
}
|
||||
/** 解析图标 class:默认 16px,与 Chat 底栏 Moon/Briefcase 一致。 */
|
||||
const resolvedIconClass = computed(() => props.iconClass || 'h-4 w-4 shrink-0');
|
||||
|
||||
onMounted(() => {
|
||||
void loadApplications();
|
||||
// 已缓存则立即展示;未缓存时补一次预取(登录后 App 通常已预取)。
|
||||
void linkedNav.ensureLoaded();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<template v-for="application in applications" :key="application.key">
|
||||
<template v-for="entry in items" :key="entry.key">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center justify-center gap-2 rounded-xl text-muted transition-colors hover:bg-surface-soft hover:text-secondary"
|
||||
:class="compact ? 'h-9 w-9' : 'min-h-9 px-3 py-2 text-sm'"
|
||||
:title="application.display_name"
|
||||
@click="openApplication(application)"
|
||||
:class="resolvedButtonClass"
|
||||
:title="entry.display_name"
|
||||
@click="linkedNav.openItem(entry)"
|
||||
>
|
||||
<ExternalLink class="h-4 w-4 shrink-0" />
|
||||
<span v-if="showLabel && !compact" class="truncate">{{ application.display_name }}</span>
|
||||
<ExternalLink :class="resolvedIconClass" />
|
||||
<span v-if="showLabel && !compact" class="truncate">{{ entry.display_name }}</span>
|
||||
</button>
|
||||
</template>
|
||||
</template>
|
||||
@@ -5,6 +5,7 @@
|
||||
* 逻辑:页面通过本入口复用平级服务导航,登录模块复用 continuation。
|
||||
*/
|
||||
export { default as ExternalSystemLinks } from './components/ExternalSystemLinks.vue';
|
||||
export { useLinkedNavStore } from './stores/linked-nav.store';
|
||||
export {
|
||||
continuationLocation,
|
||||
readSsoContinuation,
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* features/sso/stores/linked-nav.store.ts
|
||||
* 用途:缓存关联服务 / SSO 侧栏入口,避免页面切换时重复请求导致入口闪现。
|
||||
* 依赖:linked-services.api、sso.api、pinia。
|
||||
* 逻辑:登录后预取一次;ExternalSystemLinks 直接读 store;登出或管理台变更时刷新/清空。
|
||||
*/
|
||||
import { defineStore } from 'pinia';
|
||||
import { computed, ref } from 'vue';
|
||||
import { listLinkedServices, type LinkedServiceItem } from '../api/linked-services.api';
|
||||
import { listSsoApplications, type SsoApplication } from '../api/sso.api';
|
||||
|
||||
/** 侧栏可渲染的入口元数据(可序列化,不含函数)。 */
|
||||
export interface LinkedNavItem {
|
||||
key: string;
|
||||
display_name: string;
|
||||
/** sso:走 /sso/launch;url:直接打开 target */
|
||||
mode: 'sso' | 'url';
|
||||
target: string;
|
||||
}
|
||||
|
||||
/** 规范化 URL 便于与 SSO login_url 比对。 */
|
||||
function normalizeUrl(value: string): string {
|
||||
return String(value || '').trim().replace(/\/+$/, '').toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并关联服务与 SSO 目录为侧栏入口列表。
|
||||
* 核心逻辑:关联服务优先;命中 SSO 注册表则 mode=sso。
|
||||
*/
|
||||
function buildNavItems(linked: LinkedServiceItem[], ssoApps: SsoApplication[]): LinkedNavItem[] {
|
||||
const usedSsoKeys = new Set<string>();
|
||||
const next: LinkedNavItem[] = [];
|
||||
|
||||
for (const item of linked) {
|
||||
const matched = ssoApps.find(
|
||||
(app) =>
|
||||
normalizeUrl(app.login_url) === normalizeUrl(item.url)
|
||||
|| String(app.display_name || '').trim() === String(item.name || '').trim(),
|
||||
);
|
||||
if (matched) {
|
||||
usedSsoKeys.add(matched.key);
|
||||
next.push({
|
||||
key: `linked-${item.id}`,
|
||||
display_name: item.name,
|
||||
mode: 'sso',
|
||||
target: matched.key,
|
||||
});
|
||||
} else {
|
||||
next.push({
|
||||
key: `linked-${item.id}`,
|
||||
display_name: item.name,
|
||||
mode: 'url',
|
||||
target: item.url,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (const app of ssoApps) {
|
||||
if (usedSsoKeys.has(app.key)) continue;
|
||||
next.push({
|
||||
key: `sso-${app.key}`,
|
||||
display_name: app.display_name,
|
||||
mode: 'sso',
|
||||
target: app.key,
|
||||
});
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
export const useLinkedNavStore = defineStore('linkedNav', () => {
|
||||
const items = ref<LinkedNavItem[]>([]);
|
||||
const loaded = ref(false);
|
||||
const loading = ref(false);
|
||||
let inflight: Promise<void> | null = null;
|
||||
|
||||
const hasItems = computed(() => items.value.length > 0);
|
||||
|
||||
/**
|
||||
* 预取侧栏入口;已加载且非 force 时直接复用缓存。
|
||||
* @param options.force - 为 true 时忽略缓存强制刷新(管理台保存后)
|
||||
*/
|
||||
async function ensureLoaded(options?: { force?: boolean }): Promise<void> {
|
||||
if (options?.force) {
|
||||
loaded.value = false;
|
||||
}
|
||||
if (loaded.value) return;
|
||||
if (inflight) {
|
||||
await inflight;
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
inflight = (async () => {
|
||||
let linked: LinkedServiceItem[] = [];
|
||||
let ssoApps: SsoApplication[] = [];
|
||||
try {
|
||||
linked = await listLinkedServices();
|
||||
} catch (error) {
|
||||
console.warn('[linked-nav] failed to load linked services', error);
|
||||
}
|
||||
try {
|
||||
ssoApps = await listSsoApplications();
|
||||
} catch (error) {
|
||||
console.warn('[linked-nav] failed to load sso apps', error);
|
||||
}
|
||||
items.value = buildNavItems(linked, ssoApps);
|
||||
loaded.value = true;
|
||||
})();
|
||||
|
||||
try {
|
||||
await inflight;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
inflight = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 强制刷新入口缓存(管理台增删改后调用)。 */
|
||||
async function refresh(): Promise<void> {
|
||||
await ensureLoaded({ force: true });
|
||||
}
|
||||
|
||||
/** 登出时清空,避免下一账号看到旧入口。 */
|
||||
function reset(): void {
|
||||
items.value = [];
|
||||
loaded.value = false;
|
||||
loading.value = false;
|
||||
inflight = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开入口:SSO 走同源 launch,其它直接新开 URL。
|
||||
* @param item - 侧栏入口元数据
|
||||
*/
|
||||
function openItem(item: LinkedNavItem): void {
|
||||
if (item.mode === 'sso') {
|
||||
window.open(`/sso/launch?app=${encodeURIComponent(item.target)}`, '_blank');
|
||||
return;
|
||||
}
|
||||
window.open(item.target, '_blank');
|
||||
}
|
||||
|
||||
return {
|
||||
items,
|
||||
loaded,
|
||||
loading,
|
||||
hasItems,
|
||||
ensureLoaded,
|
||||
refresh,
|
||||
reset,
|
||||
openItem,
|
||||
};
|
||||
});
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/components/WorkspaceSidebar.vue
|
||||
* 工作台左侧导航:子路由链接、第三方系统、返回聊天与退出登录。
|
||||
* 工作台左侧导航:子路由链接、关联服务入口、返回聊天与退出登录。
|
||||
* 依赖:WORKSPACE_PATHS、workspace.context、ExternalSystemLinks。
|
||||
* 逻辑:底部关联服务复用 ws-nav-btn,与返回聊天/退出登录对齐。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
@@ -107,7 +109,12 @@ function isActive(match: readonly string[]) {
|
||||
|
||||
<div class="border-t border-subtle pt-4">
|
||||
<div class="space-y-2">
|
||||
<ExternalSystemLinks :compact="Boolean(collapsed)" :show-label="!collapsed" />
|
||||
<ExternalSystemLinks
|
||||
:compact="Boolean(collapsed)"
|
||||
:show-label="!collapsed"
|
||||
:button-class="collapsed ? 'ws-nav-btn justify-center px-0' : 'ws-nav-btn'"
|
||||
icon-class="h-[18px] w-[18px] shrink-0"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
@click="ws.navigateToGeneralChat"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"announcements": "Announcements",
|
||||
"questions": "Common Questions",
|
||||
"wecom": "WeCom",
|
||||
"linkedServices": "Linked Services",
|
||||
"permissions": "App Permissions",
|
||||
"requests": "Permission Requests",
|
||||
"reports": "Data Reports",
|
||||
@@ -30,6 +31,41 @@
|
||||
"platformApps": "Platform Apps",
|
||||
"procurementContract": "Procurement Contract Review"
|
||||
},
|
||||
"linkedServices": {
|
||||
"title": "Linked Services",
|
||||
"subtitle": "Configured name and URL entries appear at the bottom of the Chat and Workspace sidebars for one-click jumps.",
|
||||
"add": "Add Service",
|
||||
"edit": "Edit Linked Service",
|
||||
"formHint": "When enabled, the entry is shown in the Chat / Workspace sidebar footer.",
|
||||
"empty": "No linked services yet. Click Add Service to create one.",
|
||||
"confirmDelete": "Delete this linked service? It will disappear from the sidebar immediately.",
|
||||
"fields": {
|
||||
"name": "Display Name",
|
||||
"url": "URL",
|
||||
"sortOrder": "Sort Order",
|
||||
"enabled": "Enable entry"
|
||||
},
|
||||
"placeholders": {
|
||||
"name": "e.g. Drawings",
|
||||
"url": "http://192.168.100.192:8910/"
|
||||
},
|
||||
"headers": {
|
||||
"name": "Name",
|
||||
"url": "URL",
|
||||
"status": "Status",
|
||||
"sortOrder": "Order",
|
||||
"actions": "Actions"
|
||||
},
|
||||
"status": {
|
||||
"enabled": "Enabled",
|
||||
"disabled": "Disabled"
|
||||
},
|
||||
"msg": {
|
||||
"fillAll": "Please fill in name and URL",
|
||||
"saved": "Linked service saved",
|
||||
"deleted": "Linked service deleted"
|
||||
}
|
||||
},
|
||||
"platformApps": {
|
||||
"guideUsage": "Guide Usage",
|
||||
"generalGuide": "General Guide",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"announcements": "การจัดการประกาศ",
|
||||
"questions": "คำถามทั่วไป",
|
||||
"wecom": "WeCom",
|
||||
"linkedServices": "บริการที่เชื่อมโยง",
|
||||
"permissions": "สิทธิ์แอปพลิเคชัน",
|
||||
"requests": "คำขอสิทธิ์",
|
||||
"reports": "รายงานข้อมูล",
|
||||
@@ -30,6 +31,41 @@
|
||||
"platformApps": "แอปแพลตฟอร์ม",
|
||||
"procurementContract": "ตรวจสอบสัญญาจัดซื้อ"
|
||||
},
|
||||
"linkedServices": {
|
||||
"title": "บริการที่เชื่อมโยง",
|
||||
"subtitle": "ตั้งชื่อและ URL แล้วรายการจะปรากฏที่ด้านล่างของแถบข้าง Chat และ Workspace สำหรับการข้ามด้วยคลิกเดียว",
|
||||
"add": "เพิ่มบริการ",
|
||||
"edit": "แก้ไขบริการที่เชื่อมโยง",
|
||||
"formHint": "เมื่อเปิดใช้งาน รายการจะแสดงที่ท้ายแถบข้าง Chat / Workspace",
|
||||
"empty": "ยังไม่มีบริการที่เชื่อมโยง คลิกเพิ่มบริการเพื่อสร้าง",
|
||||
"confirmDelete": "ลบบริการนี้หรือไม่? รายการจะหายจากแถบข้างทันที",
|
||||
"fields": {
|
||||
"name": "ชื่อที่แสดง",
|
||||
"url": "URL",
|
||||
"sortOrder": "ลำดับ",
|
||||
"enabled": "เปิดใช้งานทางเข้า"
|
||||
},
|
||||
"placeholders": {
|
||||
"name": "เช่น แบบ도면",
|
||||
"url": "http://192.168.100.192:8910/"
|
||||
},
|
||||
"headers": {
|
||||
"name": "ชื่อ",
|
||||
"url": "URL",
|
||||
"status": "สถานะ",
|
||||
"sortOrder": "ลำดับ",
|
||||
"actions": "การดำเนินการ"
|
||||
},
|
||||
"status": {
|
||||
"enabled": "เปิด",
|
||||
"disabled": "ปิด"
|
||||
},
|
||||
"msg": {
|
||||
"fillAll": "กรุณากรอกชื่อและ URL",
|
||||
"saved": "บันทึกบริการแล้ว",
|
||||
"deleted": "ลบบริการแล้ว"
|
||||
}
|
||||
},
|
||||
"platformApps": {
|
||||
"guideUsage": "ประเภทการใช้งานเอกสาร",
|
||||
"generalGuide": "คู่มือทั่วไป",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"announcements": "公告管理",
|
||||
"questions": "常用问题",
|
||||
"wecom": "企业微信",
|
||||
"linkedServices": "关联服务",
|
||||
"permissions": "应用权限",
|
||||
"platformApps": "平台应用说明",
|
||||
"requests": "权限审批",
|
||||
@@ -30,6 +31,41 @@
|
||||
"schedules": "排程管理",
|
||||
"procurementContract": "采购合同审查"
|
||||
},
|
||||
"linkedServices": {
|
||||
"title": "关联服务",
|
||||
"subtitle": "配置名称与访问地址后,将自动出现在 Chat 与工作台侧栏底部,供用户一键跳转。",
|
||||
"add": "新增服务",
|
||||
"edit": "编辑关联服务",
|
||||
"formHint": "启用后会同步展示在 Chat / 工作台侧栏底部入口。",
|
||||
"empty": "暂无关联服务,点击右上角新增。",
|
||||
"confirmDelete": "确定删除该关联服务?删除后侧栏入口将立即消失。",
|
||||
"fields": {
|
||||
"name": "显示名称",
|
||||
"url": "访问地址",
|
||||
"sortOrder": "排序",
|
||||
"enabled": "启用入口"
|
||||
},
|
||||
"placeholders": {
|
||||
"name": "例如:图纸",
|
||||
"url": "http://192.168.100.192:8910/"
|
||||
},
|
||||
"headers": {
|
||||
"name": "名称",
|
||||
"url": "URL",
|
||||
"status": "状态",
|
||||
"sortOrder": "排序",
|
||||
"actions": "操作"
|
||||
},
|
||||
"status": {
|
||||
"enabled": "启用",
|
||||
"disabled": "停用"
|
||||
},
|
||||
"msg": {
|
||||
"fillAll": "请填写名称和访问地址",
|
||||
"saved": "关联服务已保存",
|
||||
"deleted": "关联服务已删除"
|
||||
}
|
||||
},
|
||||
"platformApps": {
|
||||
"guideUsage": "资料用途",
|
||||
"generalGuide": "通用指南",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"announcements": "公告管理",
|
||||
"questions": "常用問題",
|
||||
"wecom": "企業微信",
|
||||
"linkedServices": "關聯服務",
|
||||
"permissions": "應用權限",
|
||||
"requests": "權限審批",
|
||||
"reports": "數據報表",
|
||||
@@ -30,6 +31,41 @@
|
||||
"platformApps": "平台應用說明",
|
||||
"procurementContract": "採購合同審查"
|
||||
},
|
||||
"linkedServices": {
|
||||
"title": "關聯服務",
|
||||
"subtitle": "設定名稱與訪問地址後,將自動出現在 Chat 與工作台側欄底部,供使用者一鍵跳轉。",
|
||||
"add": "新增服務",
|
||||
"edit": "編輯關聯服務",
|
||||
"formHint": "啟用後會同步展示在 Chat / 工作台側欄底部入口。",
|
||||
"empty": "暫無關聯服務,點擊右上角新增。",
|
||||
"confirmDelete": "確定刪除該關聯服務?刪除後側欄入口將立即消失。",
|
||||
"fields": {
|
||||
"name": "顯示名稱",
|
||||
"url": "訪問地址",
|
||||
"sortOrder": "排序",
|
||||
"enabled": "啟用入口"
|
||||
},
|
||||
"placeholders": {
|
||||
"name": "例如:圖紙",
|
||||
"url": "http://192.168.100.192:8910/"
|
||||
},
|
||||
"headers": {
|
||||
"name": "名稱",
|
||||
"url": "URL",
|
||||
"status": "狀態",
|
||||
"sortOrder": "排序",
|
||||
"actions": "操作"
|
||||
},
|
||||
"status": {
|
||||
"enabled": "啟用",
|
||||
"disabled": "停用"
|
||||
},
|
||||
"msg": {
|
||||
"fillAll": "請填寫名稱和訪問地址",
|
||||
"saved": "關聯服務已儲存",
|
||||
"deleted": "關聯服務已刪除"
|
||||
}
|
||||
},
|
||||
"platformApps": {
|
||||
"guideUsage": "資料用途",
|
||||
"generalGuide": "通用指南",
|
||||
|
||||
Reference in new issue
Block a user