Browse Source

fix: 登录账号删除

master
guoapeng 3 days ago
parent
commit
9e8f6e7c97
  1. 4
      .env.prod
  2. 2
      src/apis/login.ts
  3. 2
      src/app.vue
  4. 4
      src/layouts/default.vue
  5. 4
      src/types/system.d.ts
  6. 11
      src/views/login/index.vue

4
.env.prod

@ -2,6 +2,6 @@
FT_NODE_ENV=prod FT_NODE_ENV=prod
FT_WS_URL=ws://192.168.8.168:8080/ws
FT_PROXY=http://192.168.8.168:8080
FT_WS_URL=ws://127.0.0.1:8080/ws
FT_PROXY=http://127.0.0.1:8080
FT_API_BASE=/api FT_API_BASE=/api

2
src/apis/login.ts

@ -1,4 +1,4 @@
import http from 'libs/http' import http from 'libs/http'
export const login = (params: User.Login): Promise<User.User> => http.post('/auth/login', params)
export const login = (params: System.LoginForm): Promise<User.User> => http.post('/auth/login', params)
export const logout = (): Promise<null> => http.post('/auth/logout') export const logout = (): Promise<null> => http.post('/auth/logout')

2
src/app.vue

@ -9,8 +9,6 @@ const systemStore = useSystemStore()
onMounted(async () => { onMounted(async () => {
startProgress() startProgress()
const res = await getStatus() const res = await getStatus()
// console.log(res)
// console.log(systemStore.systemStatus)
systemStore.updateSystemStatus(res) systemStore.updateSystemStatus(res)
}) })

4
src/layouts/default.vue

@ -103,7 +103,7 @@ const checkCraftVisible = ref(false)
// metaisDefault=true isDebug=true,debug // metaisDefault=true isDebug=true,debug
const menuList = computed(() => { const menuList = computed(() => {
return authRoutes.filter((item) => { return authRoutes.filter((item) => {
if (item.meta?.isDefault) {
if (item.meta?.isDefault && item.meta?.auth?.includes(systemStore.systemStatus.currentUser?.role)) {
return true return true
} }
return (['/debug', '/positionDebug'].includes(item.path) && systemStore.isDebug) return (['/debug', '/positionDebug'].includes(item.path) && systemStore.isDebug)
@ -194,7 +194,7 @@ const remoteControlState = computed(() => {
img(src="../assets/images/logo.svg" alt="" @click="handleLogoClick") img(src="../assets/images/logo.svg" alt="" @click="handleLogoClick")
div(class="menu-box") div(class="menu-box")
el-tag( el-tag(
v-for="item in menuList.filter((item) => item.meta?.auth?.includes(systemStore.systemStatus.currentUser?.role))"
v-for="item in menuList"
:key="item.path" :key="item.path"
class="menu-tag" class="menu-tag"
:effect="router.currentRoute.value.path.includes(item.path) ? 'dark' : 'plain'" :effect="router.currentRoute.value.path.includes(item.path) ? 'dark' : 'plain'"

4
src/types/system.d.ts

@ -96,8 +96,8 @@ declare namespace System {
params: T params: T
} }
interface LoginForm { interface LoginForm {
username: string
password: string
username?: string
password?: string
} }
interface ApiResponse<T> { interface ApiResponse<T> {
code: string code: string

11
src/views/login/index.vue

@ -11,7 +11,8 @@ import { useRouter } from 'vue-router'
const router = useRouter() const router = useRouter()
const sys = useSystemStore() const sys = useSystemStore()
const form = ref(sys.loginForm)
form.value.password = undefined
const formRef = ref() const formRef = ref()
setToken('login success') setToken('login success')
const rules = { const rules = {
@ -31,7 +32,7 @@ const loginHandle = async () => {
if (!valid) { if (!valid) {
return return
} }
const res = await login(sys.loginForm)
const res = await login(form.value)
setToken('login success') setToken('login success')
sys.systemStatus.currentUser = res sys.systemStatus.currentUser = res
await router.push('/') await router.push('/')
@ -47,15 +48,15 @@ const loginHandle = async () => {
.login-box-content .login-box-content
img(:src="logo", alt="" class="logo") img(:src="logo", alt="" class="logo")
//.title //.title
el-form(ref="formRef", :model="sys.loginForm", :rules="rules", style="width: 100%")
el-form(ref="formRef", :model="form", :rules="rules", style="width: 100%")
.input-title 用户名 .input-title 用户名
el-form-item el-form-item
ft-input(v-model="sys.loginForm.username", size="large", placeholder="请输入用户名")
ft-input(v-model="form.username", size="large", placeholder="请输入用户名")
template(#prepend) template(#prepend)
img.input-icon(:src="user", alt="") img.input-icon(:src="user", alt="")
.input-title 密码 .input-title 密码
el-form-item el-form-item
ft-input(v-model="sys.loginForm.password", size="large", placeholder="请输入密码", type="password")
ft-input(autocomplete="new-password" v-model="form.password", size="large", placeholder="请输入密码", type="password")
template(#prepend) template(#prepend)
img.input-icon(:src="password", alt="") img.input-icon(:src="password", alt="")
el-form-item el-form-item

Loading…
Cancel
Save