feature:添加变更用户名功能
This commit is contained in:
@@ -12,6 +12,7 @@ const activeNav = ref('profile');
|
|||||||
var bearer = localStorage.getItem('bearer');
|
var bearer = localStorage.getItem('bearer');
|
||||||
const loginClientUrl = 'https://www.cloudy233.top/UniAuth';
|
const loginClientUrl = 'https://www.cloudy233.top/UniAuth';
|
||||||
const loginServerUrl = 'https://www.cloudy233.top:6699';
|
const loginServerUrl = 'https://www.cloudy233.top:6699';
|
||||||
|
localStorage.setItem('loginServerUrl', loginServerUrl);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
BearerVerify();
|
BearerVerify();
|
||||||
|
|||||||
@@ -1,8 +1,28 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
UserName: String,
|
UserName: String,
|
||||||
Email: String,
|
Email: String,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function ChangeUserName() {
|
||||||
|
let newUserName = prompt('请输入新的用户名');
|
||||||
|
if (newUserName !== null && newUserName !== props.UserName && newUserName.length > 0) {
|
||||||
|
const loginServerUrl = localStorage.getItem('loginServerUrl');
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('name', newUserName);
|
||||||
|
fetch(loginServerUrl + '/changename', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${window.localStorage.getItem('bearer')}`
|
||||||
|
},
|
||||||
|
body: formData
|
||||||
|
}).then(res => {
|
||||||
|
location.reload(true);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -21,7 +41,7 @@ const props = defineProps({
|
|||||||
<label class="form-label">用户名</label>
|
<label class="form-label">用户名</label>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-value">{{ props.UserName }}</div>
|
<div class="form-value">{{ props.UserName }}</div>
|
||||||
<button class="edit-btn" disabled>编辑</button>
|
<button class="edit-btn" @click="ChangeUserName()">编辑</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user