refactor(backend): 重构后端代码 wave 3
This commit is contained in:
1 parent
affe139bf9
commit
8415653365
97 files changed
+4673
-6164
No files matched your search
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* features/auth/api/auth.api.ts
|
||||
* 用途:封装登录、Casdoor/企微回调、注册和密码重置等认证域 HTTP 请求。
|
||||
* 依赖:shared/api/client。
|
||||
* 逻辑:auth views 与 composables 只调用本模块;后端暂保留 /api/user 路径以兼容既有接口。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
|
||||
export interface PasswordLoginInput {
|
||||
username: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
/** 使用当前认证模式的登录端点完成用户名密码认证。 */
|
||||
export const loginWithPassword = (api: string, input: PasswordLoginInput) =>
|
||||
requestJson<Record<string, unknown>>(api, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
|
||||
/** 将 Casdoor 授权码兑换为 HXOPS 登录会话。 */
|
||||
export const loginWithCasdoorCode = (api: string, code: string, state: string | null) =>
|
||||
requestJson<Record<string, unknown>>(api, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ code, state }),
|
||||
});
|
||||
|
||||
/** 读取 Casdoor 授权地址及后端签发的 state。 */
|
||||
export const getCasdoorAuthorizeUrl = (api: string, query: URLSearchParams) =>
|
||||
requestJson<{ url?: string; state?: string }>(`${api}?${query.toString()}`);
|
||||
|
||||
/** 将企微授权码兑换为 HXOPS 登录会话。 */
|
||||
export const loginWithWecomCode = (api: string, code: string, state: string | null) =>
|
||||
requestJson<Record<string, unknown>>(api, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ code, state }),
|
||||
});
|
||||
|
||||
/** 读取企微授权地址及后端签发的 state。 */
|
||||
export const getWecomAuthorizeUrl = (api: string, redirectUri: string) =>
|
||||
requestJson<{ url?: string; state?: string }>(`${api}?redirect_uri=${encodeURIComponent(redirectUri)}`);
|
||||
|
||||
/** 完成企微首次登录所需的本地用户匹配。 */
|
||||
export const completeWecomBind = (api: string, input: { binding_token: string; field: string; value: string }) =>
|
||||
requestJson<Record<string, unknown>>(api, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(input),
|
||||
});
|
||||
|
||||
/** 从登录页发起企业微信密码重置通知。 */
|
||||
export const requestPasswordResetByWecom = (employeeId: string, username: string) =>
|
||||
requestJson('/api/user/reset-password-by-wecom', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ employee_id: employeeId, username }),
|
||||
});
|
||||
|
||||
/** 使用重置链接中的 token 设置新密码。 */
|
||||
export const confirmPasswordReset = (token: string, newPassword: string) =>
|
||||
requestJson('/api/user/reset-password-confirm', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ token, new_password: newPassword }),
|
||||
});
|
||||
|
||||
/** 注册 HXOPS 用户;后端负责后续 Casdoor 用户同步。 */
|
||||
export const registerUser = (form: Record<string, unknown>) =>
|
||||
requestJson('/api/user/register', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(form),
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
/**
|
||||
* features/auth/api/user.api.ts
|
||||
* 用户域 HTTP API:资料、请假、密码重置、Agent 列表等。
|
||||
*/
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
|
||||
export const getUserProfile = () => requestJson<Record<string, any>>('/api/user/profile', auth());
|
||||
|
||||
export interface LeaveBalanceResult {
|
||||
has_balance: boolean;
|
||||
leave_type_label: string;
|
||||
year: number;
|
||||
total_hours: number | null;
|
||||
used_hours: number | null;
|
||||
remaining_hours: number | null;
|
||||
}
|
||||
|
||||
export const getLeaveBalance = (leaveType: string) =>
|
||||
requestJson<LeaveBalanceResult>(`/api/user/leave-balance?leave_type=${encodeURIComponent(leaveType)}`, auth());
|
||||
|
||||
export interface LeaveWorkflowSubmitResult {
|
||||
request_id?: string;
|
||||
submitted_at?: string;
|
||||
request_name?: string;
|
||||
}
|
||||
|
||||
export const submitLeaveWorkflow = (form: Record<string, any>) =>
|
||||
requestJson<LeaveWorkflowSubmitResult>('/api/user/leave-workflow/submit', {
|
||||
method: 'POST',
|
||||
...jsonAuth(),
|
||||
body: JSON.stringify(form),
|
||||
});
|
||||
|
||||
export const resetPasswordByWecom = (employeeId: string, username: string) =>
|
||||
requestJson('/api/user/reset-password-by-wecom', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ employee_id: employeeId, username }),
|
||||
});
|
||||
|
||||
export const resetPasswordConfirm = (token: string, newPassword: string) =>
|
||||
requestJson('/api/user/reset-password-confirm', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ token, new_password: newPassword }),
|
||||
});
|
||||
|
||||
export const getUserAgent = (agentId: number) =>
|
||||
requestJson<Record<string, any>>(`/api/user/agents/${agentId}`, auth());
|
||||
|
||||
export const listUserAgents = () => requestJson<any[]>('/api/agents', auth());
|
||||
|
||||
export const listAgentGuides = (agentId: number) => requestJson<any[]>(`/api/agents/${agentId}/guides`, auth());
|
||||
@@ -2,7 +2,7 @@
|
||||
* features/auth/composables/useLoginAuth.ts
|
||||
*
|
||||
* 用途:封装登录表单、记住我偏好、企微/Casdoor OAuth 回调、注册与找回密码逻辑。
|
||||
* 依赖:shared/utils/auth、requestJson、WeCom/Casdoor 工具函数。
|
||||
* 依赖:shared/utils/auth、auth.api、WeCom/Casdoor 工具函数。
|
||||
* 逻辑:密码登录成功后根据“记住我”同步本地登录态与 remembered username/password;
|
||||
* OAuth 登录仅负责认证,不自动写入 remember 偏好,避免用户未明确选择时持久化登录页账号。
|
||||
*/
|
||||
@@ -22,7 +22,17 @@ import {
|
||||
saveRememberedLoginPreference,
|
||||
saveRememberedLoginProfile,
|
||||
} from '@/shared/utils/auth';
|
||||
import { BusinessError, requestJson } from '@/shared/api/client';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import {
|
||||
completeWecomBind,
|
||||
getCasdoorAuthorizeUrl,
|
||||
getWecomAuthorizeUrl,
|
||||
loginWithCasdoorCode,
|
||||
loginWithPassword,
|
||||
loginWithWecomCode,
|
||||
registerUser,
|
||||
requestPasswordResetByWecom,
|
||||
} from '../api/auth.api';
|
||||
import { DEFAULT_POST_LOGIN_AGENT_ID } from '@/features/workspace/types/workspace.types';
|
||||
import type { WecomBindPromptState, WecomLoginDialogContent } from '@/features/workspace/types/workspace.types';
|
||||
import type { LoginDeps } from './login.deps';
|
||||
@@ -127,11 +137,7 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await requestJson('/api/user/reset-password-by-wecom', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ employee_id: employeeId, username }),
|
||||
});
|
||||
await requestPasswordResetByWecom(employeeId, username);
|
||||
msg.success(t('login.passwordResetWecomSent'));
|
||||
showForgotPasswordModal.value = false;
|
||||
forgotPasswordForm.value = { employee_id: '', username: '' };
|
||||
@@ -173,13 +179,9 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
const loginApi = isCasdoorMode
|
||||
? (config.auth?.casdoor?.passwordLoginApi || '/api/user/casdoor/password-login')
|
||||
: '/api/user/login';
|
||||
const user = await requestJson<Record<string, unknown>>(loginApi, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
username: loginUsername.value.trim(),
|
||||
password: loginPassword.value,
|
||||
}),
|
||||
const user = await loginWithPassword(loginApi, {
|
||||
username: loginUsername.value.trim(),
|
||||
password: loginPassword.value,
|
||||
});
|
||||
|
||||
persistLoginUser(user);
|
||||
@@ -221,11 +223,7 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
}
|
||||
try {
|
||||
const api = config.auth.casdoor.loginApi || '/api/user/casdoor/login';
|
||||
const data = await requestJson<Record<string, unknown>>(api, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ code, state }),
|
||||
});
|
||||
const data = await loginWithCasdoorCode(api, code, state);
|
||||
persistLoginUser(data);
|
||||
sessionStorage.removeItem('hxops_casdoor_state');
|
||||
await completeOAuthLogin();
|
||||
@@ -267,7 +265,7 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
const qs = new URLSearchParams({ redirect_uri: redirectUri, default_provider: 'wecom' });
|
||||
const hint = (config.auth.casdoor as { wecomProviderHint?: string }).wecomProviderHint?.trim();
|
||||
if (hint) qs.set('provider_hint', hint);
|
||||
const data = await requestJson<{ url?: string; state?: string }>(`${api}?${qs.toString()}`);
|
||||
const data = await getCasdoorAuthorizeUrl(api, qs);
|
||||
if (!data?.url) {
|
||||
msg.error(t('login.wecomStartFailed'));
|
||||
return;
|
||||
@@ -280,9 +278,7 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
const callbackPath = wecomCfg.callbackPath || '/login';
|
||||
const redirectUri = `${window.location.origin}${callbackPath}`;
|
||||
const api = wecomCfg.authorizeApi || '/api/user/wecom/authorize-url';
|
||||
const data = await requestJson<{ url?: string; state?: string }>(
|
||||
`${api}?redirect_uri=${encodeURIComponent(redirectUri)}`,
|
||||
);
|
||||
const data = await getWecomAuthorizeUrl(api, redirectUri);
|
||||
if (!data?.url) {
|
||||
msg.error(t('login.wecomStartFailed'));
|
||||
return;
|
||||
@@ -336,14 +332,10 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
wecomBindPrompt.value.error = '';
|
||||
try {
|
||||
const api = config.auth.wecom.completeBindApi || '/api/user/wecom/complete-bind';
|
||||
const data = await requestJson<Record<string, unknown>>(api, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
binding_token: wecomBindPrompt.value.binding_token,
|
||||
field: wecomBindPrompt.value.field,
|
||||
value: wecomBindPrompt.value.value.trim(),
|
||||
}),
|
||||
const data = await completeWecomBind(api, {
|
||||
binding_token: wecomBindPrompt.value.binding_token,
|
||||
field: wecomBindPrompt.value.field,
|
||||
value: wecomBindPrompt.value.value.trim(),
|
||||
});
|
||||
wecomLoginDialog.value = null;
|
||||
persistLoginUser(data);
|
||||
@@ -389,11 +381,7 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
isWecomLoggingIn.value = true;
|
||||
try {
|
||||
const api = config.auth.wecom.loginApi || '/api/user/wecom/login';
|
||||
const data = await requestJson<Record<string, unknown>>(api, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ code, state }),
|
||||
});
|
||||
const data = await loginWithWecomCode(api, code, state);
|
||||
wecomLoginDialog.value = null;
|
||||
persistLoginUser(data);
|
||||
sessionStorage.removeItem('hxops_wecom_state');
|
||||
@@ -434,11 +422,7 @@ export function useLoginAuth(deps: LoginDeps, options: LoginAuthOptions) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await requestJson('/api/user/register', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(form),
|
||||
});
|
||||
await registerUser(form);
|
||||
msg.success(t('register.success'));
|
||||
showRegisterModal.value = false;
|
||||
registerForm.value = {
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* features/auth/index.ts
|
||||
* 认证 feature 对外导出:store、登录 composable、用户 API。
|
||||
* 认证 feature 对外导出:store、登录 composable 与认证 API。
|
||||
*/
|
||||
export { useAuthStore, bindAuthStoreSync } from './stores/auth.store';
|
||||
export { useLogin } from './composables/useLogin';
|
||||
export {
|
||||
getUserProfile,
|
||||
getLeaveBalance,
|
||||
submitLeaveWorkflow,
|
||||
resetPasswordByWecom,
|
||||
resetPasswordConfirm,
|
||||
getUserAgent,
|
||||
listUserAgents,
|
||||
listAgentGuides,
|
||||
type LeaveBalanceResult,
|
||||
type LeaveWorkflowSubmitResult,
|
||||
} from './api/user.api';
|
||||
export * from './api/auth.api';
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* features/auth/views/ResetPasswordView.vue
|
||||
* 企微 textcard / 邮件链接重置密码页(/reset-password?token=...)。
|
||||
* 依赖:user.api resetPasswordConfirm、vue-i18n、MinimalShell。
|
||||
* 依赖:auth.api confirmPasswordReset、vue-i18n、MinimalShell。
|
||||
* 逻辑:校验 token 与两次密码一致后调 confirm 接口,成功后跳转 /login。
|
||||
*/
|
||||
import { onMounted, ref } from 'vue';
|
||||
@@ -10,7 +10,7 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Lock, AlertCircle, CheckCircle } from 'lucide-vue-next';
|
||||
import MinimalShell from '@/shared/layouts/MinimalShell.vue';
|
||||
import { resetPasswordConfirm } from '@/features/auth/api/user.api';
|
||||
import { confirmPasswordReset } from '@/features/auth/api/auth.api';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { resolveCasdoorErrorMessage } from '@/shared/utils/casdoor';
|
||||
|
||||
@@ -65,7 +65,7 @@ onMounted(() => {
|
||||
|
||||
/**
|
||||
* 提交新密码并重置 token。
|
||||
* 核心逻辑:前端校验 → resetPasswordConfirm → 成功 3 秒后跳转登录页。
|
||||
* 核心逻辑:前端校验 → confirmPasswordReset → 成功 3 秒后跳转登录页。
|
||||
*/
|
||||
const handleReset = async () => {
|
||||
if (!token.value) {
|
||||
@@ -91,7 +91,7 @@ const handleReset = async () => {
|
||||
message.value = '';
|
||||
|
||||
try {
|
||||
await resetPasswordConfirm(token.value, password.value);
|
||||
await confirmPasswordReset(token.value, password.value);
|
||||
status.value = 'success';
|
||||
message.value = t('resetPassword.successRedirect');
|
||||
setTimeout(() => {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { computed, ref, watch, type ComputedRef } from 'vue';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { getUserAgent, listUserAgents } from '@/features/auth/api/user.api';
|
||||
import { getUserAgent, listUserAgents } from '@/features/user';
|
||||
import { setLastChatAgentId } from '@/shared/utils/lastChatAgent';
|
||||
import { sortAgentsByCategory } from '@/shared/utils/agent-category.utils';
|
||||
import {
|
||||
@@ -51,31 +51,33 @@ export interface UseChatAgentOptions {
|
||||
chatGuides: Pick<UseChatGuidesReturn, 'loadGuides' | 'clearGuides'>;
|
||||
}
|
||||
|
||||
type ChatAgentOption = AgentRegistryFields & {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
icon_url?: string;
|
||||
dify_app_type?: 'chatflow' | 'workflow';
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
is_aggregate?: boolean;
|
||||
directory_members?: Array<AgentRegistryFields & {
|
||||
id: number;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
icon_url?: string;
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
}>;
|
||||
};
|
||||
|
||||
export function useChatAgent(options: UseChatAgentOptions) {
|
||||
const { deps, currentAgentId, currentUser, chatGuides } = options;
|
||||
const { t, msg, router } = deps;
|
||||
|
||||
const currentAgent = ref<AgentRegistryFields | null>(null);
|
||||
const userAgents = ref<Array<AgentRegistryFields & {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
icon_url?: string;
|
||||
dify_app_type?: 'chatflow' | 'workflow';
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
is_aggregate?: boolean;
|
||||
directory_members?: Array<AgentRegistryFields & {
|
||||
id: number;
|
||||
name: string;
|
||||
description?: string | null;
|
||||
icon_url?: string;
|
||||
category?: string | null;
|
||||
sub_category?: string | null;
|
||||
sort_order?: number;
|
||||
}>;
|
||||
}>>([]);
|
||||
const userAgents = ref<ChatAgentOption[]>([]);
|
||||
const showAgentPanel = ref(true);
|
||||
const selectedKb = ref(DEFAULT_KB);
|
||||
const kbOptions = [DEFAULT_KB, ERP_KB];
|
||||
@@ -162,7 +164,7 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
|
||||
const loadAgent = async () => {
|
||||
try {
|
||||
currentAgent.value = await getUserAgent(currentAgentId.value);
|
||||
currentAgent.value = await getUserAgent<AgentRegistryFields>(currentAgentId.value);
|
||||
await chatGuides.loadGuides();
|
||||
} catch (e) {
|
||||
if (e instanceof BusinessError && e.status === 403) {
|
||||
@@ -178,9 +180,9 @@ export function useChatAgent(options: UseChatAgentOptions) {
|
||||
|
||||
const loadUserAgents = async () => {
|
||||
try {
|
||||
const agents = await listUserAgents();
|
||||
const agents = await listUserAgents<ChatAgentOption>();
|
||||
const filtered = Array.isArray(agents)
|
||||
? agents.filter((a: any) => (a.dify_app_type || 'chatflow') === 'chatflow')
|
||||
? agents.filter((agent) => (agent.dify_app_type || 'chatflow') === 'chatflow')
|
||||
: [];
|
||||
userAgents.value = sortAgentsByCategory(filtered);
|
||||
showAgentPanel.value = userAgents.value.length > 0;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Agent 学习之窗:指南列表加载与弹窗状态。
|
||||
*/
|
||||
import { computed, ref, type ComputedRef } from 'vue';
|
||||
import { listAgentGuides } from '@/features/auth/api/user.api';
|
||||
import { listAgentGuides } from '@/features/user';
|
||||
|
||||
export interface AgentGuide {
|
||||
id: number;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* - leave-result:OA 提交结果
|
||||
*/
|
||||
import { computed, type ComputedRef, type Ref } from 'vue';
|
||||
import { getUserProfile } from '@/features/auth/api/user.api';
|
||||
import { getUserProfile } from '@/features/user';
|
||||
import { canUseLeaveFeature as resolveLeaveFeatureEnabled } from '@/shared/utils/agent-registry.utils';
|
||||
import type { AgentRegistryFields } from '@/shared/utils/agent-registry.utils';
|
||||
import { LEAVE_TYPES } from '../constants/leave';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/** 请假(leave)子模块 barrel:纯函数 + handler 工厂 */
|
||||
export * from './leave.api';
|
||||
export * from './leaveDateTime';
|
||||
export * from './leaveDisplay';
|
||||
export * from './leaveIntent';
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* features/chat/leave/leave.api.ts
|
||||
* 用途:封装聊天请假流程的余额查询与 OA 工作流提交请求。
|
||||
* 依赖:shared/utils/auth、shared/api/client。
|
||||
* 逻辑:聊天请假表单调用本模块;后端暂保留 /api/user/leave-* 路径以兼容既有接口。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type { LeaveRequestFormData } from '../types/leave.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
const jsonAuth = () => ({ headers: { 'Content-Type': 'application/json', ...getAuthHeaders() } });
|
||||
|
||||
export interface LeaveBalanceResult {
|
||||
has_balance: boolean;
|
||||
leave_type_label: string;
|
||||
year: number;
|
||||
total_hours: number | null;
|
||||
used_hours: number | null;
|
||||
remaining_hours: number | null;
|
||||
}
|
||||
|
||||
/** 查询当前用户指定假别的可用余额。 */
|
||||
export const getLeaveBalance = (leaveType: string) =>
|
||||
requestJson<LeaveBalanceResult>(`/api/user/leave-balance?leave_type=${encodeURIComponent(leaveType)}`, auth());
|
||||
|
||||
export interface LeaveWorkflowSubmitResult {
|
||||
request_id?: string;
|
||||
submitted_at?: string;
|
||||
request_name?: string;
|
||||
}
|
||||
|
||||
/** 将聊天内确认后的请假表单提交至 OA 工作流。 */
|
||||
export const submitLeaveWorkflow = (form: LeaveRequestFormData) =>
|
||||
requestJson<LeaveWorkflowSubmitResult>('/api/user/leave-workflow/submit', {
|
||||
method: 'POST',
|
||||
...jsonAuth(),
|
||||
body: JSON.stringify(form),
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 请假:表单初始数据、校验、余额断言、确认与 OA 提交。
|
||||
*/
|
||||
import { getLeaveBalance, submitLeaveWorkflow } from '@/features/auth/api/user.api';
|
||||
import { getLeaveBalance, submitLeaveWorkflow } from './leave.api';
|
||||
import { NEED_BALANCE_CHECK_TYPES } from '../constants/leave';
|
||||
import { formatLeaveBalanceNumber, getLeaveTypeLabel } from './leaveDisplay';
|
||||
import {
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* features/user/api/user.api.ts
|
||||
* 用途:封装当前登录用户的资料与其可访问 Agent 查询请求。
|
||||
* 依赖:shared/utils/auth、shared/api/client。
|
||||
* 逻辑:Chat 和用户页面通过本模块读取当前用户资源,不与认证登录流程耦合。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type { UserProfileForm } from '../types/user-profile.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
|
||||
/** 获取当前登录用户的资料及个人设置。 */
|
||||
export const getUserProfile = () => requestJson<Record<string, unknown>>('/api/user/profile', auth());
|
||||
|
||||
/** 读取个人中心编辑表单所需的完整资料。 */
|
||||
export const getEditableUserProfile = () =>
|
||||
requestJson<Partial<UserProfileForm>>('/api/user/profile', auth());
|
||||
|
||||
/** 保存当前用户允许自助编辑的资料与偏好。 */
|
||||
export const updateUserProfile = (profile: Partial<UserProfileForm>) =>
|
||||
requestJson('/api/user/profile', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify(profile),
|
||||
});
|
||||
|
||||
/** 校验当前密码后修改 Casdoor 与 HXOPS 的统一密码。 */
|
||||
export const changeUserPassword = (currentPassword: string, newPassword: string) =>
|
||||
requestJson('/api/user/change-password', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify({ current_password: currentPassword, new_password: newPassword }),
|
||||
});
|
||||
|
||||
/** 获取当前用户有权访问的单个 Agent。 */
|
||||
export const getUserAgent = <T = Record<string, unknown>>(agentId: number) =>
|
||||
requestJson<T>(`/api/user/agents/${agentId}`, auth());
|
||||
|
||||
/** 获取当前用户有权访问的 Agent 列表。 */
|
||||
export const listUserAgents = <T = unknown>() => requestJson<T[]>('/api/agents', auth());
|
||||
|
||||
/** 获取当前用户有权查看的 Agent 使用指南。 */
|
||||
export const listAgentGuides = (agentId: number) =>
|
||||
requestJson<unknown[]>(`/api/agents/${agentId}/guides`, auth());
|
||||
@@ -0,0 +1,59 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/user/components/UserPasswordDialog.vue
|
||||
* 用途:呈现并提交当前用户的密码修改表单。
|
||||
* 依赖:user-profile.context 提供的资料状态和操作方法。
|
||||
* 逻辑:由工作台布局常驻渲染,用户资料页打开弹窗后在此完成密码修改。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { X } from 'lucide-vue-next';
|
||||
import { USER_PROFILE_KEY } from '../composables/user-profile.context';
|
||||
|
||||
const userProfile = inject(USER_PROFILE_KEY)!;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="userProfile.CHANGE_PASSWORD_ENABLED && userProfile.showPasswordModal"
|
||||
class="dialog-overlay z-50 items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-md">
|
||||
<div class="dialog-header">
|
||||
<h3 class="section-title">{{ $t('profile.changePassword') || 'Change Password' }}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-icon-ds"
|
||||
:aria-label="$t('admin.close')"
|
||||
:disabled="userProfile.isChangingPassword"
|
||||
@click="userProfile.showPasswordModal = false"
|
||||
>
|
||||
<X class="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
<form @submit.prevent="userProfile.handleChangePassword">
|
||||
<div class="dialog-body">
|
||||
<div>
|
||||
<label class="label-field">{{ $t('profile.currentPassword') || 'Current Password' }}</label>
|
||||
<input v-model="userProfile.passwordForm.current" type="password" class="input-field mt-1" :disabled="userProfile.isChangingPassword" required />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label-field">{{ $t('profile.newPassword') || 'New Password' }}</label>
|
||||
<input v-model="userProfile.passwordForm.new" type="password" class="input-field mt-1" :disabled="userProfile.isChangingPassword" required />
|
||||
</div>
|
||||
<div>
|
||||
<label class="label-field">{{ $t('profile.confirmPassword') || 'Confirm Password' }}</label>
|
||||
<input v-model="userProfile.passwordForm.confirm" type="password" class="input-field mt-1" :disabled="userProfile.isChangingPassword" required />
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<button type="button" :disabled="userProfile.isChangingPassword" @click="userProfile.showPasswordModal = false" class="btn-secondary flex-1 disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
{{ $t('profile.cancel') || 'Cancel' }}
|
||||
</button>
|
||||
<button type="submit" :disabled="userProfile.isChangingPassword" class="btn-primary flex-1 disabled:opacity-50 disabled:cursor-not-allowed">
|
||||
{{ userProfile.isChangingPassword ? $t('profile.changingPassword') : ($t('profile.changePassword') || 'Update') }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+28
-25
@@ -1,16 +1,32 @@
|
||||
/**
|
||||
* features/workspace/composables/useWorkspaceProfile.ts
|
||||
* 个人中心:资料读取/编辑、主题偏好、修改密码。
|
||||
* features/user/composables/useUserProfile.ts
|
||||
* 用途:编排个人资料读取/编辑、主题偏好与统一密码修改。
|
||||
* 依赖:user.api、主题/消息/i18n composable、Casdoor 错误映射。
|
||||
* 逻辑:UserProfilePage 和 UserPasswordDialog 消费本 composable;Workspace 仅提供它以维持布局上下文。
|
||||
*/
|
||||
import { computed, ref } from 'vue';
|
||||
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';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { changeUserPassword, getEditableUserProfile, updateUserProfile } from '../api/user.api';
|
||||
import { CHANGE_PASSWORD_ENABLED, type UserProfileForm } from '../types/user-profile.types';
|
||||
import type { ComputedRef, WritableComputedRef } from 'vue';
|
||||
import type { ComposerTranslation } from 'vue-i18n';
|
||||
import type { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
export function useWorkspaceProfile(deps: WorkspaceDeps) {
|
||||
interface UserProfileDeps {
|
||||
t: ComposerTranslation;
|
||||
locale: WritableComputedRef<string>;
|
||||
msg: ReturnType<typeof useMessage>;
|
||||
setThemePreference: (preference: ThemePreference) => void;
|
||||
appliedTheme: ComputedRef<ThemePreference>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理当前用户资料、偏好设置和密码修改状态。
|
||||
* 由工作台在初始化时创建,使资料页面与改密弹窗共享同一份状态和请求动作。
|
||||
*/
|
||||
export function useUserProfile(deps: UserProfileDeps) {
|
||||
const { t, locale, msg, setThemePreference, appliedTheme } = deps;
|
||||
|
||||
const isProfileLoading = ref(false);
|
||||
@@ -18,7 +34,7 @@ export function useWorkspaceProfile(deps: WorkspaceDeps) {
|
||||
const isChangingPassword = ref(false);
|
||||
const isProfileEditing = ref(false);
|
||||
const showPasswordModal = ref(false);
|
||||
const profileUser = ref<WorkspaceProfileForm>({
|
||||
const profileUser = ref<UserProfileForm>({
|
||||
id: 0,
|
||||
username: '',
|
||||
real_name: '',
|
||||
@@ -30,7 +46,7 @@ export function useWorkspaceProfile(deps: WorkspaceDeps) {
|
||||
language: 'zh-CN',
|
||||
theme_preference: 'system' as ThemePreference,
|
||||
});
|
||||
const originalProfile = ref<WorkspaceProfileForm | null>(null);
|
||||
const originalProfile = ref<UserProfileForm | null>(null);
|
||||
const passwordForm = ref({ current: '', new: '', confirm: '' });
|
||||
|
||||
const themeOptions: Array<{ value: ThemePreference; label: () => string }> = [
|
||||
@@ -67,9 +83,7 @@ export function useWorkspaceProfile(deps: WorkspaceDeps) {
|
||||
const fetchProfile = async () => {
|
||||
isProfileLoading.value = true;
|
||||
try {
|
||||
const data = await requestJson<Partial<WorkspaceProfileForm>>('/api/user/profile', {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
const data = await getEditableUserProfile();
|
||||
if (!data) {
|
||||
msg.error(t('workspace.profile.msg.loadFailed'));
|
||||
return;
|
||||
@@ -122,11 +136,7 @@ export function useWorkspaceProfile(deps: WorkspaceDeps) {
|
||||
setThemePreference(profileUser.value.theme_preference);
|
||||
try {
|
||||
isProfileSaving.value = true;
|
||||
await requestJson('/api/user/profile', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
await updateUserProfile(payload);
|
||||
msg.success(t('workspace.profile.msg.saved'));
|
||||
captureOriginalProfile();
|
||||
isProfileEditing.value = false;
|
||||
@@ -146,14 +156,7 @@ export function useWorkspaceProfile(deps: WorkspaceDeps) {
|
||||
}
|
||||
try {
|
||||
isChangingPassword.value = true;
|
||||
await requestJson('/api/user/change-password', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', ...getAuthHeaders() },
|
||||
body: JSON.stringify({
|
||||
current_password: passwordForm.value.current,
|
||||
new_password: passwordForm.value.new,
|
||||
}),
|
||||
});
|
||||
await changeUserPassword(passwordForm.value.current, passwordForm.value.new);
|
||||
msg.success(t('profile.passwordChanged') || 'Password changed successfully');
|
||||
passwordForm.value = { current: '', new: '', confirm: '' };
|
||||
showPasswordModal.value = false;
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* features/user/composables/user-profile.context.ts
|
||||
* 用途:定义个人资料页面和改密弹窗共享的注入上下文。
|
||||
* 依赖:useUserProfile 的返回契约与工作台提供的移动端/登出能力。
|
||||
* 逻辑:WorkspaceLayout 提供上下文;user 域组件只依赖此契约,不读取工作台注入 key。
|
||||
*/
|
||||
import type { InjectionKey } from 'vue';
|
||||
import type { UserProfileForm } from '../types/user-profile.types';
|
||||
import type { ThemePreference } from '@/shared/composables/useTheme';
|
||||
|
||||
export interface UserProfileContext {
|
||||
isMobile: boolean;
|
||||
handleLogout: () => void;
|
||||
isProfileLoading: boolean;
|
||||
isProfileSaving: boolean;
|
||||
isChangingPassword: boolean;
|
||||
isProfileEditing: boolean;
|
||||
showPasswordModal: boolean;
|
||||
CHANGE_PASSWORD_ENABLED: boolean;
|
||||
profileUser: UserProfileForm;
|
||||
passwordForm: { current: string; new: string; confirm: string };
|
||||
hasProfileUnsavedChanges: boolean;
|
||||
themeOptions: Array<{ value: ThemePreference; label: () => string }>;
|
||||
handleChangePasswordClick: () => void;
|
||||
startProfileEditing: () => void;
|
||||
cancelProfileEditing: () => void;
|
||||
saveProfile: () => Promise<void>;
|
||||
handleChangePassword: () => Promise<void>;
|
||||
}
|
||||
|
||||
export const USER_PROFILE_KEY: InjectionKey<UserProfileContext> = Symbol('user-profile');
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* features/user/index.ts
|
||||
* 用途:暴露用户域 HTTP 能力,避免其他 feature 直接依赖实现路径。
|
||||
* 依赖:user.api。
|
||||
* 逻辑:Chat 等使用方从此处或 user.api 导入当前用户资料和授权资源查询。
|
||||
*/
|
||||
export * from './api/user.api';
|
||||
export { useUserProfile } from './composables/useUserProfile';
|
||||
export type { UserProfileForm } from './types/user-profile.types';
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* features/user/types/user-profile.types.ts
|
||||
* 用途:定义个人资料编辑与密码修改的用户域类型和功能开关。
|
||||
* 依赖:shared/composables/useTheme。
|
||||
* 逻辑:useUserProfile、UserProfilePage 和 UserPasswordDialog 使用同一份资料契约。
|
||||
*/
|
||||
import type { ThemePreference } from '@/shared/composables/useTheme';
|
||||
|
||||
export interface UserProfileForm {
|
||||
id: number;
|
||||
username: string;
|
||||
real_name: string;
|
||||
email: string;
|
||||
phone_number: string;
|
||||
department: string;
|
||||
role: string;
|
||||
employee_id: string;
|
||||
language: string;
|
||||
theme_preference: ThemePreference;
|
||||
}
|
||||
|
||||
export const CHANGE_PASSWORD_ENABLED = true;
|
||||
@@ -0,0 +1,198 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/user/views/UserProfilePage.vue
|
||||
* 閻劑鈧棑绱扮仦鏇犮仛閸滃瞼绱潏鎴濈秼閸撳秶鏁ら幋鐤カ閺傛瑣鈧浇顕㈢懛鈧?娑撳顣介崑蹇撱偨閿涘苯鑻熼幓鎰返娣囶喗鏁肩€靛棛鐖滈崗銉ュ經閵? * 娓氭繆绂嗛敍姝秙er-profile.context閵嗕勾ucide 閸ョ偓鐖i妴涔倁e i18n閵? * 闁槒绶敍姘矝閻?/workspace/profile 鐠侯垳鏁遍幍鑳祰閿涘奔绲炬い鐢告桨閸滃奔绗熼崝鈥崇秺鐏?user feature閵? */
|
||||
import { inject } from 'vue';
|
||||
import {
|
||||
User, Mail, Building, CreditCard, Globe, Save, Palette,
|
||||
} from 'lucide-vue-next';
|
||||
import { USER_PROFILE_KEY } from '../composables/user-profile.context';
|
||||
|
||||
const userProfile = inject(USER_PROFILE_KEY)!;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="userProfile.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="userProfile.isMobile ? 'h-14 w-14 text-2xl' : ''">
|
||||
{{ (userProfile.profileUser.real_name || userProfile.profileUser.username || 'U').charAt(0).toUpperCase() }}
|
||||
</div>
|
||||
<div class="grid flex-1 text-left" :class="userProfile.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="userProfile.isMobile ? '' : ''">
|
||||
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.realName') : (userProfile.profileUser.username || '-') }}</div>
|
||||
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.real_name || userProfile.profileUser.username || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.employeeId') : (userProfile.profileUser.employee_id || '-') }}</div>
|
||||
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.employee_id || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.department') : (userProfile.profileUser.department || '-') }}</div>
|
||||
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.department || '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.role') : (userProfile.profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User')) }}</div>
|
||||
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.role === 'admin' ? ($t('profile.roleAdmin') || 'Administrator') : ($t('profile.roleUser') || 'User') }}</div>
|
||||
</div>
|
||||
<div :class="userProfile.isMobile ? 'col-span-2' : 'sm:col-span-2'">
|
||||
<div :class="userProfile.isMobile ? 'text-xs text-muted' : 'break-all text-lg font-semibold text-primary'">{{ userProfile.isMobile ? $t('profile.email') : (userProfile.profileUser.email || '-') }}</div>
|
||||
<div v-if="userProfile.isMobile" class="text-sm font-medium text-primary truncate">{{ userProfile.profileUser.email || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!userProfile.isMobile" class="flex shrink-0 items-center gap-2 self-start lg:ml-6">
|
||||
<button @click="userProfile.handleChangePasswordClick" class="btn-primary px-6 py-3 text-base">
|
||||
{{ $t('profile.changePassword') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="userProfile.isMobile" class="mt-4 flex items-center justify-center gap-4">
|
||||
<button @click="userProfile.handleChangePasswordClick" class="btn-primary flex-1 py-2.5 text-sm text-center">
|
||||
{{ $t('profile.changePassword') }}
|
||||
</button>
|
||||
<button @click="userProfile.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="userProfile.isMobile ? 'p-4' : ''">
|
||||
<div class="mb-8 flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between" :class="userProfile.isMobile ? 'mb-4 gap-2' : ''">
|
||||
<div class="flex items-center" :class="userProfile.isMobile ? 'w-full justify-center gap-2' : ''">
|
||||
<h3 class="flex items-center gap-3 text-3xl font-bold text-primary" :class="userProfile.isMobile ? 'text-lg gap-2' : ''">
|
||||
<User class="h-6 w-6 text-brand-500" :class="userProfile.isMobile ? 'h-4 w-4' : ''" />
|
||||
{{ $t('profile.basicInfo') }}
|
||||
</h3>
|
||||
<button v-if="userProfile.isMobile && !userProfile.isProfileEditing" @click="userProfile.startProfileEditing" class="btn-secondary px-3 py-1 text-xs">
|
||||
{{ $t('profile.edit') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="!userProfile.isMobile" class="mt-2 text-sm text-muted">
|
||||
{{ userProfile.isProfileEditing ? $t('profile.directEditHint') : $t('profile.switchEditHint') }}
|
||||
</p>
|
||||
<div v-if="!userProfile.isMobile" class="flex items-center gap-2">
|
||||
<button v-if="!userProfile.isProfileEditing" @click="userProfile.startProfileEditing" class="btn-secondary px-5 py-2.5 text-sm">
|
||||
{{ $t('profile.edit') }}
|
||||
</button>
|
||||
<template v-else>
|
||||
<button @click="userProfile.cancelProfileEditing" class="btn-secondary px-5 py-2.5 text-sm">
|
||||
{{ $t('profile.cancel') || 'Cancel' }}
|
||||
</button>
|
||||
<button
|
||||
@click="userProfile.saveProfile"
|
||||
:disabled="userProfile.isProfileSaving || !userProfile.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>{{ userProfile.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="userProfile.isMobile ? 'gap-3' : ''">
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.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="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
{{ userProfile.profileUser.username || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
|
||||
<CreditCard class="h-4 w-4" /> {{ $t('profile.employeeId') }}
|
||||
</label>
|
||||
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.employee_id" type="text" class="input-field" :class="userProfile.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="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
{{ userProfile.profileUser.employee_id || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
|
||||
<User class="h-4 w-4" /> {{ $t('profile.realName') }}
|
||||
</label>
|
||||
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.real_name" type="text" class="input-field" :class="userProfile.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="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
{{ userProfile.profileUser.real_name || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
|
||||
<Building class="h-4 w-4" /> {{ $t('profile.department') }}
|
||||
</label>
|
||||
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.department" type="text" class="input-field" :class="userProfile.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="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
{{ userProfile.profileUser.department || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
|
||||
<Mail class="h-4 w-4" /> {{ $t('profile.email') }}
|
||||
</label>
|
||||
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.email" type="email" class="input-field" :class="userProfile.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="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
{{ userProfile.profileUser.email || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-2 flex items-center gap-2 text-sm font-medium text-muted" :class="userProfile.isMobile ? 'text-xs mb-1' : ''">
|
||||
<Globe class="h-4 w-4" /> {{ $t('profile.phoneNumber') }}
|
||||
</label>
|
||||
<input v-if="userProfile.isProfileEditing" v-model="userProfile.profileUser.phone_number" type="text" class="input-field" :class="userProfile.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="userProfile.isMobile ? 'px-3 py-2 text-sm rounded-xl' : ''">
|
||||
{{ userProfile.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="userProfile.profileUser.language" :disabled="!userProfile.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">Thai</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 userProfile.themeOptions"
|
||||
:key="item.value"
|
||||
type="button"
|
||||
role="radio"
|
||||
:aria-checked="userProfile.profileUser.theme_preference === item.value"
|
||||
:disabled="!userProfile.isProfileEditing"
|
||||
class="segment-item"
|
||||
:class="userProfile.profileUser.theme_preference === item.value ? 'segment-item--active' : ''"
|
||||
@click="userProfile.profileUser.theme_preference = item.value"
|
||||
>
|
||||
{{ item.label() }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/components/WorkspaceModals.vue
|
||||
* 工作台弹窗:公告详情、修改密码、快捷问题删除、意见反馈。
|
||||
* 工作台弹窗:公告详情、快捷问题删除、意见反馈。
|
||||
*/
|
||||
import { inject } from 'vue';
|
||||
import { X } from 'lucide-vue-next';
|
||||
@@ -41,77 +41,6 @@ const ws = inject(WORKSPACE_KEY)! as any;
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="ws.CHANGE_PASSWORD_ENABLED && ws.showPasswordModal"
|
||||
class="dialog-overlay z-50 items-center"
|
||||
>
|
||||
<div class="dialog-panel max-w-md">
|
||||
<div class="dialog-header">
|
||||
<h3 class="section-title">{{ $t('profile.changePassword') || 'Change Password' }}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-icon-ds"
|
||||
:aria-label="$t('admin.close')"
|
||||
:disabled="ws.isChangingPassword"
|
||||
@click="ws.showPasswordModal = false"
|
||||
>
|
||||
<X class="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
<form @submit.prevent="ws.handleChangePassword">
|
||||
<div class="dialog-body">
|
||||
<div>
|
||||
<label class="label-field">{{ $t('profile.currentPassword') || 'Current Password' }}</label>
|
||||
<input
|
||||
v-model="ws.passwordForm.current"
|
||||
type="password"
|
||||
class="input-field mt-1"
|
||||
:disabled="ws.isChangingPassword"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label-field">{{ $t('profile.newPassword') || 'New Password' }}</label>
|
||||
<input
|
||||
v-model="ws.passwordForm.new"
|
||||
type="password"
|
||||
class="input-field mt-1"
|
||||
:disabled="ws.isChangingPassword"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="label-field">{{ $t('profile.confirmPassword') || 'Confirm Password' }}</label>
|
||||
<input
|
||||
v-model="ws.passwordForm.confirm"
|
||||
type="password"
|
||||
class="input-field mt-1"
|
||||
:disabled="ws.isChangingPassword"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<button
|
||||
type="button"
|
||||
:disabled="ws.isChangingPassword"
|
||||
@click="ws.showPasswordModal = false"
|
||||
class="btn-secondary flex-1 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{{ $t('profile.cancel') || 'Cancel' }}
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
:disabled="ws.isChangingPassword"
|
||||
class="btn-primary flex-1 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{{ ws.isChangingPassword ? $t('profile.changingPassword') : ($t('profile.changePassword') || 'Update') }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DeleteConfirmDialog
|
||||
v-model="ws.showDeleteQuickQuestionDialog"
|
||||
:title="$t('workspace.quickQuestions.deleteDialog.title')"
|
||||
|
||||
@@ -15,7 +15,7 @@ import { useChatHistory } from '@/features/chat/composables/useChatHistory';
|
||||
import { useWorkspaceHome } from './useWorkspaceHome';
|
||||
import { useWorkspaceLocale } from './useWorkspaceLocale';
|
||||
import { useWorkspaceNavigation } from './useWorkspaceNavigation';
|
||||
import { useWorkspaceProfile } from './useWorkspaceProfile';
|
||||
import { useUserProfile } from '@/features/user/composables/useUserProfile';
|
||||
import { useWorkspaceSchedule } from './useWorkspaceSchedule';
|
||||
import { useWorkspaceSession } from './useWorkspaceSession';
|
||||
|
||||
@@ -44,7 +44,7 @@ export function useWorkspace() {
|
||||
});
|
||||
sessionRef.handleLogout = session.handleLogout;
|
||||
|
||||
const profile = useWorkspaceProfile(deps);
|
||||
const profile = useUserProfile(deps);
|
||||
const schedule = useWorkspaceSchedule(deps);
|
||||
const history = useChatHistory();
|
||||
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
<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>
|
||||
@@ -2,7 +2,6 @@
|
||||
* features/workspace/types/workspace.types.ts
|
||||
* 工作台相关 TypeScript 类型与业务常量。
|
||||
*/
|
||||
import type { ThemePreference } from '@/shared/composables/useTheme';
|
||||
import type { WecomMatchField } from '@/shared/utils/wecom';
|
||||
import type { WecomLoginDialogContent } from '@/shared/utils/wecom';
|
||||
|
||||
@@ -73,19 +72,6 @@ export interface WecomBindPromptState {
|
||||
error: string;
|
||||
}
|
||||
|
||||
export interface WorkspaceProfileForm {
|
||||
id: number;
|
||||
username: string;
|
||||
real_name: string;
|
||||
email: string;
|
||||
phone_number: string;
|
||||
department: string;
|
||||
role: string;
|
||||
employee_id: string;
|
||||
language: string;
|
||||
theme_preference: ThemePreference;
|
||||
}
|
||||
|
||||
export type { ChatCrossAgentHistoryItem as WorkspaceChatHistoryItem } from '@/features/chat/types/chat.types';
|
||||
|
||||
export type { WecomLoginDialogContent };
|
||||
@@ -101,4 +87,3 @@ export const SECTION_TITLE_KEY_MAP: Record<string, string> = {
|
||||
export const DEFAULT_POST_LOGIN_AGENT_ID = 16;
|
||||
export const KB_ACCESS_DENIED_MESSAGE = '需要管理员权限才能访问知识库。';
|
||||
export const WS_SCHEDULE_FILTER_INPUT_CLASS = 'admin-table-filter-input text-xs py-1.5 px-2';
|
||||
export const CHANGE_PASSWORD_ENABLED = true;
|
||||
@@ -11,9 +11,12 @@ import { WORKSPACE_KEY } from '../composables/workspace.context';
|
||||
import WorkspaceSidebar from '../components/WorkspaceSidebar.vue';
|
||||
import WorkspaceModals from '../components/WorkspaceModals.vue';
|
||||
import { ExternalSystemLinks } from '@/features/sso';
|
||||
import UserPasswordDialog from '@/features/user/components/UserPasswordDialog.vue';
|
||||
import { USER_PROFILE_KEY, type UserProfileContext } from '@/features/user/composables/user-profile.context';
|
||||
|
||||
const ws = useWorkspace();
|
||||
provide(WORKSPACE_KEY, ws);
|
||||
provide(USER_PROFILE_KEY, ws as UserProfileContext);
|
||||
|
||||
const mobileTabs = [
|
||||
{ key: 'applications', path: WORKSPACE_PATHS.applications, icon: LayoutGrid, labelKey: 'workspace.mobileTabs.applications' },
|
||||
@@ -72,5 +75,6 @@ const mobileTabs = [
|
||||
</div>
|
||||
|
||||
<WorkspaceModals />
|
||||
<UserPasswordDialog />
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user