修复publish随MD文件移动循环请求的bug

This commit is contained in:
xiaoqi.cxq 2022-08-18 12:46:48 +08:00
parent c6d5ddfe3d
commit 04ee93237d
13 changed files with 24 additions and 16 deletions

View File

@ -41,7 +41,7 @@
</div> </div>
</div> </div>
<div class="modal__button-bar"> <div class="modal__button-bar">
<button class="button button--resolve" @click="config.resolve()">Close</button> <button class="button button--resolve" @click="config.resolve()">关闭</button>
</div> </div>
</modal-inner> </modal-inner>
</template> </template>

View File

@ -72,9 +72,9 @@ export default {
'好的,我明白了', '好的,我明白了',
), ),
stripName: simpleModal( stripName: simpleModal(
config => `<p><b>${config.item.name}</b>包含非法字符。你想剥离它们吗?</p>`, config => `<p><b>${config.item.name}</b>包含非法字符。你想去掉它们吗?</p>`,
'取消', '取消',
'确认剥离', '确认去掉',
), ),
tempFileDeletion: simpleModal( tempFileDeletion: simpleModal(
config => `<p>您将永久删除临时文件<b>${config.item.name}</b>。你确定吗?</p>`, config => `<p>您将永久删除临时文件<b>${config.item.name}</b>。你确定吗?</p>`,

View File

@ -89,9 +89,9 @@ export default {
if (store.state.offline !== offline) { if (store.state.offline !== offline) {
store.commit('setOffline', offline); store.commit('setOffline', offline);
if (offline) { if (offline) {
store.dispatch('notification/error', 'You are offline.'); store.dispatch('notification/error', '已离线!');
} else { } else {
store.dispatch('notification/info', 'You are back online!'); store.dispatch('notification/info', '恢复上线了!');
this.getServerConf(); this.getServerConf();
} }
} }

View File

@ -112,7 +112,7 @@ export default new Provider({
...syncLocation, ...syncLocation,
fileId: item.id, fileId: item.id,
}); });
store.dispatch('notification/info', `${store.getters['file/current'].name} was imported from Dropbox.`); store.dispatch('notification/info', `${store.getters['file/current'].name}已从Dropbox导入。`);
} }
}); });
}, },

View File

@ -117,7 +117,7 @@ export default new Provider({
...updatedSyncLocation, ...updatedSyncLocation,
fileId: item.id, fileId: item.id,
}); });
store.dispatch('notification/info', `${store.getters['file/current'].name} was imported from Gitea.`); store.dispatch('notification/info', `${store.getters['file/current'].name}已从Gitea导入。`);
} }
}, },
makeLocation(token, projectPath, branch, path) { makeLocation(token, projectPath, branch, path) {

View File

@ -103,7 +103,7 @@ export default new Provider({
...syncLocation, ...syncLocation,
fileId: item.id, fileId: item.id,
}); });
store.dispatch('notification/info', `${store.getters['file/current'].name} was imported from Gitee.`); store.dispatch('notification/info', `${store.getters['file/current'].name}已从Gitee导入。`);
} }
}, },
makeLocation(token, owner, repo, branch, path) { makeLocation(token, owner, repo, branch, path) {

View File

@ -103,7 +103,7 @@ export default new Provider({
...syncLocation, ...syncLocation,
fileId: item.id, fileId: item.id,
}); });
store.dispatch('notification/info', `${store.getters['file/current'].name} was imported from GitHub.`); store.dispatch('notification/info', `${store.getters['file/current'].name}已从GitHub导入。`);
} }
}, },
makeLocation(token, owner, repo, branch, path) { makeLocation(token, owner, repo, branch, path) {

View File

@ -117,7 +117,7 @@ export default new Provider({
...updatedSyncLocation, ...updatedSyncLocation,
fileId: item.id, fileId: item.id,
}); });
store.dispatch('notification/info', `${store.getters['file/current'].name} was imported from GitLab.`); store.dispatch('notification/info', `${store.getters['file/current'].name}已从GitLab导入。`);
} }
}, },
makeLocation(token, projectPath, branch, path) { makeLocation(token, projectPath, branch, path) {

View File

@ -174,7 +174,7 @@ export default new Provider({
...syncLocation, ...syncLocation,
fileId: item.id, fileId: item.id,
}); });
store.dispatch('notification/info', `${store.getters['file/current'].name} was imported from Google Drive.`); store.dispatch('notification/info', `${store.getters['file/current'].name}已从Google Drive导入。`);
} }
}); });
}, },

View File

@ -329,9 +329,10 @@ export default {
params: { ref: branch }, params: { ref: branch },
}); });
if (sha) { if (sha) {
const data = utils.decodeBase64(content);
return { return {
sha, sha,
data: utils.decodeBase64(content), data: data === ' ' ? '' : data,
}; };
} }
return {}; return {};

View File

@ -94,7 +94,7 @@ const publishFile = async (fileId) => {
}); });
}); });
const file = store.state.file.itemsById[fileId]; const file = store.state.file.itemsById[fileId];
store.dispatch('notification/info', `"${file.name}" was published to ${counter} location(s).`); store.dispatch('notification/info', `"${file.name}"已发布到${counter}个位置。`);
} finally { } finally {
await localDbSvc.unloadContents(); await localDbSvc.unloadContents();
} }
@ -133,7 +133,7 @@ const createPublishLocation = (publishLocation, featureId) => {
async () => { async () => {
const publishLocationToStore = await publish(publishLocation); const publishLocationToStore = await publish(publishLocation);
workspaceSvc.addPublishLocation(publishLocationToStore); workspaceSvc.addPublishLocation(publishLocationToStore);
store.dispatch('notification/info', `A new publication location was added to "${currentFile.name}".`); store.dispatch('notification/info', `添加了一个新的发布位置 "${currentFile.name}".`);
if (featureId) { if (featureId) {
badgeSvc.addBadge(featureId); badgeSvc.addBadge(featureId);
} }

View File

@ -222,7 +222,7 @@ const createSyncLocation = (syncLocation) => {
store.commit('syncedContent/patchItem', newSyncedContent); store.commit('syncedContent/patchItem', newSyncedContent);
workspaceSvc.addSyncLocation(updatedSyncLocation); workspaceSvc.addSyncLocation(updatedSyncLocation);
store.dispatch('notification/info', `A new synchronized location was added to "${currentFile.name}".`); store.dispatch('notification/info', `将新的同步位置添加到"${currentFile.name}"中。`);
}, },
); );
}; };
@ -665,6 +665,8 @@ const syncWorkspace = async (skipContents = false) => {
|| (isGit && item.type === 'folder') || (isGit && item.type === 'folder')
// Add file only if content has been added // Add file only if content has been added
|| (item.type === 'file' && !syncDataByItemId[`${id}/content`]) || (item.type === 'file' && !syncDataByItemId[`${id}/content`])
// 如果是发布位置 文件不存在了 则不需要更新 等待后续删除
|| (item.type === 'publishLocation' && (!item.fileId || !syncDataByItemId[`${item.fileId}/content`]))
) { ) {
return null; return null;
} }
@ -688,13 +690,16 @@ const syncWorkspace = async (skipContents = false) => {
await utils.awaitSome(() => ifNotTooLate(async () => { await utils.awaitSome(() => ifNotTooLate(async () => {
let getItem; let getItem;
let getFileItem; let getFileItem;
let getOriginFileItem;
if (store.getters['workspace/currentWorkspaceIsGit']) { if (store.getters['workspace/currentWorkspaceIsGit']) {
const { itemsByGitPath } = store.getters; const { itemsByGitPath } = store.getters;
getItem = syncData => itemsByGitPath[syncData.id]; getItem = syncData => itemsByGitPath[syncData.id];
getOriginFileItem = syncData => itemsByGitPath[syncData.fileId];
getFileItem = syncData => itemsByGitPath[syncData.id.slice(1)]; // Remove leading / getFileItem = syncData => itemsByGitPath[syncData.id.slice(1)]; // Remove leading /
} else { } else {
const { allItemsById } = store.getters; const { allItemsById } = store.getters;
getItem = syncData => allItemsById[syncData.itemId]; getItem = syncData => allItemsById[syncData.itemId];
getOriginFileItem = syncData => allItemsById[syncData.fileId];
getFileItem = syncData => allItemsById[syncData.itemId.split('/')[0]]; getFileItem = syncData => allItemsById[syncData.itemId.split('/')[0]];
} }
@ -707,6 +712,8 @@ const syncWorkspace = async (skipContents = false) => {
|| syncData.type === 'data' || syncData.type === 'data'
// Remove content only if file has been removed // Remove content only if file has been removed
|| (syncData.type === 'content' && getFileItem(syncData)) || (syncData.type === 'content' && getFileItem(syncData))
// 发布位置 如果对应的文件不存在了 也需要删除
|| (syncData.type === 'publishLocation' && syncData.fileId && getOriginFileItem(syncData))
) { ) {
return null; return null;
} }

View File

@ -80,7 +80,7 @@ export default {
type: 'unauthorizedName', type: 'unauthorizedName',
item, item,
}); });
throw new Error('Unauthorized name.'); throw new Error('未经授权的名称。');
} }
// Show warning dialogs // Show warning dialogs