feat: 登录
This commit is contained in:
@@ -52,13 +52,18 @@ const toggleDropDown = (isShow) => {
|
||||
}
|
||||
};
|
||||
|
||||
const logout = async() => {
|
||||
const logout = async () => {
|
||||
RemoveInfo(); // 目前先强制清除用户信息,后面接口通了再调
|
||||
const res = await toLogout();
|
||||
await reqCatch(devLogout, {}); // 清除社区登录
|
||||
if (!res.error) {
|
||||
RemoveInfo();
|
||||
// 有权限刷新当前页,无权限需要登录返回首页
|
||||
if (route.meta?.needLogin || (route.meta?.type === 'repo' && repoInfo.value?.visibility === 'private') || orgInfo.value?.visibility === 'private') {
|
||||
if (
|
||||
route.meta?.needLogin ||
|
||||
(route.meta?.type === 'repo' && repoInfo.value?.visibility === 'private') ||
|
||||
orgInfo.value?.visibility === 'private'
|
||||
) {
|
||||
router.push('/');
|
||||
} else {
|
||||
router.go(0);
|
||||
@@ -84,11 +89,10 @@ const DEFAULT_ROUTER_PARAMS = Object.freeze({
|
||||
params: {
|
||||
namespace: accountInfo.value.username
|
||||
},
|
||||
query: {
|
||||
}
|
||||
query: {}
|
||||
});
|
||||
// 获取router跳转参数
|
||||
const getRouterLink = params => {
|
||||
const getRouterLink = (params) => {
|
||||
if (typeof params === 'string') {
|
||||
return {
|
||||
...DEFAULT_ROUTER_PARAMS,
|
||||
@@ -103,15 +107,18 @@ const getRouterLink = params => {
|
||||
};
|
||||
|
||||
const blockList = ref([
|
||||
[
|
||||
{ id: 'myPage', label: '我的主页', to: getRouterLink('homepage') }
|
||||
],
|
||||
[{ id: 'myPage', label: '我的主页', to: getRouterLink('homepage') }],
|
||||
[
|
||||
{ id: 'dashboard', label: '工作台', icon: 'gt-member-c', to: getRouterLink('dashboard') },
|
||||
{ id: 'myIssues', label: '我的 Issue', icon: 'gt-issue-c', to: getRouterLink('issues') },
|
||||
{ id: 'myDiscuss', label: '我的讨论', icon: 'gt-comment-c', to: getRouterLink('discussionCreated') },
|
||||
{ id: 'myMR', label: '我的合并请求', icon: 'gt-me-merge-c', to: getRouterLink('merge') },
|
||||
{ id: 'notice', label: '消息通知', icon: 'gt-remind-c', to: getRouterLink({ name: 'notice', query: { status: 'all' }}) }
|
||||
{
|
||||
id: 'notice',
|
||||
label: '消息通知',
|
||||
icon: 'gt-remind-c',
|
||||
to: getRouterLink({ name: 'notice', query: { status: 'all' } })
|
||||
}
|
||||
],
|
||||
[
|
||||
{ id: 'myOrg', label: '我的组织', icon: 'gt-organizations-c', to: getRouterLink({ name: 'settingOrganization' }) },
|
||||
@@ -120,11 +127,14 @@ const blockList = ref([
|
||||
],
|
||||
[
|
||||
{ id: 'personalSetting', label: '个人设置', icon: 'gt-setting-c', to: getRouterLink('setting') },
|
||||
{ id: 'help', label: '帮助文档', icon: 'gt-file-c', href: 'https://gitcode.com/Gitcode-offical-team/GitCode-Docs/wiki' }
|
||||
{
|
||||
id: 'help',
|
||||
label: '帮助文档',
|
||||
icon: 'gt-file-c',
|
||||
href: 'https://gitcode.com/Gitcode-offical-team/GitCode-Docs/wiki'
|
||||
}
|
||||
],
|
||||
[
|
||||
{ id: 'logout', label: '退出登录', icon: 'gt-exit', action: logout }
|
||||
]
|
||||
[{ id: 'logout', label: '退出登录', icon: 'gt-exit', action: logout }]
|
||||
]);
|
||||
</script>
|
||||
|
||||
@@ -156,7 +166,7 @@ const blockList = ref([
|
||||
justify-content: space-between;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #2D2D2E;
|
||||
color: #2d2d2e;
|
||||
line-height: 20px;
|
||||
.close-icon {
|
||||
cursor: pointer;
|
||||
@@ -164,7 +174,7 @@ const blockList = ref([
|
||||
}
|
||||
&-id {
|
||||
font-size: 12px;
|
||||
color: #707A87;
|
||||
color: #707a87;
|
||||
line-height: 16px;
|
||||
}
|
||||
}
|
||||
@@ -183,7 +193,6 @@ const blockList = ref([
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in New Issue
Block a user