Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
qinhaitao
taobao-mini-template
Commits
3c47a8d2
Commit
3c47a8d2
authored
Nov 09, 2020
by
maggie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义util编译
parent
3bdb9585
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
95 additions
and
2 deletions
+95
-2
config.json
v2.0/compileServer/config.json
+4
-0
generate.js
v2.0/compileServer/generate.js
+32
-1
decorator.export.njk
v2.0/compileServer/templates/decorator.export.njk
+6
-0
util.export.njk
v2.0/compileServer/templates/util.export.njk
+19
-0
util.njk
v2.0/compileServer/templates/util.njk
+8
-0
task.controller.ts
v2.0/src/controller/common/task.controller.ts
+1
-1
index.ts
v2.0/src/decorator/custom/index.ts
+4
-0
index.ts
v2.0/src/utils/custom/index.ts
+13
-0
test.ts
v2.0/src/utils/custom/test.ts
+8
-0
No files found.
v2.0/compileServer/config.json
View file @
3c47a8d2
...
...
@@ -113,6 +113,10 @@
"type"
:
"common"
,
"name"
:
"preUpdate"
,
"params"
:
[
{
"type"
:
"custom"
,
"name"
:
"test"
},
{
"type"
:
"common"
,
"behave"
:
"update"
,
...
...
v2.0/compileServer/generate.js
View file @
3c47a8d2
...
...
@@ -30,6 +30,11 @@ const customFileMap = (controllers = {}) => {
if
(
decorator
.
type
===
'custom'
)
{
result
.
decorators
[
decorator
.
name
]
=
true
}
for
(
let
util
of
decorator
.
params
)
{
if
(
util
.
type
&&
util
.
type
===
'custom'
)
{
result
.
utils
[
util
.
name
]
=
true
}
}
}
}
}
...
...
@@ -39,7 +44,7 @@ const customFileMap = (controllers = {}) => {
const
run
=
async
(
gulp
,
nunjucksRender
,
rename
,
nunjucksRenderConfig
)
=>
{
//编译自定义文件
const
{
decorators
}
=
customFileMap
(
config
.
controllers
)
const
{
decorators
,
utils
}
=
customFileMap
(
config
.
controllers
)
for
(
let
decorator
in
decorators
)
{
await
gulp
.
src
(
`
${
serverTemplatePath
}
/decorator.njk`
)
...
...
@@ -66,6 +71,32 @@ const run = async (gulp, nunjucksRender, rename, nunjucksRenderConfig) => {
)
.
pipe
(
rename
(
`index.ts`
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/decorator/custom'
))
for
(
let
util
in
utils
)
{
await
gulp
.
src
(
`
${
serverTemplatePath
}
/util.njk`
)
.
pipe
(
nunjucksRender
({
...
nunjucksRenderConfig
,
data
:
{
name
:
util
}
})
)
.
pipe
(
rename
(
`
${
util
}
.ts`
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/utils/custom'
))
}
await
gulp
.
src
(
`
${
serverTemplatePath
}
/util.export.njk`
)
.
pipe
(
nunjucksRender
({
...
nunjucksRenderConfig
,
data
:
{
utils
}
})
)
.
pipe
(
rename
(
`index.ts`
))
.
pipe
(
gulp
.
dest
(
nunjucksRenderConfig
.
ServerFullPath
+
'/utils/custom'
))
//编译controller.common
for
(
let
commonController
in
config
.
controllers
.
common
)
{
await
gulp
...
...
v2.0/compileServer/templates/decorator.export.njk
View file @
3c47a8d2
...
...
@@ -11,3 +11,9 @@ const custom = {
}
export default custom
export {
{%-for decorator, decorator_item in decorators%}
{{decorator}}{%if loop.last%}{%else%},{%endif%}
{%-endfor%}
}
v2.0/compileServer/templates/util.export.njk
View file @
3c47a8d2
/** @format */
{%for util, util_item in utils-%}
import {{util}} from './{{util}}'
{%-endfor%}
const custom = {
{%-for util, util_item in utils%}
{{util}}{%if loop.last%}{%else%},{%endif%}
{%-endfor%}
}
export default custom
export {
{%-for util, util_item in utils%}
{{util}}{%if loop.last%}{%else%},{%endif%}
{%-endfor%}
}
v2.0/compileServer/templates/util.njk
View file @
3c47a8d2
/** @format */
import { resultsModel } from '../../sdk'
import { CODE_TYPES } from '../../errorCode'
export default async function {{name}}(context: IContext<IParams>, { activityInfo }: IControllerInfos) {
// TO DO
}
v2.0/src/controller/common/task.controller.ts
View file @
3c47a8d2
...
...
@@ -12,7 +12,7 @@ export default class TaskController {
@
commonDecorator
.
checkParams
([
'activityId'
])
@
commonDecorator
.
registeInfos
([
'vipInfo'
])
@
commonDecorator
.
preCheck
([
commonUtilCheck
.
checkActivityTime
])
@
commonDecorator
.
preUpdate
([
commonUtilUpdate
.
updateVip
,
commonUtilUpdate
.
updateSignTask
,
commonUtilUpdate
.
updateOrderGoods
])
@
commonDecorator
.
preUpdate
([
c
ustomUtil
.
test
,
c
ommonUtilUpdate
.
updateVip
,
commonUtilUpdate
.
updateSignTask
,
commonUtilUpdate
.
updateOrderGoods
])
@
services
([
TaskService
])
async
getTaskList
(
context
:
IContext
<
IParams
>
,
...
...
v2.0/src/decorator/custom/index.ts
View file @
3c47a8d2
...
...
@@ -7,3 +7,7 @@ const custom = {
}
export
default
custom
export
{
test
}
v2.0/src/utils/custom/index.ts
0 → 100644
View file @
3c47a8d2
/** @format */
import
test
from
'./test'
const
custom
=
{
test
}
export
default
custom
export
{
test
}
v2.0/src/utils/custom/test.ts
0 → 100644
View file @
3c47a8d2
/** @format */
import
{
resultsModel
}
from
'../../sdk'
import
{
CODE_TYPES
}
from
'../../errorCode'
export
default
async
function
test
(
context
:
IContext
<
IParams
>
,
{
activityInfo
}:
IControllerInfos
)
{
// TO DO
}
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