提交 1c392574 编写于 作者: P piexlmax

调整了前端接口调用防止越权

上级 a8adf85c
......@@ -111,6 +111,22 @@ export const setUserInfo = (data) => {
})
}
// @Tags SysUser
// @Summary 设置用户信息
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.SysUser true "设置用户信息"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /user/setSelfInfo [put]
export const setSelfInfo = (data) => {
return service({
url: '/user/setSelfInfo',
method: 'put',
data: data
})
}
// @Tags User
// @Summary 设置用户权限
// @Security ApiKeyAuth
......
......@@ -22,7 +22,7 @@
import { ref } from 'vue'
import { getFileList } from '@/api/fileUploadAndDownload'
const emit = defineEmits(['chooseImg'])
const emit = defineEmits(['enterImg'])
defineProps({
target: {
type: Object,
......@@ -42,7 +42,7 @@ const chooseImg = (url, target, targetKey) => {
if (target && targetKey) {
target[targetKey] = url
}
emit('enter-img', url)
emit('enterImg', url)
drawer.value = false
}
......
import { login, getUserInfo, setUserInfo as setUserInfoApi } from '@/api/user'
import { login, getUserInfo, setSelfInfo } from '@/api/user'
import { jsonInBlacklist } from '@/api/jwt'
import router from '@/router/index'
import { ElMessage } from 'element-plus'
......@@ -74,7 +74,7 @@ export const useUserStore = defineStore('user', () => {
}
/* 设置侧边栏模式*/
const changeSideMode = async(data) => {
const res = await setUserInfoApi({ sideMode: data, ID: userInfo.value.ID })
const res = await setSelfInfo({ sideMode: data })
if (res.code === 0) {
userInfo.value.sideMode = data
ElMessage({
......
......@@ -178,7 +178,7 @@ export default {
<script setup>
import ChooseImg from '@/components/chooseImg/index.vue'
import { setUserInfo, changePassword } from '@/api/user.js'
import { setSelfInfo, changePassword } from '@/api/user.js'
import { reactive, ref } from 'vue'
import { ElMessage } from 'element-plus'
import { useUserStore } from '@/pinia/modules/user'
......@@ -249,13 +249,10 @@ const openChooseImg = () => {
chooseImgRef.value.open()
}
const ResetUserInfo = (data) => {
userStore.ResetUserInfo(data)
}
const enterImg = async(url) => {
const res = await setUserInfo({ headerImg: url, ID: userStore.userInfo.ID })
const res = await setSelfInfo({ headerImg: url })
if (res.code === 0) {
ResetUserInfo({ headerImg: url })
userStore.ResetUserInfo({ headerImg: url })
ElMessage({
type: 'success',
message: '设置成功',
......@@ -274,12 +271,11 @@ const closeEdit = () => {
}
const enterEdit = async() => {
const res = await setUserInfo({
nickName: nickName.value,
ID: userStore.userInfo.ID,
const res = await setSelfInfo({
nickName: nickName.value
})
if (res.code === 0) {
ResetUserInfo({ nickName: nickName.value })
userStore.ResetUserInfo({ nickName: nickName.value })
ElMessage({
type: 'success',
message: '设置成功',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册