refactor(frontend): 重构前端第二版

This commit is contained in:
sophie committed 2026-06-11 13:47:06 +08:00
1 parent 2631f78b00
commit 4b562cfa82
205 files changed
+15399 -12015

No files matched your search

@@ -0,0 +1,30 @@
/**
* features/workspace/api/schedule.api.ts
* 工作台排程记录 HTTP API(用户可见的执行历史与 Excel 导出)。
*/
import { getAuthHeaders } from '@/shared/utils/auth';
import { requestJson } from '@/shared/api/client';
import type { ScheduleRun } from '@/shared/types/schedule.types';
async function getJson<T>(url: string): Promise<T> {
return requestJson<T>(url, { headers: getAuthHeaders() });
}
export const listWorkspaceScheduleRuns = (params?: {
status?: string;
schedule_name?: string;
started_after?: string;
started_before?: string;
}) => {
const sp = new URLSearchParams();
if (params?.status) sp.set('status', params.status);
if (params?.schedule_name) sp.set('schedule_name', params.schedule_name);
if (params?.started_after) sp.set('started_after', params.started_after);
if (params?.started_before) sp.set('started_before', params.started_before);
const qs = sp.toString();
return getJson<ScheduleRun[]>(`/api/workspace/schedule-runs${qs ? '?' + qs : ''}`);
};
export const workspaceRunExcelUrl = (runId: number) => `/api/workspace/schedule-runs/${runId}/excel`;
export type { ScheduleRun };
@@ -1,13 +1,13 @@
<script setup lang="ts">
<script setup lang="ts">
/**
* features/workspace/components/WorkspaceModals.vue
* 工作台弹窗:公告详情、修改密码、快捷问题删除、意见反馈。
*/
import { inject } from 'vue';
import { X } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/components/DeleteConfirmDialog.vue';
import GeneralFeedbackDialog from '@/components/GeneralFeedbackDialog.vue';
import { getAuthHeaders } from '@/utils/auth';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import GeneralFeedbackDialog from '@/shared/components/GeneralFeedbackDialog.vue';
import { getAuthHeaders } from '@/shared/utils/auth';
import { WORKSPACE_KEY } from '../composables/workspace.context';
const ws = inject(WORKSPACE_KEY)! as any;
@@ -1,4 +1,4 @@
/**
/**
* features/workspace/composables/useWorkspace.ts
* 工作台编排层:组合各子 composable,挂载生命周期,provide 给 Layout 与子页面。
*/
@@ -6,9 +6,9 @@ import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { config } from '@/config';
import { useTheme } from '@/composables/useTheme';
import { useMessage } from '@/composables/useMessage';
import { useIsMobile } from '@/composables/useIsMobile';
import { useTheme } from '@/shared/composables/useTheme';
import { useMessage } from '@/shared/composables/useMessage';
import { useIsMobile } from '@/shared/composables/useIsMobile';
import { WORKSPACE_PATHS } from '../constants/routes';
import type { WorkspaceUser } from '../types/workspace.types';
import { useChatHistory } from '@/features/chat/composables/useChatHistory';
@@ -1,11 +1,11 @@
/**
/**
* features/workspace/composables/useWorkspaceHome.ts
* 应用管理/最近更新:首页数据、布局分区、收藏、快捷问题。
*/
import { computed, ref, type Ref } from 'vue';
import { config } from '@/config';
import { getAuthHeaders } from '@/utils/auth';
import { BusinessError, requestJson } from '@/api/client';
import { getAuthHeaders } from '@/shared/utils/auth';
import { BusinessError, requestJson } from '@/shared/api/client';
import {
SECTION_TITLE_KEY_MAP,
type WorkspaceAgent,
@@ -1,12 +1,12 @@
/**
/**
* features/workspace/composables/useWorkspaceNavigation.ts
* 子路由导航、移动端 Tab、聊天跳转、企微 deeplink 与旧 view 参数兼容。
*/
import { computed, nextTick, ref, watch, type ComputedRef, type Ref } from 'vue';
import { config } from '@/config';
import { getAuthHeaders } from '@/utils/auth';
import { getLastChatAgentId } from '@/utils/lastChatAgent';
import { requestJson } from '@/api/client';
import { getAuthHeaders } from '@/shared/utils/auth';
import { getLastChatAgentId } from '@/shared/utils/lastChatAgent';
import { requestJson } from '@/shared/api/client';
import { WORKSPACE_PATHS, workspacePathFromLegacyView } from '../constants/routes';
import { DEFAULT_POST_LOGIN_AGENT_ID, type WorkspaceAgent, type WorkspaceSidebarItem } from '../types/workspace.types';
import type { WorkspaceLayoutSection } from '../types/workspace.types';
@@ -1,12 +1,12 @@
/**
/**
* features/workspace/composables/useWorkspaceProfile.ts
* 个人中心:资料读取/编辑、主题偏好、修改密码。
*/
import { computed, ref } from 'vue';
import type { ThemePreference } from '@/composables/useTheme';
import { resolveCasdoorErrorMessage } from '@/utils/casdoor';
import { getAuthHeaders } from '@/utils/auth';
import { BusinessError, requestJson } from '@/api/client';
import type { ThemePreference } from '@/shared/composables/useTheme';
import { resolveCasdoorErrorMessage } from '@/shared/utils/casdoor';
import { getAuthHeaders } from '@/shared/utils/auth';
import { BusinessError, requestJson } from '@/shared/api/client';
import { CHANGE_PASSWORD_ENABLED, type WorkspaceProfileForm } from '../types/workspace.types';
import type { WorkspaceDeps } from './workspace.deps';
@@ -1,10 +1,10 @@
/**
/**
* features/workspace/composables/useWorkspaceSchedule.ts
* 排程记录:筛选条件、列表加载、状态展示与 Excel 下载。
*/
import { ref } from 'vue';
import { getAuthHeaders } from '@/utils/auth';
import { listWorkspaceScheduleRuns, workspaceRunExcelUrl, type ScheduleRun } from '@/api/schedule';
import { getAuthHeaders } from '@/shared/utils/auth';
import { listWorkspaceScheduleRuns, workspaceRunExcelUrl, type ScheduleRun } from '@/features/workspace/api/schedule.api';
import { WS_SCHEDULE_FILTER_INPUT_CLASS } from '../types/workspace.types';
import type { WorkspaceDeps } from './workspace.deps';
@@ -1,9 +1,9 @@
/**
/**
* features/workspace/composables/useWorkspaceSession.ts
* 登录态:当前用户、知识库权限判断、登出与 401 清理。
*/
import { computed, type Ref } from 'vue';
import { logoutAuth, getStoredAuthUser } from '@/utils/auth';
import { logoutAuth, getStoredAuthUser } from '@/shared/utils/auth';
import { KB_ACCESS_DENIED_MESSAGE } from '../types/workspace.types';
import type { WorkspaceUser } from '../types/workspace.types';
import type { WorkspaceDeps } from './workspace.deps';
@@ -1,12 +1,12 @@
/**
/**
* features/workspace/composables/workspace.deps.ts
* 工作台 composables 共享依赖(i18n、路由、主题、消息等)。
*/
import type { ComputedRef, WritableComputedRef } from 'vue';
import type { ComposerTranslation } from 'vue-i18n';
import type { RouteLocationNormalizedLoaded, Router } from 'vue-router';
import type { useMessage } from '@/composables/useMessage';
import type { ThemePreference } from '@/composables/useTheme';
import type { useMessage } from '@/shared/composables/useMessage';
import type { ThemePreference } from '@/shared/composables/useTheme';
export interface WorkspaceDeps {
t: ComposerTranslation;
+1
View File
@@ -6,3 +6,4 @@ export { useWorkspace } from './composables/useWorkspace';
export { WORKSPACE_KEY } from './composables/workspace.context';
export type { WorkspaceContext } from './composables/workspace.context';
export { WORKSPACE_PATHS, workspacePathFromLegacyView } from './constants/routes';
export * from './api/schedule.api';
@@ -1,10 +1,10 @@
/**
/**
* features/workspace/types/workspace.types.ts
* 工作台相关 TypeScript 类型与业务常量。
*/
import type { ThemePreference } from '@/composables/useTheme';
import type { WecomMatchField } from '@/utils/wecom';
import type { WecomLoginDialogContent } from '@/utils/wecom';
import type { ThemePreference } from '@/shared/composables/useTheme';
import type { WecomMatchField } from '@/shared/utils/wecom';
import type { WecomLoginDialogContent } from '@/shared/utils/wecom';
export interface WorkspaceUser {
id: number;
@@ -1,4 +1,4 @@
<script setup lang="ts">
<script setup lang="ts">
/**
* features/workspace/views/WorkspaceLayout.vue
* 工作台布局壳:初始化 composable、侧边栏、子路由出口与全局弹窗。