# 去掉工程单点登陆

# 本内容你将获得

  • 去掉单点登陆的切换
  • ACP 切换单点和非单点的方式

# 版本说明

  • alinesno-ui:1.7 +
  • alinesno-cloud-platform:2.1.2-Alpha +

# 集成步骤

# 前端配置单点登陆

去掉拦截配置

main.js中添加以下配置引入:

// 注释掉单点的配置
// Vue.use(EnableUaaClient, {routerInstance: router})

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

打开permission.js的文件配置路径,如下:

router.beforeEach((to, from, next) => {
  NProgress.start()
  if (getToken()) {
    /* has token*/
    if (to.path === '/login') {
      next({ path: '/' })
      NProgress.done()
    } else {
      if (store.getters.roles.length === 0) {
        // 判断当前用户是否已拉取完user_info信息
        store
          .dispatch('GetInfo')
          .then(() => {
            store.dispatch('GenerateRoutes').then(accessRoutes => {
              // 根据roles权限生成可访问的路由表
              router.addRoutes(accessRoutes) // 动态添加可访问路由表
              next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
            })
          })
          .catch(err => {
            store.dispatch('LogOut').then(() => {
              console.log('err = ' + err)
              Message.error(err)
              next({ path: '/' })
            })
          })
      } else {
        next()
      }
    }
  } else {
    // 没有token
    if (whiteList.indexOf(to.path) !== -1) {
      // 在免登录白名单,直接进入
      next()
    } else {
      // next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
      next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
      NProgress.done()
    }
  }
})

# 后台切换非单点登陆

切换 API 认证注解,调用EnableSSO注解为EnableApi,如下图:

@EnableApi
// @EnableSSO  // 单点登陆注解
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class SaasWebApplication {

	public static void main(String[] args) throws IOException {
		SpringApplication.run(SaasWebApplication.class, args);

	}

}

# 其它