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
562a0bc2
Commit
562a0bc2
authored
Jan 14, 2020
by
bianlongting
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize
parent
f911b66d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
15 deletions
+60
-15
project.js
src/api/project.js
+9
-1
ProjectxOptions.vue
src/views/Editor/dialogs/ProjectxOptions.vue
+51
-14
No files found.
src/api/project.js
View file @
562a0bc2
...
...
@@ -124,7 +124,7 @@ export async function getProjectSkins(projectId, env) {
cookie
:
{
dev
:
getCookie
(
'sso_ticket'
),
test
:
localStorage
.
getItem
(
'ticket'
),
prod
:
getCookie
(
'prod_ticket'
),
prod
:
localStorage
.
getItem
(
'prod_ticket'
),
}
}
})
...
...
@@ -132,4 +132,12 @@ export async function getProjectSkins(projectId, env) {
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/views/Editor/dialogs/ProjectxOptions.vue
View file @
562a0bc2
...
...
@@ -65,7 +65,9 @@ import copy from "copy-to-clipboard";
import
{
getProjectSkins
,
saveSkins
,
getTestEnvTicket
getTestEnvTicket
,
getProdTicket
,
sendDingTalk
}
from
"../../../../src/api/project"
;
export
default
{
name
:
"ProjectxOptions"
,
...
...
@@ -107,23 +109,53 @@ export default {
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
{
this
.
$message
({
message
:
data
.
message
,
type
:
"error"
});
this
.
skinList
=
[];
return
;
// 如果是测试环境,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
=
[];
...
...
@@ -180,8 +212,11 @@ export default {
if
(
currentTypes
!==
"2"
)
{
// 2为修改,修改不需重新获取列表
this
.
getSkinsList
(
projectId
);
}
else
if
(
currentTypes
!==
"3"
)
{
this
.
name
=
""
;
}
},
/** 获取访问链接 */
getUrl
()
{
const
{
currentHtmlType
,
currentEnv
,
skinId
,
projectId
}
=
this
;
const
mapping
=
{
...
...
@@ -197,6 +232,14 @@ export default {
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
()
{
...
...
@@ -205,13 +248,7 @@ export default {
this
.
projectId
=
projectId
;
this
.
getSkinsList
(
projectId
);
},
async
created
()
{
let
ticket
=
localStorage
.
getItem
(
"ticket"
);
if
(
!
ticket
)
{
ticket
=
await
getTestEnvTicket
();
localStorage
.
setItem
(
"ticket"
,
ticket
);
}
}
async
created
()
{}
};
</
script
>
<
style
lang=
"scss"
>
...
...
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