Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
谢斯
Model_Library_Front_End
提交
518a52b7
M
Model_Library_Front_End
项目概览
谢斯
/
Model_Library_Front_End
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
Model_Library_Front_End
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
518a52b7
编写于
6月 20, 2021
作者:
X
xiesi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加登录信息验证和退出功能
上级
9cbaf485
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
2 deletion
+40
-2
src/main.js
src/main.js
+29
-1
src/router/index.js
src/router/index.js
+3
-0
src/views/Home.vue
src/views/Home.vue
+8
-1
未找到文件。
src/main.js
浏览文件 @
518a52b7
...
...
@@ -9,4 +9,32 @@ import 'element-plus/lib/theme-chalk/index.css';
import
axios
from
'
axios
'
import
VueAxios
from
'
vue-axios
'
createApp
(
App
).
use
(
store
).
use
(
router
).
use
(
ElementPlus
).
use
(
VueAxios
,
axios
).
mount
(
"
#app
"
);
\ No newline at end of file
createApp
(
App
).
use
(
store
).
use
(
router
).
use
(
ElementPlus
).
use
(
VueAxios
,
axios
).
mount
(
"
#app
"
);
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
// to and from are both route objects. must call `next`.
if
(
to
.
meta
.
needLogin
)
{
console
.
log
(
"
hello
"
);
axios
.
get
(
"
http://localhost:8070/login
"
,
{
withCredentials
:
true
})
.
then
((
response
)
=>
{
if
(
response
.
data
.
usertype
==
'
用户
'
)
{
//显示用户名
console
.
log
(
response
.
data
.
data
.
name
);
next
();
}
else
{
//当前为有课,不允许登录
next
({
name
:
"
Login
"
,
query
:
{
redirect
:
to
.
meta
.
redirect
}
});
}
});
next
();
}
else
{
next
();
}
});
\ No newline at end of file
src/router/index.js
浏览文件 @
518a52b7
...
...
@@ -8,6 +8,9 @@ const routes = [{
path
:
"
/
"
,
name
:
"
Home
"
,
component
:
Home
,
meta
:
{
needLogin
:
true
,
}
},
{
path
:
"
/login
"
,
...
...
src/views/Home.vue
浏览文件 @
518a52b7
...
...
@@ -39,7 +39,7 @@
<el-main>
<el-button
@
click=
"onclickaxios"
>
hello
</el-button>
<el-button
@
click=
"havelogin"
>
havelogin
</el-button>
<el-button
@
click=
"
gotologin"
>
gotologin
</el-button>
<el-button
@
click=
"
logout"
>
logout
</el-button>
<el-button
@
click=
"gotologin11"
>
gotologin
</el-button>
<router-link
to=
"/Login"
>
gotologin
</router-link>
</el-main>
...
...
@@ -99,6 +99,13 @@ export default {
console
.
log
(
response
.
data
);
});
},
logout
()
{
this
.
axios
.
post
(
"
http://localhost:8070/logout
"
,
{},
{
withCredentials
:
true
})
.
then
((
response
)
=>
{
console
.
log
(
response
.
data
);
});
},
},
data
()
{
return
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录