From b20a71b50836978bedfaa129761f33c2e73c0c90 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Mon, 26 Jan 2026 00:34:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E7=9A=84token=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +-- .../com/bx/implatform/config/MvcConfig.java | 2 +- .../implatform/controller/FileController.java | 2 +- .../service/impl/FileServiceImpl.java | 7 ++-- .../components/file-upload/file-upload.vue | 34 +------------------ .../components/image-upload/image-upload.vue | 9 +---- 6 files changed, 7 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 0179c9a..86237e1 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ - 框架和组件版本全面升级: jdk17、springboot3.3、node18等 - 部分界面,功能、性能优化 - #### 在线体验 web端:https://www.boxim.online @@ -48,8 +47,7 @@ https://www.yuque.com/u1475064/imk5n2/qtezcg32q1d0dr29#SbvXq #### 付费服务 -商业版源码: https://www.yuque.com/u1475064/imk5n2/qtezcg32q1d0dr29 -环境搭建: https://www.yuque.com/u1475064/imk5n2/qgq5cvgmavallqnl +商业版源码授权: https://www.yuque.com/u1475064/imk5n2/qtezcg32q1d0dr29 #### 项目结构 | 模块 | 功能 | diff --git a/im-platform/src/main/java/com/bx/implatform/config/MvcConfig.java b/im-platform/src/main/java/com/bx/implatform/config/MvcConfig.java index 2dee3c9..286461a 100644 --- a/im-platform/src/main/java/com/bx/implatform/config/MvcConfig.java +++ b/im-platform/src/main/java/com/bx/implatform/config/MvcConfig.java @@ -21,7 +21,7 @@ public class MvcConfig implements WebMvcConfigurer { public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(xssInterceptor).addPathPatterns("/**").excludePathPatterns("/error"); registry.addInterceptor(authInterceptor).addPathPatterns("/**") - .excludePathPatterns("/login", "/logout", "/register", "/refreshToken", "/swagger/**", "/v3/api-docs/**", + .excludePathPatterns("/login", "/logout", "/register", "/refreshToken","/*/upload", "/swagger/**", "/v3/api-docs/**", "/swagger-resources/**", "/swagger-ui.html", "/swagger-ui/**", "/doc.html"); } diff --git a/im-platform/src/main/java/com/bx/implatform/controller/FileController.java b/im-platform/src/main/java/com/bx/implatform/controller/FileController.java index e9c0856..1381b09 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/FileController.java +++ b/im-platform/src/main/java/com/bx/implatform/controller/FileController.java @@ -26,7 +26,7 @@ public class FileController { @PostMapping("/image/upload") public Result uploadImage(@RequestParam("file") MultipartFile file, @RequestParam(defaultValue = "true") Boolean isPermanent, @RequestParam(defaultValue = "50") Long thumbSize) { - return ResultUtils.success(fileService.uploadImage(file, isPermanent,thumbSize)); + return ResultUtils.success(fileService.uploadImage(file, isPermanent, thumbSize)); } @Operation(summary = "上传文件", description = "上传文件,上传后返回文件url") diff --git a/im-platform/src/main/java/com/bx/implatform/service/impl/FileServiceImpl.java b/im-platform/src/main/java/com/bx/implatform/service/impl/FileServiceImpl.java index 9eb4ce5..66dca5f 100644 --- a/im-platform/src/main/java/com/bx/implatform/service/impl/FileServiceImpl.java +++ b/im-platform/src/main/java/com/bx/implatform/service/impl/FileServiceImpl.java @@ -12,7 +12,6 @@ import com.bx.implatform.enums.ResultCode; import com.bx.implatform.exception.GlobalException; import com.bx.implatform.mapper.FileInfoMapper; import com.bx.implatform.service.FileService; -import com.bx.implatform.session.SessionContext; import com.bx.implatform.thirdparty.MinioService; import com.bx.implatform.util.FileUtil; import com.bx.implatform.util.ImageUtil; @@ -59,7 +58,6 @@ public class FileServiceImpl extends ServiceImpl imple @Override public String uploadFile(MultipartFile file) { try { - Long userId = SessionContext.getSession().getUserId(); // 文件名长度校验 checkFileNameLength(file); // 大小校验 @@ -84,7 +82,7 @@ public class FileServiceImpl extends ServiceImpl imple String url = generUrl(FileType.FILE, fileName); // 保存文件 saveFileInfo(file, md5, url); - log.info("文件文件成功,用户id:{},url:{}", userId, url); + log.info("文件文件成功,url:{}", url); return url; } catch (IOException e) { log.error("上传图片失败,{}", e.getMessage(), e); @@ -96,7 +94,6 @@ public class FileServiceImpl extends ServiceImpl imple @Override public UploadImageVO uploadImage(MultipartFile file, Boolean isPermanent,Long thumbSize) { try { - Long userId = SessionContext.getSession().getUserId(); // 文件名长度校验 checkFileNameLength(file); // 大小校验 @@ -150,7 +147,7 @@ public class FileServiceImpl extends ServiceImpl imple // 保存文件信息,由于缩略图不允许删除,此时原图也不允许删除 saveImageFileInfo(file, md5, vo.getOriginUrl(), vo.getThumbUrl(), true); } - log.info("文件图片成功,用户id:{},url:{}", userId, vo.getOriginUrl()); + log.info("文件图片成功,url:{}", vo.getOriginUrl()); return vo; } catch (IOException e) { log.error("上传图片失败,{}", e.getMessage(), e); diff --git a/im-uniapp/components/file-upload/file-upload.vue b/im-uniapp/components/file-upload/file-upload.vue index c364ffd..f379718 100644 --- a/im-uniapp/components/file-upload/file-upload.vue +++ b/im-uniapp/components/file-upload/file-upload.vue @@ -17,10 +17,7 @@ export default { fileMap: new Map(), option: { url: UNI_APP.BASE_URL + '/file/upload', - name: 'file', - header: { - accessToken: uni.getStorageSync('loginInfo').accessToken - } + name: 'file' } } }, @@ -59,17 +56,6 @@ export default { if (res.code == 200) { // 上传成功 this.onOk(file, res); - } else if (res.code == 401) { - // token已过期,重新获取token - this.refreshToken().then((res) => { - let newToken = res.data.accessToken; - this.option.header.accessToken = newToken; - this.$refs.lsjUpload.setData(this.option); - // 重新上传 - this.$refs.lsjUpload.upload(file.name); - }).catch(() => { - this.onError(file, res); - }) } else { // 上传失败 this.onError(file, res); @@ -95,24 +81,6 @@ export default { this.fileMap.delete(file.path); this.$refs.lsjUpload.clear(file.name); this.onError && this.onError(file, res); - }, - refreshToken() { - return new Promise((resolve, reject) => { - let loginInfo = uni.getStorageSync('loginInfo') - uni.request({ - method: 'PUT', - url: UNI_APP.BASE_URL + '/refreshToken', - header: { - refreshToken: loginInfo.refreshToken - }, - success: (res) => { - resolve(res.data); - }, - fail: (res) => { - reject(res); - } - }) - }) } } diff --git a/im-uniapp/components/image-upload/image-upload.vue b/im-uniapp/components/image-upload/image-upload.vue index 74410da..6764073 100644 --- a/im-uniapp/components/image-upload/image-upload.vue +++ b/im-uniapp/components/image-upload/image-upload.vue @@ -10,11 +10,7 @@ import UNI_APP from '@/.env.js' export default { name: "image-upload", data() { - return { - uploadHeaders: { - "accessToken": uni.getStorageSync('loginInfo').accessToken - } - } + return {} }, props: { maxCount: { @@ -70,9 +66,6 @@ export default { let action = `/image/upload?isPermanent=${this.isPermanent}&thumbSize=${this.thumbSize}` uni.uploadFile({ url: UNI_APP.BASE_URL + action, - header: { - accessToken: uni.getStorageSync("loginInfo").accessToken - }, filePath: file.path, // 要上传文件资源的路径 name: 'file', success: (res) => {