From 74c66409bdf6144a2ffc37faf5df2fa68a220bee Mon Sep 17 00:00:00 2001 From: prr <3099672575@qq.com> Date: Wed, 6 Nov 2024 19:15:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=87=AA=E8=BA=AB=E8=B5=84=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/auto-imports.d.ts | 3 +- frontend/components.d.ts | 1 + frontend/src/components/builtin/FileList.vue | 22 +++- .../src/components/chat/ChatUserSetting.vue | 114 +++++++++++++----- frontend/src/components/oa/FilePwd.vue | 33 +++++ .../src/components/setting/SetFilePwd.vue | 6 +- frontend/src/components/setting/SetSystem.vue | 2 +- frontend/src/system/config.ts | 5 +- 8 files changed, 148 insertions(+), 38 deletions(-) create mode 100644 frontend/src/components/oa/FilePwd.vue diff --git a/frontend/auto-imports.d.ts b/frontend/auto-imports.d.ts index 2d82a80..87319db 100644 --- a/frontend/auto-imports.d.ts +++ b/frontend/auto-imports.d.ts @@ -3,7 +3,6 @@ // @ts-nocheck // noinspection JSUnusedGlobalSymbols // Generated by unplugin-auto-import -// biome-ignore lint: disable export {} declare global { const EffectScope: typeof import('vue')['EffectScope'] @@ -72,6 +71,6 @@ declare global { // for type re-export declare global { // @ts-ignore - export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue' + export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue' import('vue') } diff --git a/frontend/components.d.ts b/frontend/components.d.ts index 522afce..c6ed83f 100644 --- a/frontend/components.d.ts +++ b/frontend/components.d.ts @@ -92,6 +92,7 @@ declare module 'vue' { FileIconIs: typeof import('./src/components/builtin/FileIconIs.vue')['default'] FileList: typeof import('./src/components/builtin/FileList.vue')['default'] FileProps: typeof import('./src/components/builtin/FileProps.vue')['default'] + FilePwd: typeof import('./src/components/oa/FilePwd.vue')['default'] FileTree: typeof import('./src/components/builtin/FileTree.vue')['default'] FileViewer: typeof import('./src/components/builtin/FileViewer.vue')['default'] IframeFile: typeof import('./src/components/window/IframeFile.vue')['default'] diff --git a/frontend/src/components/builtin/FileList.vue b/frontend/src/components/builtin/FileList.vue index 9a6dffd..501f28f 100644 --- a/frontend/src/components/builtin/FileList.vue +++ b/frontend/src/components/builtin/FileList.vue @@ -408,8 +408,26 @@ function handleRightClick(mouse: MouseEvent, item: OsFileWithoutContent, index: config: { path: item.path, }, - width: 500, - height: 500, + width: 450, + height: 280, + center: true, + }); + win.show(); + }, + } + ) + menuArr.push( + { + label: '文件加密', + click: () => { + const win = new BrowserWindow({ + title: '文件加密', + content: "FilePwd", + config: { + path: item.path, + }, + width: 400, + height: 200, center: true, }); win.show(); diff --git a/frontend/src/components/chat/ChatUserSetting.vue b/frontend/src/components/chat/ChatUserSetting.vue index dba1730..baa69d5 100644 --- a/frontend/src/components/chat/ChatUserSetting.vue +++ b/frontend/src/components/chat/ChatUserSetting.vue @@ -5,35 +5,28 @@ import { useChatStore } from "@/stores/chat"; import { notifyError, notifySuccess } from "@/util/msg"; import { fetchGet, fetchPost, getSystemConfig, setSystemKey } from "@/system/config"; const store = useChatStore() -const form = ref({ - nickname: '', -}) +// const form = ref({ +// nickname: '', +// }) interface ImgItem { url: string; name: string; } const editType = ref(0) const userInfo = getSystemConfig().userInfo +const userInfoForm: {[key: string]: any} = reactive({ + nickname: '', + phone: '', + email: '', + desc: '' +}) const dialogShow = ref(false) let imgList = reactive([]) let pos = ref(0) - +// 换头像 const showChange = (val: boolean) =>{ dialogShow.value = val } -const toChangeHead = async ()=>{ - let res = await fetchGet(`${userInfo.url}/files/saveavatar?id=${userInfo.id}&name=${imgList[pos.value]?.name}`) - if (!res.ok) { - notifyError("头像换取失败") - } else { - const response = await res.json() - notifySuccess(response?.message || '头像换取成功') - userInfo.avatar = imgList[pos.value]?.name - store.userInfo.avatar = userInfo.url + '/upload/avatar/' + userInfo.avatar - setSystemKey('userInfo', userInfo) - } - showChange(false) -} // 获取头像列表 const getHeadList = async () => { let res = await fetchGet (`${userInfo.url}/files/avatarlist`) @@ -49,12 +42,62 @@ const getHeadList = async () => { } } } -// 换头像 const chooseImg = (index: number) => { pos.value = index } -const onSubmit = async () => { - console.log('提交'); +const toChangeHead = async ()=>{ + let res = await fetchGet(`${userInfo.url}/files/saveavatar?id=${userInfo.id}&name=${imgList[pos.value]?.name}`) + if (!res.ok) { + notifyError("头像换取失败") + } else { + const response = await res.json() + notifySuccess(response?.message || '头像换取成功') + userInfo.avatar = imgList[pos.value]?.name + store.userInfo.avatar = userInfo.url + '/upload/avatar/' + userInfo.avatar + setSystemKey('userInfo', userInfo) + } + showChange(false) +} +//修改资料 +const userRef:any = ref(null) +const userRule = { + nickname: [ + { required: true, message: '昵称不能为空', trigger: 'blur'}, + { min: 2, max: 10, message: '昵称长度应该在2到10位', trigger: 'blur'} + ], + phone: [ + { required: true, message: '手机号不能为空', trigger: 'blur'}, + { pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确', trigger: 'blur'} + ], + email: [ + { required: true, message: '邮箱不能为空', trigger: 'blur'}, + { pattern: /^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$/, message: '邮箱格式不正确', trigger: 'blur'} + ] + // desc: [ + // { required: true, message: '昵称不能为空', trigger: 'blur'}, + // { min: 2, max: 10, message: '昵称长度应该在2到10位', trigger: 'blur'} + // ], +} +const onSubmit = async () => { + try { + for (const key in userInfoForm) { + userInfo[key] = userInfoForm[key] + } + const head = { + 'AuthorizationAdmin': userInfo.token + } + await userRef.value.validate() + const res = await fetchPost(`${userInfo.url}/user/editdata?id=${userInfo.id}`, JSON.stringify(userInfoForm), head) + const result = await res.json() + if (result?.success) { + notifySuccess(result?.message) + setSystemKey('userInfo', userInfo) + } else { + notifyError(result?.message) + } + }catch (e) { + console.log(e) + } } //修改密码 const passwordForm = reactive({ @@ -73,7 +116,9 @@ const rules = { ], confirmPassword: [ { required: true, message: '请再次输入密码', trigger: 'blur' }, - { validator: (value:any, callback:any) => { + { validator: (rule: any, value:any, callback:any) => { + console.log('rule:', rule); + if (value === '') { callback(new Error('请再次输入密码')); } else if (value !== passwordForm.newPassword) { @@ -103,6 +148,9 @@ const toChangePwd = async () => { } onMounted(()=>{ getHeadList() + for (const key in userInfoForm) { + userInfoForm[key] = userInfo[key] + } store.userInfo.avatar = userInfo.url + '/upload/avatar/' + userInfo.avatar }) @@ -113,21 +161,21 @@ onMounted(()=>{
修改密码
- + - - + + - - + + - - + + - - + + 保存 @@ -190,6 +238,12 @@ onMounted(()=>{ \ No newline at end of file diff --git a/frontend/src/components/setting/SetFilePwd.vue b/frontend/src/components/setting/SetFilePwd.vue index b6a563b..bc8a374 100644 --- a/frontend/src/components/setting/SetFilePwd.vue +++ b/frontend/src/components/setting/SetFilePwd.vue @@ -3,7 +3,7 @@
- +
@@ -26,6 +26,7 @@ import { fetchGet, getApiUrl, setSystemKey, getSystemConfig } from "@/system/con import { notifySuccess, notifyError } from "@/util/msg"; const filePwd = ref('') const setPwd = ref(false) +const config = getSystemConfig() const params = { isPwd: 1, pwd: '', @@ -58,9 +59,12 @@ async function toSetFilePwd() { async function clearPwd() { setPwd.value = false filePwd.value = '' + params.isPwd = 0 await fetchGet(`${getApiUrl()}/file/changeispwd?ispwd=0`) + setSystemKey('file',params) } onMounted(()=>{ + params.isPwd = config.file.isPwd setPwd.value = params.isPwd ? true : false }) diff --git a/frontend/src/components/setting/SetSystem.vue b/frontend/src/components/setting/SetSystem.vue index 34cf6a4..a4f3186 100644 --- a/frontend/src/components/setting/SetSystem.vue +++ b/frontend/src/components/setting/SetSystem.vue @@ -47,7 +47,7 @@ {{ t("confirm") }}
- +
diff --git a/frontend/src/system/config.ts b/frontend/src/system/config.ts index 3d1628c..981efe8 100644 --- a/frontend/src/system/config.ts +++ b/frontend/src/system/config.ts @@ -234,7 +234,7 @@ export function fetchGet(url: string, headerConfig?: {[key: string]: string}) { }) } } -export function fetchPost(url: string, data: any) { +export function fetchPost(url: string, data: any, headerConfig?: {[key: string]: string}) { const config = getSystemConfig(); if (config.userType == 'person') { return fetch(url, { @@ -248,7 +248,8 @@ export function fetchPost(url: string, data: any) { body: data, headers: { 'ClientID': getClientId(), - 'Authorization': config.userInfo.token + 'Authorization': config.userInfo.token, + ...headerConfig } }) }