Commit 6b9e549e authored by rockyl's avatar rockyl

修改发布流程

parent 00dd5872
......@@ -33,10 +33,10 @@ export async function fetchApi(uri, {params, method = 'get', auth = true, judgeS
const options = {
method,
headers: {},
//credentials: 'include',
credentials: 'include',
};
if (auth) {
options.headers.authorization = 'Bearer ' + window['zeroing_token'];
//options.headers.authorization = 'Bearer ' + window['zeroing_token'];
}
if (params) {
if (method.toLowerCase() === 'post') {
......@@ -69,12 +69,14 @@ export async function fetchApi(uri, {params, method = 'get', auth = true, judgeS
}
const response = await fetch(url, options);
if (response.status === 401) {
location.href = '/admin/permission';
const respText = await response.text();
if (response.status === 310) { //客户端重定向,用于跨域重定向
location.href = respText;
}
const jsonObj = await response.json();
//console.log(jsonObj);
try {
let jsonObj = JSON.parse(respText);
if (judgeSuccess) {
if (jsonObj.success) {
return jsonObj.data;
......@@ -83,5 +85,8 @@ export async function fetchApi(uri, {params, method = 'get', auth = true, judgeS
return jsonObj;
}
throw new ApiError('call api failed', jsonObj.code, errMessage, jsonObj.details);
return Promise.reject(new ApiError('call api failed', jsonObj.code, errMessage, jsonObj.details));
}catch (e) {
return Promise.reject(e);
}
}
......@@ -4,6 +4,15 @@
import {fetchApi} from "./common";
let devPersons;
export async function getDevPersons() {
if (!devPersons) {
devPersons = await fetchApi('/api/editor/devPersons');
}
return devPersons
}
export async function importView(file) {
const response = await fetchApi('/api/parsePSD', {
params: {
......@@ -12,8 +21,8 @@ export async function importView(file) {
method: 'post',
contentType: 'form-data',
errMessage: 'Failed to import view',
})
response.__originFile = file
});
response.__originFile = file;
return response
}
......@@ -25,13 +34,13 @@ export async function uploadView(file) {
method: 'post',
contentType: 'form-data',
errMessage: 'Failed to upload view',
})
});
response.__originFile = file;
return response
}
export async function uploadFile(file, compress = false, uuid) {
let params = { file }
let params = {file};
if (compress) {
params.compress = true
}
......@@ -43,7 +52,7 @@ export async function uploadFile(file, compress = false, uuid) {
method: 'post',
contentType: 'form-data',
errMessage: 'Failed to upload file',
})
response.__originFile = file
});
response.__originFile = file;
return response
}
......@@ -5,32 +5,15 @@
import {fetchApi} from "./common";
import {getCookie} from "./utils";
export async function saveSkins(params) {
return await fetchApi(`/polaris/autoSaveSkins`, {
export async function saveSkin(params) {
return await fetchApi(`/polaris/saveSkin`, {
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 getSkins(projectId, env) {
return await fetchApi(`/polaris/getSkins?projectId=${projectId}&env=${env}`)
}
export async function sendDingTalk() {
......
......@@ -6,11 +6,11 @@ export let API_HOST;
if (process.env.NODE_ENV === 'development') {
//API_HOST = '//10.10.95.74:7777';
//API_HOST = '//192.168.1.16:7777';
//API_HOST = '//10.10.93.88:7777';
API_HOST = '//10.10.94.107:3000';
//API_HOST = '//192.168.0.105:7777';
//API_HOST = '//localhost:3002';
//API_HOST = window.__data.apiHost;
API_HOST = 'http://beacon.duiba.com.cn';
//API_HOST = 'http://beacon.duiba.com.cn';
} else {
API_HOST = window.__data.apiHost;
}
......
......@@ -212,7 +212,7 @@
"Name required": "名字必填",
"Index page exists": "已存在首页",
"Please config projectID": "请先配置{env}环境下的projectId",
"Online ticket is invalid": "线上tickct失效,请联系管理员修改",
"SSO is invalid": "SSO失效,请重新验证",
"Are you sure to transform process?": "你确定将此转化为{inlineType}过程吗?",
"Input custom process name": "请输入自定义过程名称",
"Invalid name": "无效名称",
......
......@@ -43,10 +43,8 @@
import {mapGetters} from "vuex";
import copy from "copy-to-clipboard";
import {
getProjectSkins,
saveSkins,
getTestEnvTicket,
getProdTicket,
getSkins,
saveSkin,
sendDingTalk
} from "../../../../src/api/polaris";
import {pxHostMapping} from "../../../utils";
......@@ -91,12 +89,6 @@
async getSkinsList() {
const {env} = this;
if (env === "test") {
await this.getTicket(getTestEnvTicket);
} else if (env === "prod") {
await this.getTicket(getProdTicket, "prod_ticket");
}
const {pxEnv} = this.options;
const pxPid = this.pxPid = pxEnv[env];
......@@ -108,7 +100,7 @@
return;
}
try {
const data = await getProjectSkins(pxPid, env);
const data = await getSkins(pxPid, env);
if (data.success !== false) {
this.pxProjectName = data.name;
this.skins = data.skins;
......@@ -116,7 +108,6 @@
// 如果是测试环境,ticket过期,则重新获取ticket
if (env === "test" && data.notLogin) {
localStorage.setItem("ticket", "");
await this.getTicket(getTestEnvTicket);
this.getSkinsList(this.pxPid);
} else if (env === "prod" && data.notLogin) {
localStorage.setItem("prod_ticket", "");
......@@ -176,7 +167,7 @@
name,
env: env
};
const {ret} = await saveSkins(data);
const {ret} = await saveSkin(data);
if (ret.success !== false) {
this.$message({
message: `操作成功`,
......@@ -212,13 +203,6 @@
type: "success"
});
},
async getTicket(fn, name = "ticket") {
let ticket = localStorage.getItem(name);
if (!ticket) {
ticket = await fn();
localStorage.setItem(name, ticket);
}
},
/*getTpl(id) {
const {skins} = this;
let tpl = "";
......
......@@ -83,7 +83,7 @@
import EnabledSetter from "../components/EnabledSetter";
import MonacoEditor from "vue-monaco";
import PxConfigPopover from "../components/PxConfigPopover";
import {getProdTicket, getProjectSkins, getTestEnvTicket, saveSkins} from "../../../api/polaris";
import {getSkins, saveSkin} from "../../../api/polaris";
import {playWaiting, pxHostMapping} from "../../../utils";
import copy from "copy-to-clipboard";
import PxSkinEditor from "./PxSkinEditor";
......@@ -163,12 +163,6 @@
async getSkinsList() {
const {env} = this;
if (env === "test") {
await this.getTicket(getTestEnvTicket);
} else if (env === "prod") {
await this.getTicket(getProdTicket, "prod_ticket");
}
const {pxEnv} = this.options;
const pxPid = this.pxPid = pxEnv[env];
......@@ -180,45 +174,19 @@
return;
}
try {
const data = await getProjectSkins(pxPid, env);
if (data.success !== false) {
const data = await getSkins(pxPid, env);
this.pxProjectName = data.name;
this.skins = data.skins;
} else {
// 如果是测试环境,ticket过期,则重新获取ticket
if (env === "test" && data.notLogin) {
localStorage.setItem("ticket", "");
await this.getTicket(getTestEnvTicket);
this.getSkinsList(this.projectId);
} else if (env === "prod" && data.notLogin) {
localStorage.setItem("prod_ticket", "");
this.$message({
message: this.$t('Online ticket is invalid'),
type: "info"
});
this.pxProjectName = '';
this.skins = [];
} else {
this.$message({
message: data.message,
type: "error"
});
this.pxProjectName = '';
this.skins = [];
}
}
} catch (e) {
this.pxProjectName = '';
this.skins = [];
throw new Error(e.message);
this.invalidTicketNotice();
}
},
async getTicket(fn, name = "ticket") {
let ticket = localStorage.getItem(name);
if (!ticket) {
ticket = await fn();
localStorage.setItem(name, ticket);
}
async invalidTicketNotice(){
const {env} = this;
this.pxProjectName = '';
this.skins = [];
await this.$alert(this.$t('SSO is invalid'));
window.open('/sso/login?env=' + env, '_blank');
},
async saveSkin(skin, operate) {
const {
......@@ -226,16 +194,18 @@
pxPid,
} = this;
const {id, html, name, type} = skin;
const data = {
const params = {
projectId: pxPid,
type: (operate + 1).toString(),
currentHtmlType: type,
skinId: id,
tpl: html,
operate: operate + 1,
type,
id,
html,
name,
env,
isProd: true,
qas: [921],
};
const {ret} = await playWaiting(saveSkins(data), this.$t('In processing'));
const {ret} = await playWaiting(saveSkin(params), this.$t('In processing'));
if (ret.success !== false) {
this.$message({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment