diff --git a/ui/package.json b/ui/package.json index f391ddaeb..d0c3394c5 100644 --- a/ui/package.json +++ b/ui/package.json @@ -27,6 +27,7 @@ "@wecom/jssdk": "^2.3.1", "axios": "^1.8.4", "cropperjs": "^1.6.2", + "crypto-js": "^4.2.0", "dingtalk-jsapi": "^3.1.0", "echarts": "^5.6.0", "element-plus": "^2.10.2", @@ -60,6 +61,7 @@ }, "devDependencies": { "@tsconfig/node22": "^22.0.1", + "@types/crypto-js": "^4.2.2", "@types/file-saver": "^2.0.7", "@types/node": "^22.14.0", "@types/nprogress": "^0.2.3", diff --git a/ui/src/api/chat/chat.ts b/ui/src/api/chat/chat.ts index bd1e8f554..4bb591576 100644 --- a/ui/src/api/chat/chat.ts +++ b/ui/src/api/chat/chat.ts @@ -112,10 +112,11 @@ const ldapLogin: ( /** * 获取验证码 + * @param username * @param loading 接口加载器 */ -const getCaptcha: (loading?: Ref) => Promise> = (loading) => { - return get('/captcha', undefined, loading) +const getCaptcha: (username?: string, loading?: Ref) => Promise> = (username, loading) => { + return get('/captcha', {username: username}, loading) } /** diff --git a/ui/src/api/type/chat.ts b/ui/src/api/type/chat.ts index aac3b8faf..e5691b537 100644 --- a/ui/src/api/type/chat.ts +++ b/ui/src/api/type/chat.ts @@ -11,6 +11,7 @@ interface ChatProfile { authentication_type?: 'password' | 'login' // 登录类型 login_value?: Array + max_attempts?: number } interface ChatUserProfile { diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.ts index 4419a9a8d..e9608e87f 100644 --- a/ui/src/utils/common.ts +++ b/ui/src/utils/common.ts @@ -1,4 +1,5 @@ -import { nanoid } from 'nanoid' +import {nanoid} from 'nanoid' + /** * 数字处理 */ @@ -7,6 +8,7 @@ export function toThousands(num: any) { return n.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') }) } + export function numberFormat(num: number) { return num < 1000 ? toThousands(num) : toThousands((num / 1000).toFixed(1)) + 'k' } @@ -25,6 +27,7 @@ export function filesize(size: number) { // 头像 export const defaultIcon = '/${window.MaxKB.prefix}/favicon.ico' + export function isAppIcon(url: string | undefined) { return url === defaultIcon ? '' : url } @@ -65,6 +68,7 @@ export function getImgUrl(name: string) { : 'unknown' return new URL(`../assets/fileType/${type}-icon.svg`, import.meta.url).href } + // 是否是白名单后缀 export function isRightType(name: string, type: string) { return typeList[type].includes(fileType(name).toLowerCase()) @@ -94,7 +98,7 @@ interface LoadScriptOptions { } export const loadScript = (url: string, options: LoadScriptOptions = {}): Promise => { - const { jsId, forceReload = false } = options + const {jsId, forceReload = false} = options const scriptId = jsId || `script-${btoa(url).slice(0, 12)}` // 生成唯一 ID return new Promise((resolve, reject) => { @@ -144,12 +148,14 @@ export function getNormalizedUrl(url: string) { } return url } + export function getFileUrl(fileId?: string) { if (fileId) { return `${window.MaxKB.prefix}/oss/file/${fileId}` } return '' } + export const resetUrl = (url: string, defaultUrl?: string) => { if (url && url.startsWith('./')) { return `${window.MaxKB.prefix}/${url.substring(2)}` diff --git a/ui/src/views/chat/user-login/index.vue b/ui/src/views/chat/user-login/index.vue index fac09fedf..a3559c6da 100644 --- a/ui/src/views/chat/user-login/index.vue +++ b/ui/src/views/chat/user-login/index.vue @@ -180,6 +180,7 @@ import QrCodeTab from '@/views/chat/user-login/scanCompinents/QrCodeTab.vue' import {MsgConfirm, MsgError} from '@/utils/message.ts' import PasswordAuth from '@/views/chat/auth/component/password.vue' import {isAppIcon} from '@/utils/common' +import CryptoJS from "crypto-js"; useResize() const router = useRouter() @@ -249,6 +250,7 @@ const loginHandle = () => { }) }) } else { + loginForm.value.password = CryptoJS.MD5(loginForm.value.password.trim()).toString(CryptoJS.enc.Hex) chatUser.login(loginForm.value).then((ok) => { router.push({ name: 'chat', diff --git a/ui/src/views/login/index.vue b/ui/src/views/login/index.vue index aa9208bbe..d8e366df7 100644 --- a/ui/src/views/login/index.vue +++ b/ui/src/views/login/index.vue @@ -126,7 +126,7 @@