From 40e77fef15adcfe8619d968cf7e38d1669e52868 Mon Sep 17 00:00:00 2001 From: caojiezi2003 <249085952@qq.com> Date: Mon, 5 Aug 2024 10:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0gitee=E5=88=86=E4=BA=AB?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BD=8D=E7=BD=AE=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/providers/giteeGistProvider.js | 174 ++++++++++---------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/src/services/providers/giteeGistProvider.js b/src/services/providers/giteeGistProvider.js index eb05b966..aecee43e 100644 --- a/src/services/providers/giteeGistProvider.js +++ b/src/services/providers/giteeGistProvider.js @@ -5,91 +5,91 @@ import utils from '../utils'; import userSvc from '../userSvc'; export default new Provider({ - id: 'giteegist', - name: 'GiteeGist', - getToken({ sub }) { - return store.getters['data/giteeTokensBySub'][sub]; - }, - getLocationUrl({ gistId }) { - return `https://gitee.com/mafgwo/codes/${gistId}`; - }, - getLocationDescription({ filename }) { - return filename; - }, - async downloadContent(token, syncLocation) { - const content = await giteeHelper.downloadGist({ - ...syncLocation, - token, - }); - return Provider.parseContent(content, `${syncLocation.fileId}/content`); - }, - async uploadContent(token, content, syncLocation) { - const file = store.state.file.itemsById[syncLocation.fileId]; - const description = utils.sanitizeName(file && file.name); - const gist = await giteeHelper.uploadGist({ - ...syncLocation, - token, - description, - content: Provider.serializeContent(content), - }); - return { - ...syncLocation, - gistId: gist.id, - }; - }, - async publish(token, html, metadata, publishLocation) { - const gist = await giteeHelper.uploadGist({ - ...publishLocation, - token, - description: metadata.title, - content: html, - }); - return { - ...publishLocation, - gistId: gist.id, - }; - }, - makeLocation(token, filename, isPublic, gistId) { - return { - providerId: this.id, - sub: token.sub, - filename, - isPublic, - gistId, - }; - }, - async listFileRevisions({ token, syncLocation }) { - const entries = await giteeHelper.getGistCommits({ - ...syncLocation, - token, - }); + id: 'giteegist', + name: 'GiteeGist', + getToken({ sub }) { + return store.getters['data/giteeTokensBySub'][sub]; + }, + getLocationUrl({ gistId }) { + return `https://gitee.com/caojiezi2003/codes/${gistId}`; + }, + getLocationDescription({ filename }) { + return filename; + }, + async downloadContent(token, syncLocation) { + const content = await giteeHelper.downloadGist({ + ...syncLocation, + token, + }); + return Provider.parseContent(content, `${syncLocation.fileId}/content`); + }, + async uploadContent(token, content, syncLocation) { + const file = store.state.file.itemsById[syncLocation.fileId]; + const description = utils.sanitizeName(file && file.name); + const gist = await giteeHelper.uploadGist({ + ...syncLocation, + token, + description, + content: Provider.serializeContent(content), + }); + return { + ...syncLocation, + gistId: gist.id, + }; + }, + async publish(token, html, metadata, publishLocation) { + const gist = await giteeHelper.uploadGist({ + ...publishLocation, + token, + description: metadata.title, + content: html, + }); + return { + ...publishLocation, + gistId: gist.id, + }; + }, + makeLocation(token, filename, isPublic, gistId) { + return { + providerId: this.id, + sub: token.sub, + filename, + isPublic, + gistId, + }; + }, + async listFileRevisions({ token, syncLocation }) { + const entries = await giteeHelper.getGistCommits({ + ...syncLocation, + token, + }); - return entries.map((entry) => { - const sub = `${giteeHelper.subPrefix}:${entry.user.id}`; - userSvc.addUserInfo({ id: sub, name: entry.user.login, imageUrl: entry.user.avatar_url }); - return { - sub, - id: entry.version, - message: entry.commit && entry.commit.message, - created: new Date(entry.committed_at).getTime(), - }; - }); - }, - async loadFileRevision() { - // Revision are already loaded - return false; - }, - // async getFileRevisionContent({ - // token, - // contentId, - // syncLocation, - // revisionId, - // }) { - // const data = await giteeHelper.downloadGistRevision({ - // ...syncLocation, - // token, - // sha: revisionId, - // }); - // return Provider.parseContent(data, contentId); - // }, -}); + return entries.map((entry) => { + const sub = `${giteeHelper.subPrefix}:${entry.user.id}`; + userSvc.addUserInfo({ id: sub, name: entry.user.login, imageUrl: entry.user.avatar_url }); + return { + sub, + id: entry.version, + message: entry.commit && entry.commit.message, + created: new Date(entry.committed_at).getTime(), + }; + }); + }, + async loadFileRevision() { + // Revision are already loaded + return false; + }, + // async getFileRevisionContent({ + // token, + // contentId, + // syncLocation, + // revisionId, + // }) { + // const data = await giteeHelper.downloadGistRevision({ + // ...syncLocation, + // token, + // sha: revisionId, + // }); + // return Provider.parseContent(data, contentId); + // }, +}); \ No newline at end of file