Skip to content

Commit 2b3d36b

Browse files
author
piexlmax
committed
前端页面改造基本完成 待优化
1 parent 80c851d commit 2b3d36b

File tree

20 files changed

+708
-699
lines changed

20 files changed

+708
-699
lines changed

server/source/system/api.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func (a *api) Initialize() error {
5959
{ApiGroup: "菜单", Method: "POST", Path: "/menu/getMenuAuthority", Description: "获取指定角色menu"},
6060
{ApiGroup: "菜单", Method: "POST", Path: "/menu/addMenuAuthority", Description: "增加menu和角色关联关系"},
6161

62+
{ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/findFile", Description: "寻找目标文件(秒传)"},
63+
{ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/breakpointContinueFinish", Description: "断点续传"},
64+
{ApiGroup: "分片上传", Method: "POST", Path: "/fileUploadAndDownload/removeChunk", Description: "上传完成"},
65+
6266
{ApiGroup: "文件上传与下载", Method: "POST", Path: "/fileUploadAndDownload/upload", Description: "文件上传示例"},
6367
{ApiGroup: "文件上传与下载", Method: "POST", Path: "/fileUploadAndDownload/deleteFile", Description: "删除文件"},
6468
{ApiGroup: "文件上传与下载", Method: "POST", Path: "/fileUploadAndDownload/getFileList", Description: "获取上传文件列表"},

server/source/system/casbin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ func (c *casbin) Initialize() error {
5454
{PType: "p", V0: "888", V1: "/user/setUserAuthority", V2: "POST"},
5555
{PType: "p", V0: "888", V1: "/user/setUserAuthorities", V2: "POST"},
5656

57+
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/findFile", V2: "GET"},
58+
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/breakpointContinueFinish", V2: "POST"},
59+
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/removeChunk", V2: "POST"},
60+
5761
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/upload", V2: "POST"},
5862
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/deleteFile", V2: "POST"},
5963
{PType: "p", V0: "888", V1: "/fileUploadAndDownload/getFileList", V2: "POST"},

web/src/components/customPic/index.vue

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,54 @@
1515
</template>
1616

1717
<script>
18-
import noAvatar from '@/assets/noBody.png'
19-
import { mapGetters } from 'vuex'
20-
const path = import.meta.env.VITE_BASE_API
2118
export default {
22-
name: 'CustomPic',
23-
props: {
24-
picType: {
25-
type: String,
26-
required: false,
27-
default: 'avatar'
28-
},
29-
picSrc: {
30-
type: String,
31-
required: false,
32-
default: ''
33-
}
19+
name: 'CustomPic'
20+
}
21+
</script>
22+
23+
<script setup>
24+
import noAvatarPng from '@/assets/noBody.png'
25+
import { useStore } from 'vuex'
26+
import { computed, ref, defineProps } from 'vue-demi'
27+
const store = useStore()
28+
29+
const props = defineProps({
30+
picType: {
31+
type: String,
32+
required: false,
33+
default: 'avatar'
3434
},
35-
data() {
36-
return {
37-
noAvatar: noAvatar,
38-
path: path + '/'
35+
picSrc: {
36+
type: String,
37+
required: false,
38+
default: ''
39+
}
40+
})
41+
42+
const path = ref(import.meta.env.VITE_BASE_API + '/')
43+
const noAvatar = ref(noAvatarPng)
44+
const userInfo = computed(() => store.getters['user/userInfo'])
45+
46+
const avatar = computed(() => {
47+
if (props.picSrc === '') {
48+
if (userInfo.value.headerImg !== '' && userInfo.value.headerImg.slice(0, 4) === 'http') {
49+
return userInfo.value.headerImg
3950
}
40-
},
41-
computed: {
42-
...mapGetters('user', ['userInfo']),
43-
avatar() {
44-
if (this.picSrc === '') {
45-
if (this.userInfo.headerImg !== '' && this.userInfo.headerImg.slice(0, 4) === 'http') {
46-
return this.userInfo.headerImg
47-
}
48-
return this.path + this.userInfo.headerImg
49-
} else {
50-
if (this.picSrc !== '' && this.picSrc.slice(0, 4) === 'http') {
51-
return this.picSrc
52-
}
53-
return this.path + this.picSrc
54-
}
55-
},
56-
file() {
57-
if (this.picSrc && this.picSrc.slice(0, 4) !== 'http') {
58-
return this.path + this.picSrc
59-
}
60-
return this.picSrc
51+
return path.value + userInfo.value.headerImg
52+
} else {
53+
if (props.picSrc !== '' && props.picSrc.slice(0, 4) === 'http') {
54+
return props.picSrc
6155
}
56+
return path.value + props.picSrc
6257
}
63-
}
58+
})
59+
const file = computed(() => {
60+
if (props.picSrc && props.picSrc.slice(0, 4) !== 'http') {
61+
return path.value + props.picSrc
62+
}
63+
return props.picSrc
64+
})
65+
6466
</script>
6567
6668
<style scoped>

web/src/components/upload/image.vue

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@
1414
</div>
1515
</template>
1616

17-
<script>
18-
const path = import.meta.env.VITE_BASE_API
19-
import { mapGetters } from 'vuex'
17+
<script setup>
2018
import ImageCompress from '@/utils/image'
21-
export default {
22-
name: 'UploadImage',
23-
model: {
24-
prop: 'imageUrl',
25-
event: 'change'
26-
},
27-
props: {
19+
import { computed, ref } from 'vue'
20+
import { useStore } from 'vuex'
21+
import { ElMessage } from 'element-plus'
22+
const store = useStore()
23+
24+
const emit = defineEmits(['on-success'])
25+
const props = defineProps({
2826
imageUrl: {
2927
type: String,
3028
default: ''
@@ -37,43 +35,45 @@ export default {
3735
type: Number,
3836
default: 1920 // 图片长宽上限
3937
}
40-
},
41-
data() {
42-
return {
43-
path: path
44-
}
45-
},
46-
computed: {
47-
...mapGetters('user', ['userInfo', 'token']),
48-
showImageUrl() {
49-
return (this.imageUrl && this.imageUrl.slice(0, 4) !== 'http') ? path + this.imageUrl : this.imageUrl
50-
}
51-
},
52-
methods: {
53-
beforeImageUpload(file) {
38+
})
39+
40+
41+
const path = ref(import.meta.env.VITE_BASE_API)
42+
const token = computed(()=>store.getters['user/token'])
43+
const showImageUrl = computed(()=>(props.imageUrl && props.imageUrl.slice(0, 4) !== 'http') ? path.value + props.imageUrl : props.imageUrl)
44+
45+
const beforeImageUpload = (file) => {
5446
const isJPG = file.type === 'image/jpeg'
5547
const isPng = file.type === 'image/png'
5648
if (!isJPG && !isPng) {
57-
this.$message.error('上传头像图片只能是 jpg或png 格式!')
49+
ElMessage.error('上传头像图片只能是 jpg或png 格式!')
5850
return false
5951
}
6052
61-
const isRightSize = file.size / 1024 < this.fileSize
53+
const isRightSize = file.size / 1024 < props.fileSize
6254
if (!isRightSize) {
6355
// 压缩
64-
const compress = new ImageCompress(file, this.fileSize, this.maxWH)
56+
const compress = new ImageCompress(file, props.fileSize, props.maxWH)
6557
return compress.compress()
6658
}
6759
return isRightSize
68-
},
69-
handleImageSuccess(res) {
70-
// this.imageUrl = URL.createObjectURL(file.raw);
60+
}
61+
62+
const handleImageSuccess = (res) => {
7163
const { data } = res
7264
if (data.file) {
73-
this.$emit('change', data.file.url)
74-
this.$emit('on-success')
65+
emit('on-success',data.file.url)
7566
}
7667
}
68+
69+
</script>
70+
71+
<script>
72+
73+
export default {
74+
name: 'UploadImage',
75+
methods: {
76+
7777
}
7878
}
7979
</script>

web/src/components/warningBar/warningBar.vue

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,15 @@
1010
</span>
1111
</div>
1212
</template>
13-
<script>
13+
<script setup>
1414
import { WarningFilled } from '@element-plus/icons'
15-
16-
export default {
17-
components: {
18-
[WarningFilled.name]: WarningFilled
15+
import { defineProps } from 'vue'
16+
defineProps({
17+
title: {
18+
type: String,
19+
default: ''
1920
},
20-
props: {
21-
title: {
22-
type: String,
23-
default: ''
24-
},
25-
}
26-
}
21+
})
2722
</script>
2823
<style lang="scss" scoped>
2924
.warning-bar{

web/src/mixins/infoList.js

Lines changed: 0 additions & 61 deletions
This file was deleted.

web/src/utils/format.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { formatTimeToStr } from '@/utils/date'
2+
import { getDict } from '@/utils/dictionary'
23

34
export const formatBoolean = (bool) => {
45
if (bool !== null) {
@@ -15,3 +16,13 @@ export const formatDate = (time) => {
1516
return ''
1617
}
1718
}
19+
20+
export const filterDict = (value, options) => {
21+
const rowLabel = options && options.filter(item => item.value === value)
22+
return rowLabel && rowLabel[0] && rowLabel[0].label
23+
}
24+
25+
export const getDictFunc = async(type) => {
26+
const dicts = await getDict(type)
27+
return dicts
28+
}

0 commit comments

Comments
 (0)