上线登录

This commit is contained in:
2025-03-03 09:21:50 +08:00
parent a577fa4133
commit bc360d868e
4 changed files with 15 additions and 9 deletions

View File

@@ -23,8 +23,8 @@ whenever(ctrl_s, () => {})
whenever(ctrl_r, () => {}) whenever(ctrl_r, () => {})
onMounted(async () => { onMounted(async () => {
// const data = await getMyProfile() const data = await getMyProfile()
// username.value = data username.value = data
}) })
watch(authed, (v) => { watch(authed, (v) => {

View File

@@ -2,7 +2,7 @@ import axios from "axios"
import { router } from "./router" import { router } from "./router"
const http = axios.create({ const http = axios.create({
baseURL: "http://localhost:8000/api", baseURL: "https://webapi.xuyue.cc/api",
xsrfCookieName: "xsrfCookieName", xsrfCookieName: "xsrfCookieName",
xsrfHeaderName: "X-CSRFTOKEN", xsrfHeaderName: "X-CSRFTOKEN",
withCredentials: true, withCredentials: true,

View File

@@ -68,9 +68,11 @@
</n-tab-pane> </n-tab-pane>
<template #suffix> <template #suffix>
<n-flex align="center" class="suffix"> <n-flex align="center" class="suffix">
<!-- <span>{{ username }}</span> <span>{{ username }}</span>
<n-button v-if="!authed" @click="handleLogin">登录</n-button> <n-button v-if="!authed" @click="handleLogin" secondary type="primary">
<n-button v-else @click="handleLogout">退出</n-button> --> 登录
</n-button>
<n-button v-else @click="handleLogout">退出</n-button>
</n-flex> </n-flex>
</template> </template>
</n-tabs> </n-tabs>

View File

@@ -7,10 +7,14 @@
> >
<n-form> <n-form>
<n-form-item label="用户名"> <n-form-item label="用户名">
<n-input v-model:value="name"></n-input> <n-input v-model:value="name" name="username"></n-input>
</n-form-item> </n-form-item>
<n-form-item label="密码"> <n-form-item label="密码">
<n-input v-model:value="password"></n-input> <n-input
type="password"
v-model:value="password"
name="password"
></n-input>
</n-form-item> </n-form-item>
<n-alert <n-alert
type="error" type="error"
@@ -19,7 +23,7 @@
title="登录失败" title="登录失败"
></n-alert> ></n-alert>
<n-flex> <n-flex>
<n-button @click="submit">登录</n-button> <n-button block @click="submit" type="primary">登录</n-button>
</n-flex> </n-flex>
</n-form> </n-form>
</n-modal> </n-modal>