Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Cloudbase Extension Cms
Commits
614cc922
Commit
614cc922
authored
4 years ago
by
cwuyiqing
Browse files
Options
Download
Email Patches
Plain Diff
feat: support redirect by project customId
parent
387d133d
master
feat/analytics
feat/batch
feat/micro
feat/sms
v2.11.0
v2.10.2
v2.10.1
v2.10.0
v2.9.1
v2.9.0
v2.8.3
v2.8.2
v2.8.1
v2.8.0
v2.7.3
v2.7.2
v2.7.1
v2.7.0
v2.6.9
v2.6.8
v2.6.7
v2.6.6
v2.6.5
v2.6.4
v2.6.3
v2.6.2
v2.6.1
v2.6.0
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
README.md
+2
-0
README.md
packages/admin/config/routes.ts
+5
-0
packages/admin/config/routes.ts
packages/admin/src/app.tsx
+0
-1
packages/admin/src/app.tsx
packages/admin/src/pages/redirect.tsx
+19
-7
packages/admin/src/pages/redirect.tsx
packages/admin/src/services/common.ts
+2
-1
packages/admin/src/services/common.ts
packages/service/src/app.controller.ts
+29
-6
packages/service/src/app.controller.ts
with
57 additions
and
15 deletions
+57
-15
README.md
+
2
-
0
View file @
614cc922
...
...
@@ -110,6 +110,8 @@ CloudBase CMS 是云开发推出的,基于 Node.js 的 Headless 内容管理
| 功能 | 状态 | 发布版本 |
| ------------------------------------------------ | --------- | -------- |
| 字段禁止编辑 | 👷 进行中 | |
| 地图组件 | 👷 进行中 | |
| 支持以微前端的模式嵌入系统 | 🏹 设计中 | |
| 提供项目模板,支持从模板创建项目 | 🏹 设计中 | |
| 支持操作记录 | 🏹 设计中 | |
...
...
This diff is collapsed.
Click to expand it.
packages/admin/config/routes.ts
+
5
-
0
View file @
614cc922
...
...
@@ -33,6 +33,11 @@ const routesConfig: IConfig = {
exact
:
true
,
redirect
:
'
/home
'
,
},
{
path
:
'
/redirect
'
,
exact
:
true
,
component
:
'
./redirect
'
,
},
{
component
:
'
../layout/index
'
,
layout
:
false
,
...
...
This diff is collapsed.
Click to expand it.
packages/admin/src/app.tsx
+
0
-
1
View file @
614cc922
...
...
@@ -72,7 +72,6 @@ export async function getInitialState(): Promise<{
if
(
currentUser
?.
_id
&&
window
.
parent
!==
window
.
self
)
{
window
.
parent
.
postMessage
(
JSON
.
stringify
({
ack
:
2
,
from
:
'
cms
'
,
status
:
'
success
'
,
}),
...
...
This diff is collapsed.
Click to expand it.
packages/admin/src/pages/redirect.tsx
+
19
-
7
View file @
614cc922
...
...
@@ -4,22 +4,34 @@ import { history, useRequest } from 'umi'
import
{
getCollectionInfo
}
from
'
@/services/common
'
export
default
()
=>
{
const
{
collectionName
,
from
}
=
history
.
location
.
query
||
{}
const
{
collectionName
,
from
,
customId
}
=
history
.
location
.
query
||
{}
// 不存在 projectCustomId
if
(
!
collectionName
||
!
from
)
{
return
history
.
push
(
'
/home
'
)
if
(
!
customId
||
!
from
)
{
history
.
push
(
'
/home
'
)
return
''
}
// 获取项目信息
const
{
data
:
schema
}
=
useRequest
<
{
data
:
Schema
}
>
(()
=>
getCollectionInfo
(
collectionName
))
// 获取项目、模型信息
const
{
data
}
=
useRequest
<
{
data
:
{
schema
:
Schema
project
:
Project
}
}
>
(()
=>
getCollectionInfo
(
customId
,
collectionName
))
useEffect
(()
=>
{
if
(
!
data
)
return
const
{
schema
,
project
}
=
data
// 跳转到对应的集合管理页面
if
(
schema
?.
_id
)
{
history
.
push
(
`/
${
schema
.
projectId
}
/content/
${
schema
.
_id
}
`
)
history
.
push
(
`/
${
project
.
_id
}
/content/
${
schema
.
_id
}
`
)
}
else
if
(
project
)
{
history
.
push
(
`/
${
project
.
_id
}
/home`
)
}
else
{
history
.
push
(
'
/home
'
)
}
},
[
schem
a
])
},
[
dat
a
])
return
(
<
div
className
=
"flex items-center justify-center h-full"
>
...
...
This diff is collapsed.
Click to expand it.
packages/admin/src/services/common.ts
+
2
-
1
View file @
614cc922
import
{
tcbRequest
}
from
'
@/utils
'
export
const
getCollectionInfo
=
async
(
collectionName
:
string
)
=>
{
export
const
getCollectionInfo
=
async
(
customId
:
string
,
collectionName
:
string
)
=>
{
return
tcbRequest
(
'
/collectionInfo
'
,
{
method
:
'
POST
'
,
data
:
{
customId
,
collectionName
,
},
})
...
...
This diff is collapsed.
Click to expand it.
packages/service/src/app.controller.ts
+
29
-
6
View file @
614cc922
import
{
Body
,
Controller
,
Get
,
Post
}
from
'
@nestjs/common
'
import
{
AppService
}
from
'
./app.service
'
import
{
RecordNotExistException
}
from
'
./common
'
import
{
Collection
}
from
'
./constants
'
import
{
CloudBaseService
}
from
'
./services
'
import
{
getCollectionSchema
}
from
'
./utils
'
@
Controller
()
export
class
AppController
{
constructor
(
private
readonly
appService
:
AppService
)
{}
constructor
(
private
readonly
appService
:
AppService
,
private
readonly
cloudbaseService
:
CloudBaseService
)
{}
@
Get
()
async
getHello
():
Promise
<
string
>
{
...
...
@@ -15,15 +20,33 @@ export class AppController {
// 根据 collectionName 查询 collection 信息
@
Post
(
'
collectionInfo
'
)
async
getCollectionInfo
(@
Body
()
body
)
{
const
{
collectionName
}
=
body
const
schema
=
await
getCollectionSchema
(
collectionName
)
const
{
collectionName
,
customId
}
=
body
if
(
!
schema
)
{
throw
new
RecordNotExistException
(
'
数据集合不存在
'
)
// 查询项目信息
const
{
data
:
[
project
],
}
=
await
this
.
cloudbaseService
.
collection
(
Collection
.
Projects
)
.
where
({
customId
,
})
.
get
()
let
schema
// 如果有 collectionName,也查询集合信息
if
(
collectionName
)
{
schema
=
await
getCollectionSchema
(
collectionName
)
if
(
!
schema
)
{
throw
new
RecordNotExistException
(
'
数据集合不存在
'
)
}
}
return
{
data
:
schema
,
data
:
{
project
,
schema
,
},
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help