36 changed files with 489 additions and 569 deletions
@ -1,93 +1,67 @@ |
|||
# 盒子IM商业版后台 |
|||
# 盒子IM后台管理 |
|||
|
|||
#### 介绍 |
|||
本项目为盒子IM后台管理,主要为盒子IM提供用户管理、群组管理、消息管理、敏感词管理等后台功能。 |
|||
|
|||
盒子IM前台代码地址:https://gitee.com/bluexsx/box-im |
|||
详细文档: https://www.yuque.com/u1475064/mufu2a |
|||
|
|||
## Getting started |
|||
|
|||
To make it easy for you to get started with GitLab, here's a list of recommended next steps. |
|||
#### 基于maku框架 |
|||
为了减少重复工作,达到快速开发目的,本项目选择了一款优秀的开源脚手架-maku进行二次开发。 |
|||
|
|||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! |
|||
maku的仓库: |
|||
https://gitee.com/makunet/maku-boot |
|||
https://gitee.com/makunet/maku-admin |
|||
|
|||
## Add your files |
|||
maku的文档: |
|||
https://maku.net/docs/maku-boot/index |
|||
|
|||
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files |
|||
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: |
|||
#### 框架改造说明 |
|||
为了更好地与盒子IM的业务相结合,同时保持代码的简洁性,对ruoyi-vue-plus框架进行了以下改造: |
|||
1. 移除了定时任务、监控、工作流模块 |
|||
2. 添加minio模块替代原先的oss模块 |
|||
3. 加入了ruoyi-im模块,此模块即为盒子IM的核心后台模块 |
|||
4. 为了兼容历史数据,逻辑删除值由'2'修改为'1' |
|||
|
|||
``` |
|||
cd existing_repo |
|||
git remote add origin http://113.45.141.159:8099/commerce/box-im-admin-ry.git |
|||
git branch -M main |
|||
git push -uf origin main |
|||
``` |
|||
|
|||
## Integrate with your tools |
|||
|
|||
- [ ] [Set up project integrations](http://113.45.141.159:8099/commerce/box-im-admin-ry/-/settings/integrations) |
|||
|
|||
## Collaborate with your team |
|||
|
|||
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) |
|||
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) |
|||
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) |
|||
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) |
|||
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) |
|||
|
|||
## Test and Deploy |
|||
|
|||
Use the built-in continuous integration in GitLab. |
|||
|
|||
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) |
|||
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) |
|||
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) |
|||
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) |
|||
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) |
|||
|
|||
*** |
|||
|
|||
# Editing this README |
|||
#### 本地快速启动 |
|||
|
|||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. |
|||
1.安装运行环境 |
|||
- 安装node:v18.19.0 |
|||
- 安装jdk:17 |
|||
- 安装maven:3.9.6 |
|||
- 安装mysql:8.0,密码分别为root/root,创建名为im_admin的数据库,并执行db/im-admin.sql |
|||
- 安装redis:6.2 |
|||
- 安装minio:RELEASE.2024-xx,使用默认账号、密码、端口 |
|||
|
|||
## Suggestions for a good README |
|||
注: 盒子IM的后台服务同时还依赖im-platform的数据库,请在启动前先初始化该数据库 |
|||
|
|||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. |
|||
|
|||
## Name |
|||
Choose a self-explaining name for your project. |
|||
|
|||
## Description |
|||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. |
|||
|
|||
## Badges |
|||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. |
|||
|
|||
## Visuals |
|||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. |
|||
|
|||
## Installation |
|||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. |
|||
|
|||
## Usage |
|||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. |
|||
2.启动后端服务 |
|||
进入 im-admin目录,打开控制台 |
|||
``` |
|||
mvn clean package |
|||
java -jar ./maku-server/target/im-admin.jar |
|||
``` |
|||
|
|||
## Support |
|||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. |
|||
3.启动前端 |
|||
进入 maku-admin目录,打开控制台 |
|||
``` |
|||
npm install |
|||
npm run dev |
|||
``` |
|||
访问 http://localhost:3000 |
|||
|
|||
## Roadmap |
|||
If you have ideas for releases in the future, it is a good idea to list them in the README. |
|||
#### 界面截图: |
|||
 |
|||
|
|||
## Contributing |
|||
State if you are open to contributions and what your requirements are for accepting them. |
|||
 |
|||
|
|||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. |
|||
 |
|||
|
|||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. |
|||
 |
|||
|
|||
## Authors and acknowledgment |
|||
Show your appreciation to those who have contributed to the project. |
|||
 |
|||
|
|||
## License |
|||
For open source projects, say how it is licensed. |
|||
|
|||
## Project status |
|||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. |
|||
#### 点下star吧 |
|||
如果项目对您有帮助,请点亮右上方的star,支持一下作者吧! |
|||
@ -1,244 +1,88 @@ |
|||
<template> |
|||
<div> |
|||
<el-upload |
|||
v-if="type === 'url'" |
|||
:action="upload.url" |
|||
:before-upload="handleBeforeUpload" |
|||
:on-success="handleUploadSuccess" |
|||
:on-error="handleUploadError" |
|||
class="editor-img-uploader" |
|||
name="file" |
|||
:show-file-list="false" |
|||
:headers="upload.headers" |
|||
> |
|||
<i ref="uploadRef"></i> |
|||
</el-upload> |
|||
</div> |
|||
<div class="editor"> |
|||
<quill-editor |
|||
ref="quillEditorRef" |
|||
v-model:content="content" |
|||
content-type="html" |
|||
:options="options" |
|||
:style="styles" |
|||
@text-change="(e: any) => $emit('update:modelValue', content)" |
|||
/> |
|||
</div> |
|||
<div style="border: 1px solid #ccc; z-index: 100"> |
|||
<!-- 工具栏 --> |
|||
<Toolbar :editor="editorRef" :mode="mode" style="border-bottom: 1px solid #ccc" /> |
|||
<!-- 编辑器 --> |
|||
<Editor :model-value="modelValue" :style="style" :disabled="disabled" :default-config="editorConfig" |
|||
:mode="mode" @on-created="handleCreated" @on-change="handleChange" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import '@vueup/vue-quill/dist/vue-quill.snow.css'; |
|||
|
|||
import { QuillEditor, Quill } from '@vueup/vue-quill'; |
|||
import { propTypes } from '@/utils/propTypes'; |
|||
<script lang="ts" setup name="MaEditor"> |
|||
import '@wangeditor/editor/dist/css/style.css' |
|||
import { onBeforeUnmount, shallowRef } from 'vue' |
|||
import { Editor, Toolbar } from '@wangeditor/editor-for-vue' |
|||
import { IDomEditor, IEditorConfig } from '@wangieditor/editor' |
|||
import { globalHeaders } from '@/utils/request'; |
|||
|
|||
defineEmits(['update:modelValue']); |
|||
import axios from 'axios'; |
|||
|
|||
const props = defineProps({ |
|||
/* 编辑器的内容 */ |
|||
modelValue: propTypes.string, |
|||
/* 高度 */ |
|||
height: propTypes.number.def(400), |
|||
/* 最小高度 */ |
|||
minHeight: propTypes.number.def(400), |
|||
/* 只读 */ |
|||
readOnly: propTypes.bool.def(false), |
|||
/* 上传文件大小限制(MB) */ |
|||
fileSize: propTypes.number.def(5), |
|||
/* 类型(base64格式、url格式) */ |
|||
type: propTypes.string.def('url') |
|||
}); |
|||
|
|||
const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
|||
|
|||
const upload = reactive<UploadOption>({ |
|||
headers: globalHeaders(), |
|||
url: import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload' |
|||
}); |
|||
const quillEditorRef = ref(); |
|||
const uploadRef = ref<HTMLDivElement>(); |
|||
modelValue: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
mode: { |
|||
type: String, |
|||
default: 'default' // 可选值:[default | simple] |
|||
}, |
|||
placeholder: { |
|||
type: String, |
|||
default: '' |
|||
}, |
|||
style: { |
|||
type: String, |
|||
default: 'height: 400px;' |
|||
}, |
|||
disabled: { |
|||
type: Boolean, |
|||
default: false |
|||
} |
|||
}) |
|||
|
|||
const options = ref<any>({ |
|||
theme: 'snow', |
|||
bounds: document.body, |
|||
debug: 'warn', |
|||
modules: { |
|||
// 工具栏配置 |
|||
toolbar: { |
|||
container: [ |
|||
['bold', 'italic', 'underline', 'strike'], // 加粗 斜体 下划线 删除线 |
|||
['blockquote', 'code-block'], // 引用 代码块 |
|||
[{ list: 'ordered' }, { list: 'bullet' }], // 有序、无序列表 |
|||
[{ indent: '-1' }, { indent: '+1' }], // 缩进 |
|||
[{ size: ['small', false, 'large', 'huge'] }], // 字体大小 |
|||
[{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题 |
|||
[{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色 |
|||
[{ align: [] }], // 对齐方式 |
|||
['clean'], // 清除文本格式 |
|||
['link', 'image', 'video'] // 链接、图片、视频 |
|||
], |
|||
handlers: { |
|||
image: (value: boolean) => { |
|||
if (value) { |
|||
// 调用element图片上传 |
|||
uploadRef.value.click(); |
|||
} else { |
|||
Quill.format('image', true); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
placeholder: '请输入内容', |
|||
readOnly: props.readOnly |
|||
}); |
|||
// 编辑器实例,必须用 shallowRef |
|||
const editorRef = shallowRef() |
|||
|
|||
const styles = computed(() => { |
|||
let style: any = {}; |
|||
if (props.minHeight) { |
|||
style.minHeight = `${props.minHeight}px`; |
|||
} |
|||
if (props.height) { |
|||
style.height = `${props.height}px`; |
|||
} |
|||
return style; |
|||
}); |
|||
type InsertFnType = (url: string, alt: string, href: string) => void |
|||
|
|||
const content = ref(''); |
|||
watch( |
|||
() => props.modelValue, |
|||
(v: string) => { |
|||
if (v !== content.value) { |
|||
content.value = v || '<p></p>'; |
|||
} |
|||
}, |
|||
{ immediate: true } |
|||
); |
|||
|
|||
// 图片上传成功返回图片地址 |
|||
const handleUploadSuccess = (res: any) => { |
|||
// 如果上传成功 |
|||
if (res.code === 200) { |
|||
// 获取富文本实例 |
|||
let quill = toRaw(quillEditorRef.value).getQuill(); |
|||
// 获取光标位置 |
|||
let length = quill.selection.savedRange.index; |
|||
// 插入图片,res为服务器返回的图片链接地址 |
|||
quill.insertEmbed(length, 'image', res.data.url); |
|||
// 调整光标到最后 |
|||
quill.setSelection(length + 1); |
|||
proxy?.$modal.closeLoading(); |
|||
} else { |
|||
proxy?.$modal.msgError('图片插入失败'); |
|||
proxy?.$modal.closeLoading(); |
|||
} |
|||
}; |
|||
|
|||
// 图片上传前拦截 |
|||
const handleBeforeUpload = (file: any) => { |
|||
const type = ['image/jpeg', 'image/jpg', 'image/png', 'image/svg']; |
|||
const isJPG = type.includes(file.type); |
|||
//检验文件格式 |
|||
if (!isJPG) { |
|||
proxy?.$modal.msgError(`图片格式错误!`); |
|||
return false; |
|||
} |
|||
// 校检文件大小 |
|||
if (props.fileSize) { |
|||
const isLt = file.size / 1024 / 1024 < props.fileSize; |
|||
if (!isLt) { |
|||
proxy?.$modal.msgError(`上传文件大小不能超过 ${props.fileSize} MB!`); |
|||
return false; |
|||
} |
|||
} |
|||
proxy?.$modal.loading('正在上传文件,请稍候...'); |
|||
return true; |
|||
}; |
|||
// 编辑器配置 |
|||
const editorConfig: Partial<IEditorConfig> = { |
|||
placeholder: props.placeholder, |
|||
readOnly: props.disabled, |
|||
MENU_CONF: { |
|||
uploadImage: { |
|||
async customUpload(file: File, insertFn: InsertFnType) { |
|||
// file 即选中的文件 |
|||
console.log(file) |
|||
const fd = new FormData() |
|||
fd.append('file', file) |
|||
let url = import.meta.env.VITE_APP_BASE_API + '/image/upload'; |
|||
let headers = globalHeaders(); |
|||
headers['Content-Type'] = 'multipart/form-data'; |
|||
let res = await axios.post(url, fd, { headers }) |
|||
console.log(res); |
|||
insertFn(res.data.data.originUrl, file.name, '') |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
// 图片失败拦截 |
|||
const handleUploadError = (err: any) => { |
|||
proxy?.$modal.msgError('上传文件失败'); |
|||
}; |
|||
</script> |
|||
// 组件销毁时,也及时销毁编辑器 |
|||
onBeforeUnmount(() => { |
|||
const editor = editorRef.value |
|||
if (editor == null) { |
|||
return |
|||
} |
|||
console.log("onBeforeUnmount") |
|||
editor.destroy() |
|||
}) |
|||
|
|||
<style> |
|||
.editor-img-uploader { |
|||
display: none; |
|||
} |
|||
.editor, |
|||
.ql-toolbar { |
|||
white-space: pre-wrap !important; |
|||
line-height: normal !important; |
|||
} |
|||
.quill-img { |
|||
display: none; |
|||
} |
|||
.ql-snow .ql-tooltip[data-mode='link']::before { |
|||
content: '请输入链接地址:'; |
|||
} |
|||
.ql-snow .ql-tooltip.ql-editing a.ql-action::after { |
|||
border-right: 0; |
|||
content: '保存'; |
|||
padding-right: 0; |
|||
} |
|||
.ql-snow .ql-tooltip[data-mode='video']::before { |
|||
content: '请输入视频地址:'; |
|||
} |
|||
.ql-snow .ql-picker.ql-size .ql-picker-label::before, |
|||
.ql-snow .ql-picker.ql-size .ql-picker-item::before { |
|||
content: '14px'; |
|||
const handleCreated = (editor: IDomEditor) => { |
|||
editorRef.value = editor |
|||
} |
|||
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value='small']::before, |
|||
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value='small']::before { |
|||
content: '10px'; |
|||
} |
|||
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value='large']::before, |
|||
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value='large']::before { |
|||
content: '18px'; |
|||
} |
|||
.ql-snow .ql-picker.ql-size .ql-picker-label[data-value='huge']::before, |
|||
.ql-snow .ql-picker.ql-size .ql-picker-item[data-value='huge']::before { |
|||
content: '32px'; |
|||
} |
|||
.ql-snow .ql-picker.ql-header .ql-picker-label::before, |
|||
.ql-snow .ql-picker.ql-header .ql-picker-item::before { |
|||
content: '文本'; |
|||
} |
|||
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value='1']::before, |
|||
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value='1']::before { |
|||
content: '标题1'; |
|||
} |
|||
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value='2']::before, |
|||
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value='2']::before { |
|||
content: '标题2'; |
|||
} |
|||
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value='3']::before, |
|||
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value='3']::before { |
|||
content: '标题3'; |
|||
} |
|||
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value='4']::before, |
|||
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value='4']::before { |
|||
content: '标题4'; |
|||
} |
|||
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value='5']::before, |
|||
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value='5']::before { |
|||
content: '标题5'; |
|||
} |
|||
.ql-snow .ql-picker.ql-header .ql-picker-label[data-value='6']::before, |
|||
.ql-snow .ql-picker.ql-header .ql-picker-item[data-value='6']::before { |
|||
content: '标题6'; |
|||
} |
|||
.ql-snow .ql-picker.ql-font .ql-picker-label::before, |
|||
.ql-snow .ql-picker.ql-font .ql-picker-item::before { |
|||
content: '标准字体'; |
|||
} |
|||
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value='serif']::before, |
|||
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value='serif']::before { |
|||
content: '衬线字体'; |
|||
} |
|||
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value='monospace']::before, |
|||
.ql-snow .ql-picker.ql-font .ql-picker-item[data-value='monospace']::before { |
|||
content: '等宽字体'; |
|||
|
|||
// 编辑器change事件触发 |
|||
const emit = defineEmits(['update:modelValue']) |
|||
const handleChange = (editor: IDomEditor) => { |
|||
emit('update:modelValue', editor.getHtml()) |
|||
} |
|||
</style> |
|||
</script> |
|||
|
|||
@ -0,0 +1,145 @@ |
|||
<template> |
|||
<div class="component-upload-image"> |
|||
<el-upload class="upload" ref="imageUpload" :action="uploadImgUrl" list-type="picture-card" |
|||
:style="style" |
|||
:on-success="handleUploadSuccess" :before-upload="handleBeforeUpload" |
|||
:on-error="handleUploadError" :show-file-list="false" |
|||
:headers="headers" :on-preview="handlePictureCardPreview"> |
|||
<img v-if="modelValue" :src="modelValue" class="avatar"> |
|||
<el-icon v-else class="avatar-uploader-icon"> |
|||
<plus /> |
|||
</el-icon> |
|||
</el-upload> |
|||
<!-- 上传提示 --> |
|||
<div v-if="showTip" class="el-upload__tip"> |
|||
请上传 |
|||
<template v-if="fileSize"> |
|||
大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> |
|||
</template> |
|||
<template v-if="fileType"> |
|||
格式为 <b style="color: #f56c6c">{{ fileType.join('/') }}</b> |
|||
</template> |
|||
的文件 |
|||
</div> |
|||
<el-dialog v-model="dialogVisible" title="预览" width="800px" append-to-body> |
|||
<img :src="dialogImageUrl" style="display: block; max-width: 100%; margin: 0 auto" /> |
|||
</el-dialog> |
|||
</div> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
|
|||
import { propTypes } from '@/utils/propTypes'; |
|||
import { globalHeaders } from '@/utils/request'; |
|||
|
|||
const props = defineProps({ |
|||
modelValue: { |
|||
type: [String, Object, Array], |
|||
default: '' |
|||
}, |
|||
width: { |
|||
type: Number, |
|||
default: 100 |
|||
}, |
|||
height: { |
|||
type: Number, |
|||
default: 100 |
|||
}, |
|||
// 图片数量限制 |
|||
limit: propTypes.number.def(5), |
|||
// 大小限制(MB) |
|||
fileSize: propTypes.number.def(5), |
|||
// 文件类型, 例如['png', 'jpg', 'jpeg'] |
|||
fileType: propTypes.array.def(['png', 'jpg', 'jpeg']), |
|||
// 是否显示提示 |
|||
isShowTip: { |
|||
type: Boolean, |
|||
default: false |
|||
} |
|||
}); |
|||
|
|||
const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
|||
const emit = defineEmits(['update:modelValue']); |
|||
|
|||
const dialogImageUrl = ref(''); |
|||
const dialogVisible = ref(false); |
|||
|
|||
const baseUrl = import.meta.env.VITE_APP_BASE_API; |
|||
const uploadImgUrl = ref(baseUrl + '/system/image/upload'); // 上传的图片服务器地址 |
|||
const headers = ref(globalHeaders()); |
|||
const showTip = computed(() => props.isShowTip && (props.fileType || props.fileSize)); |
|||
/** 上传前loading加载 */ |
|||
const handleBeforeUpload = (file: any) => { |
|||
let isImg = false; |
|||
if (props.fileType.length) { |
|||
let fileExtension = ''; |
|||
if (file.name.lastIndexOf('.') > -1) { |
|||
fileExtension = file.name.slice(file.name.lastIndexOf('.') + 1); |
|||
} |
|||
isImg = props.fileType.some((type: any) => { |
|||
if (file.type.indexOf(type) > -1) return true; |
|||
if (fileExtension && fileExtension.indexOf(type) > -1) return true; |
|||
return false; |
|||
}); |
|||
} else { |
|||
isImg = file.type.indexOf('image') > -1; |
|||
} |
|||
if (!isImg) { |
|||
proxy?.$modal.msgError(`文件格式不正确, 请上传${props.fileType.join('/')}图片格式文件!`); |
|||
return false; |
|||
} |
|||
if (props.fileSize) { |
|||
const isLt = file.size / 1024 / 1024 < props.fileSize; |
|||
if (!isLt) { |
|||
proxy?.$modal.msgError(`上传头像图片大小不能超过 ${props.fileSize} MB!`); |
|||
return false; |
|||
} |
|||
} |
|||
}; |
|||
// 上传成功回调 |
|||
const handleUploadSuccess = (res: any) => { |
|||
if (res.code === 200) { |
|||
emit('update:modelValue', res.data.originUrl); |
|||
} else { |
|||
emit('update:modelValue', ''); |
|||
} |
|||
}; |
|||
// 上传失败 |
|||
const handleUploadError = () => { |
|||
proxy?.$modal.msgError('上传图片失败'); |
|||
proxy?.$modal.closeLoading(); |
|||
}; |
|||
|
|||
// 预览 |
|||
const handlePictureCardPreview = (file: any) => { |
|||
dialogImageUrl.value = file.url; |
|||
dialogVisible.value = true; |
|||
}; |
|||
|
|||
const style = computed(() => { |
|||
return `width:${props.width}px;height: ${props.height}px;` |
|||
|
|||
}) |
|||
</script> |
|||
|
|||
<style lang="scss"> |
|||
//.el-upload--picture-card 控制加号部分 |
|||
:deep(.hide .el-upload--picture-card) { |
|||
display: none; |
|||
} |
|||
|
|||
.upload { |
|||
width: 300px ; |
|||
height: 200px; |
|||
} |
|||
|
|||
.el-upload--picture-card { |
|||
width: 100% !important; |
|||
height: 100% !important; |
|||
} |
|||
|
|||
.avatar { |
|||
width: 100%; |
|||
height: 100%; |
|||
} |
|||
</style> |
|||
@ -0,0 +1,57 @@ |
|||
package org.dromara.im.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.FieldFill; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableLogic; |
|||
import lombok.Data; |
|||
|
|||
import java.time.LocalDateTime; |
|||
|
|||
/** |
|||
* @author Blue |
|||
* @date 2024-12-29 |
|||
* @version 1.0 |
|||
*/ |
|||
@Data |
|||
public class ImBaseEntity { |
|||
|
|||
|
|||
/** |
|||
* id |
|||
*/ |
|||
@TableId |
|||
private Long id; |
|||
|
|||
/** |
|||
* 创建者 |
|||
*/ |
|||
@TableField(fill = FieldFill.INSERT) |
|||
private Long creator; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
@TableField(fill = FieldFill.INSERT) |
|||
private LocalDateTime createTime; |
|||
|
|||
/** |
|||
* 更新者 |
|||
*/ |
|||
@TableField(fill = FieldFill.INSERT_UPDATE) |
|||
private Long updater; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
@TableField(fill = FieldFill.INSERT_UPDATE) |
|||
private LocalDateTime updateTime; |
|||
|
|||
|
|||
/** |
|||
* 删除标记 |
|||
*/ |
|||
@TableLogic |
|||
@TableField(fill = FieldFill.INSERT) |
|||
private Integer deleted; |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package org.dromara.system.controller.system; |
|||
|
|||
|
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import io.swagger.v3.oas.annotations.tags.Tag; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.dromara.common.core.domain.R; |
|||
import org.dromara.common.minio.service.FileService; |
|||
import org.dromara.common.minio.vo.UploadImageVO; |
|||
import org.springframework.web.bind.annotation.*; |
|||
import org.springframework.web.multipart.MultipartFile; |
|||
|
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("/system") |
|||
@Tag(name = "文件上传") |
|||
@RequiredArgsConstructor |
|||
public class SysFileController { |
|||
|
|||
private final FileService fileService; |
|||
|
|||
@Operation(summary = "上传图片", description = "上传图片,上传后返回原图和缩略图的url") |
|||
@PostMapping("/image/upload") |
|||
public R<UploadImageVO> uploadImage(@RequestParam("file") MultipartFile file,@RequestParam(defaultValue = "false")Boolean withThumb) { |
|||
return R.ok(fileService.uploadImage(file,withThumb)); |
|||
} |
|||
|
|||
|
|||
@Operation(summary = "上传文件", description = "上传文件,上传后返回文件url") |
|||
@PostMapping("/file/upload") |
|||
public R<String> uploadFile(@RequestParam("file") MultipartFile file) { |
|||
return R.ok(fileService.uploadFile(file)); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue