fix login

This commit is contained in:
Владимир Фёдоров 2025-05-20 02:04:33 +07:00
parent be7ed728a3
commit 39cdf1c162
4 changed files with 14 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, nextTick, watch, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { getApiUrl } from './net';
import { encodeUTF8ToBase64, getApiUrl } from './utils';
const router = useRouter();
const route = useRoute();
@ -35,7 +35,7 @@
{
method: "GET",
headers: {
"X-Id": login.value,
"X-Id": encodeUTF8ToBase64(login.value),
"X-Password": password.value
},
}
@ -65,7 +65,7 @@
{
method: "POST",
headers: {
"X-Id": login.value,
"X-Id": encodeUTF8ToBase64(login.value),
"X-Password": password.value
},
body: JSON.stringify({

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { getApiUrl } from './net';
import { encodeUTF8ToBase64, getApiUrl } from './utils';
const router = useRouter();
@ -19,7 +19,7 @@
{
method: "GET",
headers: {
"X-Id": login.value,
"X-Id": encodeUTF8ToBase64(login.value),
"X-Password": password.value
},
}

View File

@ -1,5 +0,0 @@
export function getApiUrl(path: string) {
const url = "http://" + window.location.host.split(":")[0] + ":8090" + path
console.log(url)
return url
}

9
src/components/utils.ts Normal file
View File

@ -0,0 +1,9 @@
export function getApiUrl(path: string) {
const url = "http://" + window.location.host.split(":")[0] + ":8090" + path
console.log(url)
return url
}
export function encodeUTF8ToBase64(s: string) {
return btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g, (_, p1) => String.fromCharCode(parseInt(p1, 16))))
}