Jelajahi Sumber

增加【获取登录用户信息】接口,接口报跨域错误

yanglzh 3 tahun lalu
induk
melakukan
82037af455
2 mengubah file dengan 11 tambahan dan 2 penghapusan
  1. 6 1
      src/api/login/index.ts
  2. 5 1
      src/views/login/component/account.vue

+ 6 - 1
src/api/login/index.ts

@@ -1,8 +1,13 @@
 import { get, post } from '/@/utils/request';
 
-// 登录api接口集合
+// 登录api接口
 export const login = (data: object) => post('/login', data)
+
+// 获取登录用户信息
+export const currentUser = () => post('/system/user/currentUser')
+
 // 获取验证码
 export const captcha = () => get('/captcha')
+
 // 退出登录
 export const signOut = (data: object) => post('/user/signOut', data)

+ 5 - 1
src/views/login/component/account.vue

@@ -58,6 +58,7 @@ import { useStore } from '/@/store/index';
 import { Session } from '/@/utils/storage';
 import { formatAxis } from '/@/utils/formatTime';
 import { login, captcha } from '/@/api/login';
+import * as api from '/@/api/login';
 export default defineComponent({
 	name: 'loginAccount',
 	setup() {
@@ -126,7 +127,10 @@ export default defineComponent({
 				.catch(() => {});
 		};
 		// 获取登录用户信息
-		const currentUser = async () => {
+    const currentUser = async () => {
+      api.currentUser().then(res => {
+        console.log(res)
+      })
 			// 设置用户菜单
 			// Session.set('userMenu', res.data.menuList);
 			// // 设置按钮权限