Skip to content

Commit

Permalink
Merge pull request #130 from TencentCloudBase/feat/jayjauan-aegis
Browse files Browse the repository at this point in the history
Feat/jayjauan aegis
  • Loading branch information
Mrjing authored Sep 30, 2021
2 parents b52eb6f + a3e0309 commit 322eae0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["packages/*"],
"npmClient": "yarn",
"version": "2.13.2"
"version": "2.13.3"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"lint:fix": "eslint --fix --cache --ext .ts,.tsx --format=pretty ./packages",
"lint:prettier": "prettier --check \"**/*.{ts,tsx,js,jsx,json}\" --end-of-line auto",
"deploy": "tcb framework deploy",
"preext:zip": "rm -rf build && mkdir build && npm run build",
"preext:zip-wx": "rm -rf build && mkdir build && npm run build:wx",
"preext:zip": "rm -rf build && mkdir build && yarn run build",
"preext:zip-wx": "rm -rf build && mkdir build && yarn run build:wx",
"ext:zip": "bash ./scripts/zip.sh",
"ext:zip-wx": "bash ./scripts/zip.sh"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloudbase-cms-admin",
"version": "2.13.2",
"version": "2.13.3",
"private": true,
"description": "An out-of-box UI solution for enterprise applications",
"scripts": {
Expand Down
37 changes: 33 additions & 4 deletions packages/admin/src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ const Login: React.FC<{}> = () => {

const { username, password } = values

let loginSuccess = false
try {
// 用户名密码登录
await loginWithPassword(username.trim(), password.trim())
message.success('登录成功')
loginSuccess = true
replaceGoto()
setTimeout(() => {
refresh()
Expand All @@ -101,6 +103,7 @@ const Login: React.FC<{}> = () => {
}

setSubmitting(false)
return Promise.resolve(loginSuccess)
}

// 从低码平台登录
Expand All @@ -111,9 +114,16 @@ const Login: React.FC<{}> = () => {

console.log('CMS 收到信息', event.data, event.origin)

const loginData: {
username?: string
password?: string
fromLowcode?: boolean
isSuccess?: boolean
} = {}
try {
const data = event?.data ? JSON.parse(event.data) : {}
if (data?.from !== 'lowcode') return
loginData.fromLowcode = true
window?.opener?.postMessage(
JSON.stringify({
from: 'cms',
Expand All @@ -123,30 +133,49 @@ const Login: React.FC<{}> = () => {
)

const { password, username } = data
await handleSubmit({
loginData.password = password || undefined
loginData.username = username || undefined
const loginSuccess = await handleSubmit({
password,
username,
})
loginData.isSuccess = !!loginSuccess

// 响应低码平台
window?.opener?.postMessage(
JSON.stringify({
from: 'cms',
status: 'success',
status: loginSuccess ? 'success' : 'fail',
}),
'*'
)
} catch (error) {
if (window.parent === window.self) return
// if (window.parent === window.self) return
// 响应低码平台
window?.opener?.postMessage(
JSON.stringify({
from: 'cms',
status: 'fail',
message: error.message,
message: error?.message,
}),
'*'
)
}

// 上报cms日志
if (loginData?.fromLowcode && window['Aegis']) {
try {
new window['Aegis']({
id: 'lXHFsBpTyYTEVwaNUr',
}).infoAll({
msg: `lowcode-login::${loginData?.isSuccess || false}`,
ext1: window?.TcbCmsConfig?.envId || '',
ext2: loginData?.username || '',
// password: loginData.password || "",
ext3: loginData?.isSuccess || false,
})
} catch (e) {}
}
}
window.addEventListener('message', messageListener, false)

Expand Down
10 changes: 4 additions & 6 deletions sam.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TCBSAMFormatVersion: '2020-10-20'
Name: tcb-ext-cms
SpecVersion: v1beta
Version: 2.13.2
Version: 2.13.3
License: Apache-2.0
Category: CloudApp
DisplayName: CMS内容管理系统
Expand All @@ -19,11 +19,9 @@ IconUrl: https://main.qcloudimg.com/raw/f87b49914efe502722f9aa128f5d8865/hello_w
IntroUrl: https://docs.cloudbase.net/cms/intro.html
# 更新日志
ChangeLog:
- Title: 2.13.2
- Title: 2.13.3
Content:
- 优化数据列表样式
- 优化时间类型数据的检索方式
- 优化其他平台拉起cms流程
- 体验优化
Author:
AuthorName: TCB
Email: [email protected]
Expand Down Expand Up @@ -60,7 +58,7 @@ Resources:
Type: CloudBase::Function
Properties:
FunctionName: tcb-ext-cms-init
CodeUri: extension://f95fb4211ebe4c6bb241f5af181019ab.zip
CodeUri: extension://0ba805cc0a3f4c80b211221115723de7.zip
InstallDependency: true
Description: 提供初始化应用功能,安装扩展后,会通过该函数来进行静态资源的部署和密码的生成和设置,修改账号密码或者部署路径等扩展参数都会再次执行该函数来进行更新
MemorySize: 256
Expand Down

0 comments on commit 322eae0

Please sign in to comment.