diff --git a/src/components/modals/providers/GoogleDrivePublishModal.vue b/src/components/modals/providers/GoogleDrivePublishModal.vue
index 2333f04b..5fb8fd41 100644
--- a/src/components/modals/providers/GoogleDrivePublishModal.vue
+++ b/src/components/modals/providers/GoogleDrivePublishModal.vue
@@ -4,7 +4,7 @@
diff --git a/src/services/providers/giteaProvider.js b/src/services/providers/giteaProvider.js
index 49c14136..8cbc8ff9 100644
--- a/src/services/providers/giteaProvider.js
+++ b/src/services/providers/giteaProvider.js
@@ -56,7 +56,7 @@ export default new Provider({
});
return updatedSyncLocation;
},
- async publish(token, html, metadata, publishLocation) {
+ async publish(token, html, metadata, publishLocation, commitMessage) {
const updatedPublishLocation = {
...publishLocation,
projectId: await giteaHelper.getProjectId(publishLocation),
@@ -74,6 +74,7 @@ export default new Provider({
token,
content: html,
sha,
+ commitMessage,
});
return updatedPublishLocation;
},
diff --git a/src/services/providers/giteeProvider.js b/src/services/providers/giteeProvider.js
index 3acb10ad..7eabf703 100644
--- a/src/services/providers/giteeProvider.js
+++ b/src/services/providers/giteeProvider.js
@@ -51,7 +51,7 @@ export default new Provider({
});
return syncLocation;
},
- async publish(token, html, metadata, publishLocation) {
+ async publish(token, html, metadata, publishLocation, commitMessage) {
try {
// Get the last sha
await this.downloadContent(token, publishLocation);
@@ -65,6 +65,7 @@ export default new Provider({
token,
content: html,
sha,
+ commitMessage,
});
return publishLocation;
},
diff --git a/src/services/providers/githubProvider.js b/src/services/providers/githubProvider.js
index 1f88b096..22d063e0 100644
--- a/src/services/providers/githubProvider.js
+++ b/src/services/providers/githubProvider.js
@@ -51,7 +51,7 @@ export default new Provider({
});
return syncLocation;
},
- async publish(token, html, metadata, publishLocation) {
+ async publish(token, html, metadata, publishLocation, commitMessage) {
try {
// Get the last sha
await this.downloadContent(token, publishLocation);
@@ -65,6 +65,7 @@ export default new Provider({
token,
content: html,
sha,
+ commitMessage,
});
return publishLocation;
},
diff --git a/src/services/providers/gitlabProvider.js b/src/services/providers/gitlabProvider.js
index c0e07193..c3db96b5 100644
--- a/src/services/providers/gitlabProvider.js
+++ b/src/services/providers/gitlabProvider.js
@@ -56,7 +56,7 @@ export default new Provider({
});
return updatedSyncLocation;
},
- async publish(token, html, metadata, publishLocation) {
+ async publish(token, html, metadata, publishLocation, commitMessage) {
const updatedPublishLocation = {
...publishLocation,
projectId: await gitlabHelper.getProjectId(token, publishLocation),
@@ -74,6 +74,7 @@ export default new Provider({
token,
content: html,
sha,
+ commitMessage,
});
return updatedPublishLocation;
},
diff --git a/src/services/providers/helpers/giteaHelper.js b/src/services/providers/helpers/giteaHelper.js
index 7fd8f6aa..432fc5ff 100644
--- a/src/services/providers/helpers/giteaHelper.js
+++ b/src/services/providers/helpers/giteaHelper.js
@@ -280,13 +280,14 @@ export default {
content,
sha,
isFile,
+ commitMessage,
}) {
const refreshedToken = await this.refreshToken(token);
return request(refreshedToken, {
method: sha ? 'PUT' : 'POST',
url: `repos/${projectId}/contents/${encodeURIComponent(path)}`,
body: {
- message: getCommitMessage(sha ? 'updateFileMessage' : 'createFileMessage', path),
+ message: commitMessage || getCommitMessage(sha ? 'updateFileMessage' : 'createFileMessage', path),
content: isFile ? await utils.encodeFiletoBase64(content) : utils.encodeBase64(content),
sha,
branch,
diff --git a/src/services/providers/helpers/giteeHelper.js b/src/services/providers/helpers/giteeHelper.js
index 54a614aa..f8db1c9c 100644
--- a/src/services/providers/helpers/giteeHelper.js
+++ b/src/services/providers/helpers/giteeHelper.js
@@ -276,13 +276,14 @@ export default {
path,
content,
sha,
+ commitMessage,
}) {
const refreshedToken = await this.refreshToken(token);
return repoRequest(refreshedToken, owner, repo, {
method: sha ? 'PUT' : 'POST',
url: `contents/${encodeURIComponent(path)}`,
body: {
- message: getCommitMessage(sha ? 'updateFileMessage' : 'createFileMessage', path),
+ message: commitMessage || getCommitMessage(sha ? 'updateFileMessage' : 'createFileMessage', path),
content: utils.encodeBase64(content || ' '),
sha,
branch,
diff --git a/src/services/providers/helpers/githubHelper.js b/src/services/providers/helpers/githubHelper.js
index 542fed0b..eacfdde5 100644
--- a/src/services/providers/helpers/githubHelper.js
+++ b/src/services/providers/helpers/githubHelper.js
@@ -176,12 +176,13 @@ export default {
content,
sha,
isFile,
+ commitMessage,
}) {
return repoRequest(token, owner, repo, {
method: 'PUT',
url: `contents/${encodeURIComponent(path)}`,
body: {
- message: getCommitMessage(sha ? 'updateFileMessage' : 'createFileMessage', path),
+ message: commitMessage || getCommitMessage(sha ? 'updateFileMessage' : 'createFileMessage', path),
content: isFile ? await utils.encodeFiletoBase64(content) : utils.encodeBase64(content),
sha,
branch,
diff --git a/src/services/providers/helpers/gitlabHelper.js b/src/services/providers/helpers/gitlabHelper.js
index 03312e61..51fca332 100644
--- a/src/services/providers/helpers/gitlabHelper.js
+++ b/src/services/providers/helpers/gitlabHelper.js
@@ -157,12 +157,13 @@ export default {
path,
content,
sha,
+ commitMessage,
}) {
return request(token, {
method: sha ? 'PUT' : 'POST',
url: `projects/${encodeURIComponent(projectId)}/repository/files/${encodeURIComponent(path)}`,
body: {
- commit_message: getCommitMessage(sha ? 'updateFileMessage' : 'createFileMessage', path),
+ commit_message: commitMessage || getCommitMessage(sha ? 'updateFileMessage' : 'createFileMessage', path),
content,
last_commit_id: sha,
branch,
diff --git a/src/services/publishSvc.js b/src/services/publishSvc.js
index 653537b9..a8a9fc7b 100644
--- a/src/services/publishSvc.js
+++ b/src/services/publishSvc.js
@@ -40,7 +40,10 @@ const ensureDate = (value, defaultValue) => {
return new Date(`${value}`);
};
-const publish = async (publishLocation) => {
+// git 相关的 providerId
+const gitProviderIds = ['gitea', 'gitee', 'github', 'gitlab'];
+
+const publish = async (publishLocation, commitMessage) => {
const { fileId } = publishLocation;
const template = store.getters['data/allTemplatesById'][publishLocation.templateId];
const html = await exportSvc.applyTemplate(fileId, template);
@@ -59,7 +62,7 @@ const publish = async (publishLocation) => {
status: ensureString(properties.status),
date: ensureDate(properties.date, new Date()),
};
- return provider.publish(token, html, metadata, publishLocation);
+ return provider.publish(token, html, metadata, publishLocation, commitMessage);
};
const publishFile = async (fileId) => {
@@ -69,11 +72,22 @@ const publishFile = async (fileId) => {
...store.getters['publishLocation/filteredGroupedByFileId'][fileId] || [],
];
try {
+ // 查询是否包含git provider 包含则需要填入提交信息
+ const gitLocations = publishLocations.filter(it => gitProviderIds.indexOf(it.providerId) > -1);
+ let commitMsg = '';
+ if (gitLocations.length) {
+ try {
+ const { commitMessage } = await store.dispatch('modal/open', { type: 'commitMessage' });
+ commitMsg = commitMessage;
+ } catch (e) {
+ return;
+ }
+ }
await utils.awaitSequence(publishLocations, async (publishLocation) => {
await store.dispatch('queue/doWithLocation', {
location: publishLocation,
action: async () => {
- const publishLocationToStore = await publish(publishLocation);
+ const publishLocationToStore = await publish(publishLocation, commitMsg);
try {
// Replace publish location if modified
if (utils.serializeObject(publishLocation) !==
@@ -131,7 +145,16 @@ const createPublishLocation = (publishLocation, featureId) => {
store.dispatch(
'queue/enqueue',
async () => {
- const publishLocationToStore = await publish(publishLocation);
+ let commitMsg = '';
+ if (gitProviderIds.indexOf(publishLocation.providerId) > -1) {
+ try {
+ const { commitMessage } = await store.dispatch('modal/open', { type: 'commitMessage' });
+ commitMsg = commitMessage;
+ } catch (e) {
+ return;
+ }
+ }
+ const publishLocationToStore = await publish(publishLocation, commitMsg);
workspaceSvc.addPublishLocation(publishLocationToStore);
store.dispatch('notification/info', `添加了一个新的发布位置 "${currentFile.name}".`);
if (featureId) {