You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.1 KiB

1 year ago
import { authBinding } from '@/api/auth';
/**
* @description:
* @param key key
* @param title
* @param description
* @param extra
* @param avatar
* @param color /hex
*/
export interface ListItem {
key: string;
title: string;
description: string;
extra?: string;
avatar?: string;
color?: string;
}
/**
* @description:
* @param source gitee github social-callback?source=xxx对应
* @param bound
* @param action
*/
export interface BindItem extends ListItem {
source: string;
bound?: boolean;
action?: (source: string) => Promise<any>;
}
/**
* todo tenantId
* userStore.userInfo获取
* localStorage获取
* @param source
*/
async function handleAuthBinding(source: string) {
const tenantId = localStorage.getItem('tenantId') ?? '000000';
// 这里返回打开授权页面的链接
const href = await authBinding(source, tenantId);
window.location.href = href;
}
/**
* list
*
* -
* action不为空的会在登录页显示
*/
export const accountBindList: BindItem[] = [
{
key: '1',
source: 'taobao',
title: '淘宝',
description: '绑定淘宝账号',
avatar: 'ri:taobao-fill',
color: '#ff4000',
},
{
key: '2',
source: 'alipay',
title: '支付宝',
description: '绑定支付宝账号',
avatar: 'fa-brands:alipay',
color: '#2eabff',
},
{
key: '3',
source: 'ding',
title: '钉钉',
description: '绑定钉钉账号',
avatar: 'ri:dingding-fill',
color: '#2eabff',
},
{
key: '4',
source: 'gitee',
title: 'GITEE',
description: '绑定GITEE账号',
avatar: 'simple-icons:gitee',
color: '#c71d23',
action: () => handleAuthBinding('gitee'),
},
{
key: '5',
source: 'github',
title: 'GITHUB',
description: '绑定GITHUB账号',
avatar: 'uiw:github',
color: '',
1 year ago
action: () => handleAuthBinding('github'),
},
];