forked from eee555/saolei_website
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request eee555#52 from putianyi889/debug-4
增加管理员操作接口与界面
- Loading branch information
Showing
10 changed files
with
176 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useLocalStore } from "@/store"; | ||
import { ElNotification } from "element-plus" | ||
const local = useLocalStore(); | ||
|
||
const notificationType = ['', '', 'success', '', 'error', 'error']; | ||
const notificationTitle = ['', '', 'common.msg.actionSuccess', '', 'common.msg.actionFail', 'common.msg.actionFail']; | ||
const notificationMessage: { [code: number]: string} = { | ||
200: 'common.response.OK', | ||
400: 'common.response.BadRequest', | ||
403: 'common.response.Forbidden', | ||
404: 'common.response.NotFound', | ||
500: 'common.response.InternalServerError', | ||
}; | ||
|
||
export function generalNotification(t: any, status: number, action: string) { | ||
let type = Math.floor(status / 100); | ||
ElNotification({ | ||
title: t.t(notificationTitle[type], [action]), | ||
message: t.t(notificationMessage[status]), | ||
type: notificationType[type], | ||
duration: local.notification_duration, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<div> | ||
用户ID | ||
<el-input-number v-model="userid" :controls="false" :min="0"></el-input-number> | ||
<el-button @click="getUser">查询</el-button> | ||
</div> | ||
<div> | ||
域<el-select v-model="userfield"> | ||
<el-option v-for="field in descriptionitems" :value="field"></el-option> | ||
</el-select> | ||
</div> | ||
<div> | ||
值<el-input v-model="uservalue"></el-input> | ||
</div> | ||
<div> | ||
<el-button @click="setUser(userid, userfield, uservalue)">修改</el-button> | ||
</div> | ||
<el-descriptions title="UserProfile"> | ||
<el-descriptions-item v-for="item in descriptionitems" :label="item">{{ userprofile[item] }}</el-descriptions-item> | ||
</el-descriptions> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import useCurrentInstance from '@/utils/common/useCurrentInstance'; | ||
import { generalNotification } from '@/utils/system/status'; | ||
import { ref } from 'vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
const t = useI18n(); | ||
const { proxy } = useCurrentInstance(); | ||
const userid = ref(0); | ||
const userfield = ref(""); | ||
const uservalue = ref(""); | ||
const descriptionitems = ["username", "first_name", "last_name", "email", "realname", "country", "is_banned", "left_realname_n", "left_avatar_n", "left_signature_n"] | ||
interface UserProfile { | ||
userms__designators: Array<String>; | ||
userms__video_num_limit: Number; | ||
username: String; | ||
first_name: String; | ||
last_name: String; | ||
email: String; | ||
realname: String; | ||
signature: String; | ||
country: String; | ||
is_banned: Boolean; | ||
left_realname_n: Number; | ||
left_avatar_n: Number; | ||
left_signature_n: Number; | ||
} | ||
const userprofile = ref<UserProfile>({ | ||
userms__designators: [], | ||
userms__video_num_limit: 0, | ||
username: "", | ||
first_name: "", | ||
last_name: "", | ||
email: "", | ||
realname: "", | ||
signature: "", | ||
country: "", | ||
is_banned: false, | ||
left_realname_n: 0, | ||
left_avatar_n: 0, | ||
left_signature_n: 0, | ||
}); | ||
const getUser = () => { | ||
proxy.$axios.get('userprofile/get', {params: {id: userid.value}}).then( | ||
function (response: any) { | ||
userprofile.value = response.data; | ||
} | ||
).catch(error => { | ||
generalNotification(t, error.response.status, t.t('common.action.getUserProfile')) | ||
}) | ||
} | ||
const setUser = (id: number, field: string, value: string) => { | ||
proxy.$axios.post('userprofile/set/', {id: id, field: field, value: value}).then( | ||
function (response: any) { | ||
generalNotification(t, response.status, t.t('common.action.setUserProfile')); | ||
getUser(); | ||
} | ||
) | ||
} | ||
</script> |