1.创建login 文件夹--index.vue ------->配置登录路由
{
path: "/",
name: "Login",
component: () => import("../../views/login/index.vue"),
meta: {
title: "登录",
keepAlive: false,
scrollBar: false,
},
},
2.首先判断是不是已经登陆,是不是在钉钉平台登录。(路由全局前置守卫,通过判断本地有没有存储登录信息,来决定是否放行)
router.beforeEach((to, from, next) => {
const ticketStore = useTicketStore()
if (ticketStore.isLogin === true && to.name!=='Login' ) next({ name: 'Login' })
else next()
})
3.安装dingtalk插件
4.登录页面(用到了一些钉钉的原生api)
import { runtime, ready, env, config } from 'dingtalk-jsapi'
1).判断登录平台(只有在钉钉才能打开)
2).掉钉钉权限接口,获取健全相关数据参数(传参:url:window.location.href,时间:当前时间new Date().getTime())
3).通过c