Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zeroing-editor
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
劳工
zeroing-editor
Commits
7135df63
Commit
7135df63
authored
Jan 14, 2020
by
rockyl
Browse files
Options
Browse Files
Download
Plain Diff
修复打包问题
parents
efa3717a
0925bfb2
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
686 additions
and
301 deletions
+686
-301
project.js
src/api/project.js
+49
-16
utils.js
src/api/utils.js
+10
-0
zh-CN.json
src/locales/zh-CN.json
+1
-0
project.js
src/store/modules/project.js
+288
-283
ProjectxOptions.vue
src/views/Editor/dialogs/ProjectxOptions.vue
+262
-0
ProjectxConfig.vue
src/views/Editor/dialogs/editors/ProjectxConfig.vue
+71
-0
vue.config.js
vue.config.js
+5
-2
No files found.
src/api/project.js
View file @
7135df63
...
@@ -4,11 +4,12 @@
...
@@ -4,11 +4,12 @@
* 项目相关api
* 项目相关api
*/
*/
import
{
fetchApi
}
from
"./common"
;
import
{
fetchApi
}
from
"./common"
import
{
getCookie
}
from
'./utils'
export
async
function
fetchAll
(
currentPage
,
pageSize
,
onlyMine
)
{
export
async
function
fetchAll
(
currentPage
,
pageSize
,
onlyMine
)
{
return
await
fetchApi
(
'/api/project/query'
,
{
return
await
fetchApi
(
'/api/project/query'
,
{
params
:
{
currentPage
,
pageSize
,
isAll
:
onlyMine
?
0
:
1
},
params
:
{
currentPage
,
pageSize
,
isAll
:
onlyMine
?
0
:
1
},
errMessage
:
'Failed to fetch projects'
,
errMessage
:
'Failed to fetch projects'
,
})
})
}
}
...
@@ -31,7 +32,7 @@ export async function duplicateOne(project) {
...
@@ -31,7 +32,7 @@ export async function duplicateOne(project) {
export
async
function
deleteOne
(
id
)
{
export
async
function
deleteOne
(
id
)
{
return
await
fetchApi
(
'/api/project/delete'
,
{
return
await
fetchApi
(
'/api/project/delete'
,
{
params
:
{
id
},
params
:
{
id
},
method
:
'post'
,
method
:
'post'
,
errMessage
:
'Failed to delete project'
,
errMessage
:
'Failed to delete project'
,
})
})
...
@@ -39,7 +40,7 @@ export async function deleteOne(id) {
...
@@ -39,7 +40,7 @@ export async function deleteOne(id) {
export
async
function
fetchOne
(
id
)
{
export
async
function
fetchOne
(
id
)
{
return
await
fetchApi
(
'/api/project/query/data'
,
{
return
await
fetchApi
(
'/api/project/query/data'
,
{
params
:
{
id
},
params
:
{
id
},
method
:
'get'
,
method
:
'get'
,
errMessage
:
'Failed to fetch project'
,
errMessage
:
'Failed to fetch project'
,
})
})
...
@@ -55,14 +56,14 @@ export async function fetchOneFromDataUrl(dataUrl) {
...
@@ -55,14 +56,14 @@ export async function fetchOneFromDataUrl(dataUrl) {
export
async
function
fetchHistory
(
id
,
currentPage
,
pageSize
)
{
export
async
function
fetchHistory
(
id
,
currentPage
,
pageSize
)
{
return
await
fetchApi
(
'/api/project/history'
,
{
return
await
fetchApi
(
'/api/project/history'
,
{
params
:
{
id
,
currentPage
,
pageSize
},
params
:
{
id
,
currentPage
,
pageSize
},
method
:
'get'
,
method
:
'get'
,
errMessage
:
'Failed to history'
,
errMessage
:
'Failed to history'
,
})
})
}
}
export
async
function
saveOne
(
project
,
remark
)
{
export
async
function
saveOne
(
project
,
remark
)
{
project
.
remark
=
remark
;
project
.
remark
=
remark
return
await
fetchApi
(
'/api/project/update'
,
{
return
await
fetchApi
(
'/api/project/update'
,
{
params
:
project
,
params
:
project
,
method
:
'post'
,
method
:
'post'
,
...
@@ -72,7 +73,7 @@ export async function saveOne(project, remark) {
...
@@ -72,7 +73,7 @@ export async function saveOne(project, remark) {
export
async
function
pack
(
id
,
debug
,
packedAssets
)
{
export
async
function
pack
(
id
,
debug
,
packedAssets
)
{
return
await
fetchApi
(
'/api/project/pack'
,
{
return
await
fetchApi
(
'/api/project/pack'
,
{
params
:
{
id
,
debug
,
packedAssets
},
params
:
{
id
,
debug
,
packedAssets
},
method
:
'post'
,
method
:
'post'
,
errMessage
:
'Failed to pack project'
,
errMessage
:
'Failed to pack project'
,
})
})
...
@@ -86,25 +87,57 @@ export async function importView(file) {
...
@@ -86,25 +87,57 @@ export async function importView(file) {
method
:
'post'
,
method
:
'post'
,
contentType
:
'form-data'
,
contentType
:
'form-data'
,
errMessage
:
'Failed to import view'
,
errMessage
:
'Failed to import view'
,
})
;
})
response
.
__originFile
=
file
;
response
.
__originFile
=
file
return
response
;
return
response
}
}
export
async
function
uploadFile
(
file
,
compress
=
false
,
uuid
)
{
export
async
function
uploadFile
(
file
,
compress
=
false
,
uuid
)
{
let
params
=
{
file
};
let
params
=
{
file
}
if
(
compress
)
{
if
(
compress
)
{
params
.
compress
=
true
;
params
.
compress
=
true
}
}
if
(
uuid
)
{
if
(
uuid
)
{
params
.
uuid
=
uuid
;
params
.
uuid
=
uuid
}
}
const
response
=
await
fetchApi
(
'/api/uploadFile'
,
{
const
response
=
await
fetchApi
(
'/api/uploadFile'
,
{
params
,
params
,
method
:
'post'
,
method
:
'post'
,
contentType
:
'form-data'
,
contentType
:
'form-data'
,
errMessage
:
'Failed to upload file'
,
errMessage
:
'Failed to upload file'
,
});
})
response
.
__originFile
=
file
;
response
.
__originFile
=
file
return
response
;
return
response
}
export
async
function
saveSkins
(
params
)
{
return
await
fetchApi
(
`/polaris/autoSaveSkins`
,
{
params
,
method
:
'post'
})
}
export
async
function
getProjectSkins
(
projectId
,
env
)
{
return
await
fetchApi
(
`/polaris/getProjectSkins?projectId=
${
projectId
}
&env=
${
env
}
`
,
{
method
:
'post'
,
params
:
{
cookie
:
{
dev
:
getCookie
(
'sso_ticket'
),
test
:
localStorage
.
getItem
(
'ticket'
),
prod
:
localStorage
.
getItem
(
'prod_ticket'
),
}
}
})
}
export
async
function
getTestEnvTicket
()
{
return
await
fetchApi
(
`/polaris/getTestEnvTicket`
,
{
method
:
'get'
})
}
export
async
function
getProdTicket
()
{
return
await
fetchApi
(
`/polaris/getProdTicket`
,
{
method
:
'get'
})
}
}
export
async
function
sendDingTalk
()
{
return
await
fetchApi
(
`/polaris/sendMessage`
,
{
method
:
'post'
})
}
\ No newline at end of file
src/api/utils.js
0 → 100644
View file @
7135df63
export
function
getCookie
(
name
)
{
var
cookie
=
document
.
cookie
,
pattern
=
/
([^
=
]
+
)
=
([^
;
]
+
)
;
?\s
*/g
,
result
,
value
=
{}
while
((
result
=
pattern
.
exec
(
cookie
))
!=
null
)
{
value
[
result
[
1
]]
=
result
[
2
]
}
return
value
[
name
]
}
\ No newline at end of file
src/locales/zh-CN.json
View file @
7135df63
...
@@ -114,6 +114,7 @@
...
@@ -114,6 +114,7 @@
"Builtin event should add directly"
:
"内部事件请直接添加"
,
"Builtin event should add directly"
:
"内部事件请直接添加"
,
"Env constant"
:
"自定义常量"
,
"Env constant"
:
"自定义常量"
,
"Custom module"
:
"自定义模块"
,
"Custom module"
:
"自定义模块"
,
"Projectx config"
:
"星速台配置"
,
"Custom module asset mapping"
:
"自定义模块素材映射"
,
"Custom module asset mapping"
:
"自定义模块素材映射"
,
"Copy template to clipboard"
:
"复制模板到粘贴板"
,
"Copy template to clipboard"
:
"复制模板到粘贴板"
,
"Copied process to clipboard"
:
"复制过程到粘贴板"
,
"Copied process to clipboard"
:
"复制过程到粘贴板"
,
...
...
src/store/modules/project.js
View file @
7135df63
This diff is collapsed.
Click to expand it.
src/views/Editor/dialogs/ProjectxOptions.vue
0 → 100644
View file @
7135df63
<
template
>
<div
class=
"config"
>
<el-select
size=
"small"
v-model=
"currentEnv"
placeholder=
"请选择环境"
@
change=
"changeCurrentEnv"
>
<el-option
v-for=
"item in env"
:key=
"item.value"
:label=
"item.name"
:value=
"item.value"
></el-option>
</el-select>
<el-select
size=
"small"
v-model=
"currentTypes"
placeholder=
"是否新增"
>
<el-option
v-for=
"item in types"
:key=
"item.value"
:label=
"item.name"
:value=
"item.value"
></el-option>
</el-select>
<el-select
v-if=
"currentTypes !== '1'"
size=
"small"
v-model=
"skinId"
placeholder=
"选择skinID"
clearable
>
<el-option
v-for=
"item in skinList"
:key=
"item.id"
:label=
"`$
{item.type !== '1' ? item.name : '首页'}(${item.id})`"
:value="item.id"
>
</el-option>
</el-select>
<div
v-if=
"currentTypes === '1'"
>
<el-select
size=
"small"
v-model=
"currentHtmlType"
placeholder
>
<el-option
v-for=
"item in htmlType"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
></el-option>
</el-select>
<el-input
v-model=
"name"
size=
"small"
class=
"name"
placeholder=
"请输入皮肤名称"
></el-input>
</div>
<el-button
type=
"primary"
size=
"small"
@
click=
"saveSkins"
>
保存
</el-button>
<el-button
v-if=
"skinId"
type=
"primary"
size=
"small"
@
click=
"getUrl"
>
获取链接
</el-button
>
</div>
</
template
>
<
script
>
import
{
mapState
}
from
"vuex"
;
import
copy
from
"copy-to-clipboard"
;
import
{
getProjectSkins
,
saveSkins
,
getTestEnvTicket
,
getProdTicket
,
sendDingTalk
}
from
"../../../../src/api/project"
;
export
default
{
name
:
"ProjectxOptions"
,
props
:
{
tpl
:
String
},
data
()
{
return
{
env
:
[
{
value
:
"dev"
,
name
:
"开发环境"
},
{
value
:
"test"
,
name
:
"测试环境"
},
{
value
:
"prod"
,
name
:
"线上环境"
}
],
currentEnv
:
"dev"
,
types
:
[
{
value
:
"1"
,
name
:
"新增"
},
{
value
:
"2"
,
name
:
"修改"
},
{
value
:
"3"
,
name
:
"删除"
}
],
currentTypes
:
"2"
,
skinId
:
""
,
htmlType
:
[
{
value
:
"1"
,
label
:
"首页"
},
{
value
:
"2"
,
label
:
"其他"
}
],
currentHtmlType
:
"1"
,
skinList
:
[],
projectId
:
""
,
name
:
""
};
},
computed
:
{
...
mapState
([
"project"
])
},
methods
:
{
getProjectId
(
env
)
{
const
{
projectxConfig
}
=
this
.
project
.
data
.
options
;
this
.
projectId
=
projectxConfig
[
env
];
return
this
.
projectId
;
},
changeCurrentEnv
(
e
)
{
if
(
e
===
"test"
)
{
this
.
getTicket
(
getTestEnvTicket
);
}
else
if
(
e
===
"prod"
)
{
this
.
getTicket
(
getProdTicket
,
"prod_ticket"
);
}
const
projectId
=
this
.
getProjectId
(
e
);
this
.
skinId
=
""
;
this
.
getSkinsList
(
projectId
);
},
async
getSkinsList
(
projectId
)
{
const
{
currentEnv
}
=
this
;
if
(
!
projectId
)
{
this
.
$message
({
message
:
`请先配置
${
currentEnv
}
环境下的projectId`
,
type
:
"error"
});
return
;
}
try
{
const
data
=
await
getProjectSkins
(
projectId
,
currentEnv
);
if
(
data
.
success
!==
false
)
{
this
.
skinList
=
data
;
}
else
{
// 如果是测试环境,ticket过期,则重新获取ticket
if
(
currentEnv
===
"test"
&&
data
.
notLogin
)
{
localStorage
.
setItem
(
"ticket"
,
""
);
await
this
.
getTicket
(
getTestEnvTicket
);
this
.
getSkinsList
(
this
.
projectId
);
}
else
if
(
currentEnv
===
"prod"
&&
data
.
notLogin
)
{
// 如果是线上环境,则发送钉钉消息
sendDingTalk
();
localStorage
.
setItem
(
"prod_ticket"
,
""
);
this
.
$message
({
message
:
"线上tickct失效,已给相关人员发送消息"
,
type
:
"info"
});
this
.
skinList
=
[];
return
;
// sendDingTalk();
}
else
{
this
.
$message
({
message
:
data
.
message
,
type
:
"error"
});
this
.
skinList
=
[];
return
;
}
}
}
catch
(
e
)
{
this
.
skinList
=
[];
throw
new
Error
(
e
.
message
);
}
},
hasIndex
()
{
const
{
skinList
}
=
this
;
return
skinList
.
some
(
v
=>
v
.
type
===
"1"
);
},
async
saveSkins
()
{
const
{
currentEnv
,
skinId
,
currentHtmlType
,
currentTypes
,
projectId
,
tpl
,
name
,
skinList
}
=
this
;
if
(
currentTypes
===
"2"
&&
!
skinId
)
{
this
.
$message
({
message
:
"请选择修改的皮肤"
,
type
:
"warning"
});
return
;
}
if
(
currentTypes
===
"1"
)
{
if
(
this
.
hasIndex
()
&&
currentHtmlType
===
"1"
)
{
this
.
$message
({
message
:
"已存在首页"
,
type
:
"warning"
});
return
;
}
else
if
(
!
name
)
{
this
.
$message
({
message
:
"请输入要添加的皮肤名称"
,
type
:
"warning"
});
return
;
}
}
const
data
=
{
projectId
,
type
:
currentTypes
,
currentHtmlType
,
skinId
,
tpl
,
name
,
env
:
currentEnv
};
const
{
ret
}
=
await
saveSkins
(
data
);
if
(
ret
.
success
!==
false
)
{
this
.
$message
({
message
:
`操作成功`
,
type
:
"success"
});
}
else
{
this
.
$message
({
message
:
ret
.
message
,
type
:
"error"
});
}
// 新增皮肤则重新获取皮肤列表
if
(
currentTypes
!==
"2"
)
{
// 2为修改,修改不需重新获取列表
this
.
getSkinsList
(
projectId
);
}
else
if
(
currentTypes
!==
"3"
)
{
this
.
name
=
""
;
}
},
/** 获取访问链接 */
getUrl
()
{
const
{
currentHtmlType
,
currentEnv
,
skinId
,
projectId
}
=
this
;
const
mapping
=
{
dev
:
"activity.m.duibadev.com.cn"
,
test
:
"activity.m.duibatest.com.cn"
,
prod
:
"https://activity.m.duiba.com.cn"
};
const
url
=
`
${
mapping
[
currentEnv
]}
/projectx/
${
projectId
}
/
${
currentHtmlType
===
"1"
?
"index"
:
skinId
}
.html`
;
copy
(
url
);
this
.
$message
({
message
:
"链接复制成功"
,
type
:
"success"
});
},
async
getTicket
(
fn
,
name
=
"ticket"
)
{
let
ticket
=
localStorage
.
getItem
(
name
);
if
(
!
ticket
)
{
ticket
=
await
fn
();
console
.
log
(
ticket
,
"ticketticket"
);
localStorage
.
setItem
(
name
,
ticket
);
}
}
},
async
mounted
()
{
const
{
projectxConfig
}
=
this
.
project
.
data
.
options
;
const
projectId
=
projectxConfig
[
this
.
currentEnv
];
this
.
projectId
=
projectId
;
this
.
getSkinsList
(
projectId
);
},
async
created
()
{}
};
</
script
>
<
style
lang=
"scss"
>
.config
{
display
:
flex
;
.name
{
display
:
inline-block
;
width
:
200px
;
}
}
</
style
>
src/views/Editor/dialogs/editors/ProjectxConfig.vue
0 → 100644
View file @
7135df63
<
template
>
<div>
<div
v-for=
"(item, index) in envConfig"
:key=
"index"
>
<div
class=
"list"
>
<span>
{{
item
.
name
}}
</span>
<el-icon
class=
"el-icon-connection"
/>
<el-input
size=
"small"
v-model=
"envs[item.key]"
:placeholder=
"`请输入$
{item.name}星速台项目ID`"
>
</el-input>
</div>
</div>
</div>
</
template
>
<
script
>
import
{
mapState
,
mapGetters
,
mapMutations
}
from
"vuex"
;
import
{
clonePureObj
}
from
"../../../../utils"
;
export
default
{
name
:
"ProjectxConfig"
,
data
()
{
return
{
envConfig
:
[
{
key
:
"dev"
,
name
:
"开发环境"
},
{
key
:
"test"
,
name
:
"测试环境"
},
{
key
:
"prod"
,
name
:
"线上环境"
}
],
envs
:
{
dev
:
""
,
test
:
""
,
prod
:
""
}
};
},
computed
:
{
...
mapState
([
"project"
])
},
created
()
{
this
.
envs
=
this
.
project
.
data
.
options
.
projectxConfig
;
},
methods
:
{
...
mapMutations
([
"modifyOptions"
]),
edit
()
{
// this.editData = clonePureObj(this.options);
},
save
()
{
const
{
options
}
=
this
.
project
.
data
;
Object
.
assign
(
options
,
{
projectxConfig
:
this
.
envs
});
this
.
modifyOptions
(
options
);
}
}
};
</
script
>
<
style
lang=
"scss"
scoped
>
.list
{
display
:
flex
;
align-items
:
center
;
margin-bottom
:
20px
;
span
{
width
:
100px
;
text-align
:
center
;
}
i
{
width
:
50px
;
}
>
div
{
width
:
200px
;
}
}
</
style
>
vue.config.js
View file @
7135df63
...
@@ -12,7 +12,7 @@ module.exports = {
...
@@ -12,7 +12,7 @@ module.exports = {
enableInSFC
:
true
enableInSFC
:
true
}
}
},
},
/*
devServer: {
devServer
:
{
host
:
'0.0.0.0'
,
host
:
'0.0.0.0'
,
port
:
'8080'
,
port
:
'8080'
,
proxy
:
{
proxy
:
{
...
@@ -22,8 +22,11 @@ module.exports = {
...
@@ -22,8 +22,11 @@ module.exports = {
'/api'
:
{
'/api'
:
{
target
:
serverHost
,
target
:
serverHost
,
},
},
'polaris'
:
{
target
:
serverHost
}
}
}
},
*/
},
configureWebpack
:
{
configureWebpack
:
{
plugins
:
[
plugins
:
[
new
MonacoWebpackPlugin
({
new
MonacoWebpackPlugin
({
...
...
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