feat(i18n): 将前端用户可见中文硬编码改为四语言
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
dce915ea30
commit
ac7b53a523
105 files changed
+2928
-647
No files matched your search
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/components/WorkspaceModals.vue
|
||||
* 工作台弹窗:公告详情、快捷问题删除、意见反馈。
|
||||
* 用途:工作台弹窗:公告详情、快捷问题删除、意见反馈。
|
||||
* 依赖:DeleteConfirmDialog、GeneralFeedbackDialog、workspace.context、vue-i18n。
|
||||
* 逻辑:由 WorkspaceLayout 挂载;反馈成功 toast 使用 feedback.msg.submitSuccess。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { X } from 'lucide-vue-next';
|
||||
@@ -52,7 +54,7 @@ const ws = inject(WORKSPACE_KEY)! as any;
|
||||
v-model="ws.showGeneralFeedbackDialog"
|
||||
:auth-headers="getAuthHeaders()"
|
||||
source-page="workspace"
|
||||
@submitted="ws.msg.success('反馈提交成功')"
|
||||
@submitted="ws.msg.success($t('feedback.msg.submitSuccess'))"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/workspace/composables/useWorkspace.ts
|
||||
* 工作台编排层:组合各子 composable,挂载生命周期,provide 给 Layout 与子页面。
|
||||
* 用途:工作台编排层:组合各子 composable,挂载生命周期,provide 给 Layout 与子页面。
|
||||
* 依赖:useWorkspaceHome/Session/Navigation/Locale、useUserProfile、useChatHistory、useWorkspaceSchedule。
|
||||
* 逻辑:登录校验后 fetchHome;知识库拒绝由 Navigation 内 t(KB_ACCESS_DENIED_KEY) 处理。
|
||||
*/
|
||||
import { computed, onBeforeUnmount, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
@@ -51,7 +53,6 @@ export function useWorkspace() {
|
||||
const navigation = useWorkspaceNavigation(deps, {
|
||||
isLoggedIn: session.isLoggedIn,
|
||||
hasKnowledgeBaseAccess: session.hasKnowledgeBaseAccess,
|
||||
KB_ACCESS_DENIED_MESSAGE: session.KB_ACCESS_DENIED_MESSAGE,
|
||||
agents: home.agents,
|
||||
layoutSections: home.layoutSections,
|
||||
profileUserId: computed(() => profile.profileUser.value.id),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/workspace/composables/useWorkspaceNavigation.ts
|
||||
* 子路由导航、移动端 Tab、聊天跳转、企微 deeplink 与旧 view 参数兼容。
|
||||
* 用途:子路由导航、移动端 Tab、聊天跳转、企微 deeplink 与旧 view 参数兼容。
|
||||
* 依赖:vue-router、config、auth、requestJson、workspace routes/types。
|
||||
* 逻辑:由 useWorkspace 注入;知识库无权限时 toast t('workspace.kb.accessDenied')。
|
||||
*/
|
||||
import { computed, nextTick, ref, watch, type ComputedRef, type Ref } from 'vue';
|
||||
import { config } from '@/config';
|
||||
@@ -8,7 +10,7 @@ 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 { DEFAULT_POST_LOGIN_AGENT_ID, KB_ACCESS_DENIED_KEY, type WorkspaceAgent, type WorkspaceSidebarItem } from '../types/workspace.types';
|
||||
import type { WorkspaceLayoutSection } from '../types/workspace.types';
|
||||
import type { WorkspaceDeps } from './workspace.deps';
|
||||
|
||||
@@ -27,7 +29,6 @@ const ROUTE_NAME_TO_SIDEBAR: Record<string, WorkspaceSidebarItem> = {
|
||||
interface NavigationOptions {
|
||||
isLoggedIn: ComputedRef<boolean>;
|
||||
hasKnowledgeBaseAccess: ComputedRef<boolean>;
|
||||
KB_ACCESS_DENIED_MESSAGE: string;
|
||||
agents: Ref<WorkspaceAgent[]>;
|
||||
layoutSections: Ref<WorkspaceLayoutSection[]>;
|
||||
profileUserId: ComputedRef<number>;
|
||||
@@ -37,12 +38,17 @@ interface NavigationOptions {
|
||||
loadWorkspaceScheduleRuns: () => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装工作台侧栏/移动端导航与路由副作用。
|
||||
* 核心逻辑:映射 route.name → sidebar item;无知识库权限时本地化 toast 并拦截跳转。
|
||||
* @param deps - t/msg/router/route
|
||||
* @param options - 登录态、权限与各模块加载回调
|
||||
*/
|
||||
export function useWorkspaceNavigation(deps: WorkspaceDeps, options: NavigationOptions) {
|
||||
const { t, msg, router, route } = deps;
|
||||
const {
|
||||
isLoggedIn,
|
||||
hasKnowledgeBaseAccess,
|
||||
KB_ACCESS_DENIED_MESSAGE,
|
||||
agents,
|
||||
layoutSections,
|
||||
profileUserId,
|
||||
@@ -97,8 +103,11 @@ export function useWorkspaceNavigation(deps: WorkspaceDeps, options: NavigationO
|
||||
const navigateToApplications = () => router.push(WORKSPACE_PATHS.applications);
|
||||
const navigateToUpdates = () => router.push(WORKSPACE_PATHS.updates);
|
||||
|
||||
/**
|
||||
* 弹出知识库无权限提示(四语言)。
|
||||
*/
|
||||
const showKnowledgeBaseAccessDenied = () => {
|
||||
msg.warning(KB_ACCESS_DENIED_MESSAGE);
|
||||
msg.warning(t(KB_ACCESS_DENIED_KEY));
|
||||
};
|
||||
|
||||
const navigateToKnowledgeBase = () => {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
* features/workspace/composables/useWorkspaceSession.ts
|
||||
* 登录态:当前用户、知识库权限判断、登出与 401 清理。
|
||||
* 用途:登录态:当前用户、知识库权限判断、登出与 401 清理。
|
||||
* 依赖:auth utils、workspace.types.WorkspaceUser。
|
||||
* 逻辑:useWorkspace 组合本模块;知识库拒绝文案由导航层 t('workspace.kb.accessDenied') 解析。
|
||||
*/
|
||||
import { computed, type Ref } from 'vue';
|
||||
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';
|
||||
|
||||
@@ -79,7 +80,6 @@ export function useWorkspaceSession(deps: WorkspaceDeps, options: SessionOptions
|
||||
currentUser,
|
||||
isLoggedIn,
|
||||
hasKnowledgeBaseAccess,
|
||||
KB_ACCESS_DENIED_MESSAGE,
|
||||
loadAuthUser,
|
||||
applyLoggedOutState,
|
||||
handleLogout,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* features/workspace/types/workspace.types.ts
|
||||
* 工作台相关 TypeScript 类型与业务常量。
|
||||
* 用途:工作台相关 TypeScript 类型与业务常量。
|
||||
* 依赖:wecom utils、chat.types(历史项 re-export)。
|
||||
* 逻辑:composables/views 共享类型;知识库拒绝文案 key 为 KB_ACCESS_DENIED_KEY,由导航层 t() 解析。
|
||||
*/
|
||||
import type { WecomMatchField } from '@/shared/utils/wecom';
|
||||
import type { WecomLoginDialogContent } from '@/shared/utils/wecom';
|
||||
@@ -85,5 +87,6 @@ export const SECTION_TITLE_KEY_MAP: Record<string, string> = {
|
||||
};
|
||||
|
||||
export const DEFAULT_POST_LOGIN_AGENT_ID = 16;
|
||||
export const KB_ACCESS_DENIED_MESSAGE = '需要管理员权限才能访问知识库。';
|
||||
/** 知识库无权限提示的 i18n key(在 toast 使用点调用 t()) */
|
||||
export const KB_ACCESS_DENIED_KEY = 'workspace.kb.accessDenied';
|
||||
export const WS_SCHEDULE_FILTER_INPUT_CLASS = 'admin-table-filter-input text-xs py-1.5 px-2';
|
||||
@@ -1,7 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/views/WorkspaceLayout.vue
|
||||
* 工作台布局壳:初始化 composable、侧边栏、子路由出口与全局弹窗。
|
||||
* 用途:工作台布局壳:初始化 composable、侧边栏、子路由出口与全局弹窗。
|
||||
* 依赖:useWorkspace、WorkspaceSidebar/Modals、ExternalSystemLinks。
|
||||
* 逻辑:provide WORKSPACE_KEY;移动端返回按钮文案走 workspace.nav.backShort。
|
||||
*/
|
||||
import { provide } from 'vue';
|
||||
import { LayoutGrid, Bot, User } from 'lucide-vue-next';
|
||||
@@ -40,7 +42,7 @@ const mobileTabs = [
|
||||
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')"
|
||||
>
|
||||
返
|
||||
{{ $t('workspace.nav.backShort') }}
|
||||
</button>
|
||||
<span class="text-sm font-semibold text-primary">{{ ws.mobileTabTitle }}</span>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user