@cloudbase/lowcode-builder 1.9.11 → 1.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "1.9.11",
3
+ "version": "1.9.13",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -557,7 +557,7 @@
557
557
  crossorigin
558
558
  src="<%=
559
559
  cdnEndpoints.cdngo
560
- %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.be9848557e443dbc9550.bundle.js"
560
+ %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.a33416580dd1425d5d06.bundle.js"
561
561
  ></script>
562
562
  </body>
563
563
  </html>
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
  import { auth } from '@cloudbase/weda-client';
4
4
  const { checkAnonymous, __internal__ = {}} = auth;
5
- const { getAuthConfig, redirectToLogin, getAccessPermission, findLoginPage, cleanAccessPermissionCache } = __internal__
5
+ const { getAuthConfig, redirectToLogin: _redirectToLogin, getAccessPermission, findLoginPage, cleanAccessPermissionCache } = __internal__
6
6
  import { getWedaAPI } from '@cloudbase/weda-client'
7
7
 
8
8
  export let LOGIN_CONFIG = <%= customLoginConfig %>
@@ -23,16 +23,41 @@ export function formatErrorMsg(e) {
23
23
  return msg;
24
24
  }
25
25
 
26
+ export async function redirectToLogin($page) {
27
+ const { app } = getWedaAPI();
28
+ const loginConfig = await getLoginConfig();
29
+
30
+ // openid 登录特殊处理,不在登录页登录,在原地静默登录
31
+ const hasOpenIdLoginType = loginConfig?.miniprogram?.find(v => v.type === 'openid_login')?.enable;
32
+ const hasUnionIdLoginType = loginConfig?.miniprogram?.find(v => v.type === 'unionid_login')?.enable;
33
+
34
+ if(hasOpenIdLoginType){
35
+ // 开启了openId静默登录,则进行openid登录
36
+ const result = await app.cloud.openIdLoginInWxApp();
37
+ cleanAccessPermissionCache?.()
38
+ return { returnResult: result }
39
+ } else if (hasUnionIdLoginType) {
40
+ // 开启了unionId静默登录,则进行unionId登录
41
+ const result = await app.cloud.unionIdLoginInWxApp();
42
+ cleanAccessPermissionCache?.()
43
+ return { returnResult: result }
44
+ }
45
+ _redirectToLogin($page);
46
+ return null
47
+ }
48
+
26
49
  /**
27
50
  * 检查页面权限
28
51
  **/
29
52
  export async function checkAuth(app, appId, $page) {
30
53
  <% if(skipCheckAuth){ %> return true <% } %>
31
54
 
55
+ const { publicPage } = app.__internal__?.getConfig() || {};
56
+
57
+ // 是否处于公开访问页面
58
+ const isInPublicPage = publicPage?.includes(`${$page.__internal__.packageName}/${$page.id}`.replace(/^\/|\/$/g, ''));
59
+
32
60
  const loginConfig = await getLoginConfig();
33
- // openid 登录特殊处理,不在登录页登录,在原地静默登录
34
- const hasOpenIdLoginType = loginConfig?.miniprogram?.find(v => v.type === 'openid_login')?.enable;
35
- const hasUnionIdLoginType = loginConfig?.miniprogram?.find(v => v.type === 'unionid_login')?.enable;
36
61
 
37
62
  const loginPage = findLoginPage(app);
38
63
  const loginPageUUID = loginPage?.uuid || loginPage?.id
@@ -47,7 +72,7 @@ export async function checkAuth(app, appId, $page) {
47
72
  wx.showNavigationBarLoading();
48
73
  const requestList = [getAccessPermission(appId, $page.__internal__.packageName, $page.id, <%= !!isAdminPortal %>)];
49
74
  // 暂时先认为有登录页则自定义登录功能开启且生效
50
- if (loginPage || hasOpenIdLoginType || hasUnionIdLoginType) {
75
+ if (loginConfig) {
51
76
  requestList.push(getAuthConfig(<%= !!isAdminPortal %>));
52
77
  }
53
78
  try {
@@ -58,20 +83,12 @@ export async function checkAuth(app, appId, $page) {
58
83
  if (!accessData?.isAccess) {
59
84
  // 当前匿名情况下,且需要登录后访问应用
60
85
  if (isAnonymousUser && (authConfig?.NeedLogin || authConfig?.RejectStrategy == 'to_login')) {
61
- if(hasOpenIdLoginType){
62
- // 开启了openId静默登录,则进行openid登录
63
- const result = await app.cloud.openIdLoginInWxApp();
64
- cleanAccessPermissionCache?.()
65
- return result
66
- } else if (hasUnionIdLoginType) {
67
- // 开启了unionId静默登录,则进行unionId登录
68
- const result = await app.cloud.unionIdLoginInWxApp();
69
- cleanAccessPermissionCache?.()
70
- return result
71
- }
72
- else if (loginPage) {
86
+ if (loginPage && !isInPublicPage) {
73
87
  // 开启了手机号授权登录,则判断是否跳转到登录页面
74
- redirectToLogin($page);
88
+ const res = await redirectToLogin($page, loginConfig);
89
+ if(res !== null) {
90
+ return res.returnResult
91
+ }
75
92
  }
76
93
  } else {
77
94
  app.showToast({
@@ -82,22 +99,12 @@ export async function checkAuth(app, appId, $page) {
82
99
  } else if (authConfig?.NeedLogin && isAnonymousUser) {
83
100
  // 此分支逻辑本不应该前端判断是否登录,历史原因后端短期内搞不定,后续后端优化后删除
84
101
  // 如果当前页面匿名用户有权限访问,且需要登录后访问应用,则按配置进行登录
85
- if (hasOpenIdLoginType) {
86
- // openId静默登录
87
- const result = await app.cloud.openIdLoginInWxApp();
88
- cleanAccessPermissionCache?.()
89
- return result
90
- } else if (hasUnionIdLoginType) {
91
- // 开启了unionId静默登录
92
- const result = await app.cloud.unionIdLoginInWxApp();
93
- cleanAccessPermissionCache?.()
94
- return result
95
- } else if (loginPage) {
102
+ if (loginPage && !isInPublicPage) {
96
103
  try {
97
- redirectToLogin($page);
104
+ await redirectToLogin($page, loginConfig);
98
105
  return false;
99
106
  } catch (e) {
100
- redirectToLogin($page);
107
+ await redirectToLogin($page, loginConfig);
101
108
  return false;
102
109
  }
103
110
  }
@@ -1,7 +1,7 @@
1
1
  import datasetProfiles from './dataset-profiles'
2
2
  const dataSourceProfiles = require('./datasource-profiles.js')
3
3
  import config from '../common/config'
4
- import { LOGIN_CONFIG } from '../common/util'
4
+ import { LOGIN_CONFIG, redirectToLogin } from '../common/util'
5
5
 
6
6
  /**
7
7
  * 数据源基本配置
@@ -55,18 +55,17 @@ const CLOUD_CONFIG = {
55
55
 
56
56
  if (!LOGIN_CONFIG?.access?.needLogin) {
57
57
  if (<%= pureAnonymousLogin %>) {
58
- return !loginState.isAnonymous && await auth.signInAnonymously();
58
+ return loginState.notLogin && await auth.signInAnonymously();
59
59
  } else if (!config.endpointType) {
60
60
  return await auth.signInAnonymouslyInWx();
61
61
  }
62
62
  } else if (publicPage){
63
63
  const pages = getCurrentPages();
64
- const currentPage = pages[pages.length - 1]?.route?.match(/^pages\/(.*)\//)?.[1] || getApp().app?.__internal__?.getConfig()?.page?.[0]?.id;
64
+ const currentPage = pages[pages.length - 1]?.route?.match(/^pages\/(.*)\//)?.[1] || getApp().app?.__internal__?.getConfig()?.pages?.[0]?.id;
65
65
  if (publicPage.includes(currentPage)) {
66
66
  // 未登录时,进入公开访问页面,则匿名登录
67
- return !loginState.isAnonymous && await auth.signInAnonymously();
67
+ return loginState.notLogin && await auth.signInAnonymously();
68
68
  } else {
69
- const { redirectToLogin } = getApp().app?.auth?.__internal__ || {};
70
69
  return redirectToLogin?.();
71
70
  }
72
71
  }