Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
quantum-blocks
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
quantum-blocks
Commits
ba6342c1
Commit
ba6342c1
authored
Oct 24, 2022
by
徐光星
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 增加页面历史记录关联表
parent
b60f711b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
184 additions
and
10 deletions
+184
-10
editor.ts
app/controller/editor.ts
+13
-7
pageHistory.ts
app/model/pageHistory.ts
+131
-0
pageInfo.ts
app/model/pageInfo.ts
+5
-2
navigator.ts
app/service/navigator.ts
+1
-1
records.ts
app/service/records.ts
+9
-0
state.ts
app/web/page/store/modules/editor/state.ts
+21
-0
index.d.ts
typings/app/model/index.d.ts
+2
-0
index.d.ts
typings/app/service/index.d.ts
+2
-0
No files found.
app/controller/editor.ts
View file @
ba6342c1
import
{
Controller
,
Context
}
from
'
egg
'
;
import
_
,
{
omitBy
}
from
'
lodash
'
;
import
{
v1
as
uuidv1
}
from
'
uuid
'
;
import
{
PageHistory
}
from
'
../model/pageHistory
'
;
export
default
class
EditorController
extends
Controller
{
public
async
login
(
ctx
:
Context
)
{
...
...
@@ -16,9 +17,11 @@ export default class EditorController extends Controller {
const
pageInfo
=
ctx
.
request
.
body
;
try
{
const
result
=
await
ctx
.
model
.
PageInfo
.
create
({
...
pageInfo
,
uuid
:
uuidv1
().
replace
(
/-/g
,
''
),
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
const
uuid
=
result
.
dataValues
.
uuid
;
await
ctx
.
model
.
PageHistory
.
create
({
...
pageInfo
,
uuid
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
ctx
.
body
=
ctx
.
helper
.
ok
(
result
);
await
ctx
.
service
.
redis
.
del
(
`pageInfo:
${
result
.
dataValues
.
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
result
.
dataValues
.
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`pageInfo:
${
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
uuid
}
`
);
}
catch
(
error
)
{
if
(
error
.
message
.
indexOf
(
'
Data too long
'
)
>
-
1
&&
error
.
message
.
indexOf
(
'
page_data
'
)
>
-
1
)
{
error
.
message
=
'
配置组件过多,请对组件进行删减
'
;
...
...
@@ -35,10 +38,12 @@ export default class EditorController extends Controller {
if
(
ctx
.
headers
[
'
qg-tenant-id
'
])
{
pageInfo
.
tenantId
=
+
ctx
.
headers
[
'
qg-tenant-id
'
];
}
const
uuid
=
pageInfo
.
uuid
;
try
{
const
result
=
await
ctx
.
model
.
PageInfo
.
update
(
pageInfo
,
{
where
:
{
uuid
:
pageInfo
.
uuid
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
await
ctx
.
service
.
redis
.
del
(
`pageInfo:
${
pageInfo
.
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
pageInfo
.
uuid
}
`
);
await
ctx
.
model
.
PageHistory
.
create
({
...
pageInfo
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]});
await
ctx
.
service
.
redis
.
del
(
`pageInfo:
${
uuid
}
`
);
await
ctx
.
service
.
redis
.
del
(
`page:
${
uuid
}
`
);
ctx
.
body
=
ctx
.
helper
.
ok
(
result
);
}
catch
(
error
)
{
if
(
error
.
message
.
indexOf
(
'
Data too long
'
)
>
-
1
&&
error
.
message
.
indexOf
(
'
page_data
'
)
>
-
1
)
{
...
...
@@ -51,10 +56,9 @@ export default class EditorController extends Controller {
public
async
get
(
ctx
:
Context
)
{
const
{
isEditor
}
=
ctx
.
query
;
let
pageInfo
=
isEditor
?
null
:
await
ctx
.
service
.
redis
.
get
(
`pageInfo:
${
ctx
.
params
.
uuid
}
`
);
console
.
log
(
'
redis
'
,
pageInfo
);
if
(
!
pageInfo
)
{
pageInfo
=
await
ctx
.
model
.
PageInfo
.
findOne
({
where
:
{
uuid
:
ctx
.
params
.
uuid
}});
console
.
log
(
'
sql
'
,
pageInfo
);
//
console.log('sql', pageInfo);
if
(
ctx
.
query
.
lite
&&
pageInfo
)
{
// 如果存在sheme移除掉
...
...
@@ -92,7 +96,7 @@ export default class EditorController extends Controller {
where
=
{
...
where
,
isTemplate
:
1
};
}
const
{
count
:
total
,
rows
:
data
}
=
await
ctx
.
model
.
PageInfo
.
findAndCountAll
({
where
,
limit
:
+
pageSize
||
10
,
offset
:
(
+
pageNo
-
1
)
*
+
pageSize
||
0
,
order
:
[[
'
updated_at
'
,
'
DESC
'
]]
});
offset
:
(
+
pageNo
-
1
)
*
+
pageSize
||
0
,
order
:
[[
'
updated_at
'
,
'
DESC
'
]]
,
include
:
[
PageHistory
]
});
ctx
.
body
=
ctx
.
helper
.
ok
({
total
,
data
});
}
...
...
@@ -125,6 +129,8 @@ export default class EditorController extends Controller {
public
async
delete
(
ctx
:
Context
)
{
const
pageInfo
=
await
ctx
.
model
.
PageInfo
.
update
({
enable
:
0
},
{
where
:
{
id
:
+
ctx
.
params
.
pageId
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
const
pageData
=
await
ctx
.
model
.
PageInfo
.
find
({
where
:
{
id
:
+
ctx
.
params
.
pageId
,
tenantId
:
ctx
.
headers
[
'
qg-tenant-id
'
]
}});
await
ctx
.
model
.
PageHistory
.
destroy
({
where
:
{
uuid
:
pageData
.
dataValues
.
uuid
}});
ctx
.
body
=
ctx
.
helper
.
ok
(
pageInfo
);
}
public
async
getServerTime
(
ctx
:
Context
)
{
...
...
app/model/pageHistory.ts
0 → 100644
View file @
ba6342c1
/**
* @desc 页面信息表
*/
import
{
AutoIncrement
,
Column
,
DataType
,
Model
,
PrimaryKey
,
Table
,
AllowNull
,
ForeignKey
,
BelongsTo
}
from
'
sequelize-typescript
'
;
import
{
PageInfo
}
from
'
./pageInfo
'
;
@
Table
({
modelName
:
'
page_history
'
,
freezeTableName
:
true
})
export
class
PageHistory
extends
Model
<
PageHistory
>
{
@
PrimaryKey
@
AutoIncrement
@
Column
({
type
:
DataType
.
INTEGER
(
11
)
})
id
:
number
;
@
Column
({
field
:
'
page_data
'
,
type
:
DataType
.
TEXT
})
page
:
string
;
@
Column
({
field
:
'
page_name
'
,
type
:
DataType
.
STRING
(
32
)
})
pageName
:
string
;
@
Column
({
field
:
'
page_describe
'
,
type
:
DataType
.
STRING
(
255
)
})
pageDescribe
:
string
;
@
Column
({
field
:
'
page_keywords
'
,
type
:
DataType
.
STRING
(
255
)
})
pageKeywords
:
string
;
@
ForeignKey
(()
=>
PageInfo
)
@
Column
({
field
:
'
uuid
'
,
type
:
DataType
.
UUID
})
uuid
:
string
;
@
BelongsTo
(()
=>
PageInfo
)
pageInfo
:
PageInfo
;
@
Column
({
field
:
'
redirectUrl
'
,
type
:
DataType
.
STRING
(
255
),
get
()
{
const
redirectUrl
=
this
.
getDataValue
(
'
redirectUrl
'
);
return
!
redirectUrl
?
''
:
redirectUrl
;
},
})
redirectUrl
:
string
;
@
Column
({
field
:
'
validEndTime
'
,
type
:
DataType
.
STRING
(
32
),
get
()
{
const
validEndTime
=
this
.
getDataValue
(
'
validEndTime
'
);
return
!
validEndTime
?
''
:
validEndTime
;
},
})
validEndTime
:
string
;
@
Column
({
field
:
'
validStartTime
'
,
type
:
DataType
.
STRING
(
32
),
get
()
{
const
validStartTime
=
this
.
getDataValue
(
'
validStartTime
'
);
return
!
validStartTime
?
''
:
validStartTime
;
},
})
validStartTime
:
string
;
@
Column
({
type
:
DataType
.
INTEGER
(
1
)
})
enable
:
number
;
@
AllowNull
(
false
)
@
Column
({
type
:
DataType
.
STRING
(
32
)
})
author
:
string
;
@
Column
({
type
:
DataType
.
STRING
(
32
),
field
:
'
cover_image
'
})
coverImage
:
string
;
@
Column
({
type
:
DataType
.
INTEGER
(
1
),
field
:
'
is_template
'
})
isTemplate
:
number
;
@
Column
({
type
:
DataType
.
INTEGER
(
1
),
field
:
'
is_publish
'
})
isPublish
:
number
;
@
Column
({
type
:
DataType
.
DATE
,
field
:
'
updated_at
'
,
get
()
{
const
moment
=
require
(
'
moment
'
);
const
updatedAt
=
this
.
getDataValue
(
'
updatedAt
'
);
return
moment
(
updatedAt
).
format
(
'
YYYY-MM-DD HH:mm:ss
'
);
},
})
updatedAt
:
string
;
@
Column
({
type
:
DataType
.
INTEGER
(
11
),
field
:
'
tenant_id
'
,
})
tenantId
:
number
;
}
export
default
()
=>
PageHistory
;
\ No newline at end of file
app/model/pageInfo.ts
View file @
ba6342c1
/**
* @desc 页面信息表
*/
import
{
AutoIncrement
,
Column
,
DataType
,
Model
,
PrimaryKey
,
Table
,
AllowNull
}
from
'
sequelize-typescript
'
;
import
{
AutoIncrement
,
Column
,
DataType
,
Model
,
PrimaryKey
,
Table
,
AllowNull
,
HasMany
}
from
'
sequelize-typescript
'
;
import
{
PageHistory
}
from
'
./pageHistory
'
;
@
Table
({
modelName
:
'
page_config_info
'
,
freezeTableName
:
true
...
...
@@ -122,6 +122,9 @@ export class PageInfo extends Model<PageInfo> {
field
:
'
tenant_id
'
,
})
tenantId
:
number
;
@
HasMany
(()
=>
PageHistory
)
pageHistory
:
PageHistory
[];
}
export
default
()
=>
PageInfo
;
\ No newline at end of file
app/service/navigator.ts
View file @
ba6342c1
...
...
@@ -46,7 +46,7 @@ function deleteUrlParams(url, ref) {
}
}
export
default
class
Artice
Service
extends
Service
{
export
default
class
Nav
Service
extends
Service
{
private
context
:
Context
;
constructor
(
ctx
:
Context
)
{
super
(
ctx
);
...
...
app/service/records.ts
0 → 100644
View file @
ba6342c1
import
{
Context
,
Service
}
from
'
egg
'
;
export
default
class
RecordsService
extends
Service
{
private
context
:
Context
;
constructor
(
ctx
:
Context
)
{
super
(
ctx
);
this
.
context
=
ctx
;
}
}
app/web/page/store/modules/editor/state.ts
View file @
ba6342c1
...
...
@@ -64,6 +64,27 @@ export interface PageInfo {
validEndTime
?:
string
;
}
export
interface
PageHistory
{
id
?:
number
;
page
?:
Page
|
string
;
enable
?:
number
;
author
?:
string
;
coverImage
?:
string
;
shareCoverImage
?:
string
;
// 分享缩略图
shareOpenMethod
?:
string
;
// 分享后的打开方式
isTemplate
?:
number
|
boolean
;
isPublish
?:
number
|
boolean
;
pageName
?:
string
;
pageDescribe
?:
string
;
pageKeywords
?:
string
;
uuid
?:
string
;
tenantId
?:
number
;
diversion
?:
string
;
redirectUrl
?:
string
;
validStartTime
?:
string
;
validEndTime
?:
string
;
}
export
default
interface
EditorState
{
pageInfo
:
PageInfo
;
curEleIndex
:
number
|
null
;
...
...
typings/app/model/index.d.ts
View file @
ba6342c1
...
...
@@ -3,12 +3,14 @@
import
'
egg
'
;
import
ExportNavigatorConfig
from
'
../../../app/model/navigatorConfig
'
;
import
ExportPageHistory
from
'
../../../app/model/pageHistory
'
;
import
ExportPageInfo
from
'
../../../app/model/pageInfo
'
;
import
ExportTenantAuth
from
'
../../../app/model/tenantAuth
'
;
declare
module
'
egg
'
{
interface
IModel
{
NavigatorConfig
:
ReturnType
<
typeof
ExportNavigatorConfig
>
;
PageHistory
:
ReturnType
<
typeof
ExportPageHistory
>
;
PageInfo
:
ReturnType
<
typeof
ExportPageInfo
>
;
TenantAuth
:
ReturnType
<
typeof
ExportTenantAuth
>
;
}
...
...
typings/app/service/index.d.ts
View file @
ba6342c1
...
...
@@ -7,11 +7,13 @@ type AnyFunc<T = any> = (...args: any[]) => T;
type
CanExportFunc
=
AnyFunc
<
Promise
<
any
>>
|
AnyFunc
<
IterableIterator
<
any
>>
;
type
AutoInstanceType
<
T
,
U
=
T
extends
CanExportFunc
?
T
:
T
extends
AnyFunc
?
ReturnType
<
T
>
:
T
>
=
U
extends
AnyClass
?
InstanceType
<
U
>
:
U
;
import
ExportNavigator
from
'
../../../app/service/navigator
'
;
import
ExportRecords
from
'
../../../app/service/records
'
;
import
ExportRedis
from
'
../../../app/service/redis
'
;
declare
module
'
egg
'
{
interface
IService
{
navigator
:
AutoInstanceType
<
typeof
ExportNavigator
>
;
records
:
AutoInstanceType
<
typeof
ExportRecords
>
;
redis
:
AutoInstanceType
<
typeof
ExportRedis
>
;
}
}
Write
Preview
Markdown
is supported
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