gitee 接口限制兼容
This commit is contained in:
		
							parent
							
								
									e1eb7ec350
								
							
						
					
					
						commit
						72f9fea42e
					
				| @ -35,7 +35,6 @@ exports.publicValues = { | |||||||
|   dropboxAppKey, |   dropboxAppKey, | ||||||
|   dropboxAppKeyFull, |   dropboxAppKeyFull, | ||||||
|   githubClientId, |   githubClientId, | ||||||
|   giteeClientId, |  | ||||||
|   googleClientId, |   googleClientId, | ||||||
|   googleApiKey, |   googleApiKey, | ||||||
|   wordpressClientId, |   wordpressClientId, | ||||||
|  | |||||||
| @ -34,7 +34,11 @@ module.exports = (app) => { | |||||||
|   app.post('/paypalIpn', bodyParser.urlencoded({ |   app.post('/paypalIpn', bodyParser.urlencoded({ | ||||||
|     extended: false, |     extended: false, | ||||||
|   }), user.paypalIpn); |   }), user.paypalIpn); | ||||||
| 
 |   app.get('/giteeClientId', (req, res) => { | ||||||
|  |     const giteeClientIds = conf.values.giteeClientId.split(','); | ||||||
|  |     const clientId = giteeClientIds[Math.floor((giteeClientIds.length * Math.random()))]; | ||||||
|  |     res.send(clientId); | ||||||
|  |   }); | ||||||
|   // Serve landing.html
 |   // Serve landing.html
 | ||||||
|   app.get('/', (req, res) => res.sendFile(resolvePath('static/landing/index.html'))); |   app.get('/', (req, res) => res.sendFile(resolvePath('static/landing/index.html'))); | ||||||
|   // Serve privacy_policy.html
 |   // Serve privacy_policy.html
 | ||||||
|  | |||||||
| @ -56,7 +56,6 @@ import GithubWorkspaceModal from './modals/providers/GithubWorkspaceModal'; | |||||||
| import GithubPublishModal from './modals/providers/GithubPublishModal'; | import GithubPublishModal from './modals/providers/GithubPublishModal'; | ||||||
| import GistSyncModal from './modals/providers/GistSyncModal'; | import GistSyncModal from './modals/providers/GistSyncModal'; | ||||||
| import GistPublishModal from './modals/providers/GistPublishModal'; | import GistPublishModal from './modals/providers/GistPublishModal'; | ||||||
| import GiteeAccountModal from './modals/providers/GiteeAccountModal'; |  | ||||||
| import GiteeOpenModal from './modals/providers/GiteeOpenModal'; | import GiteeOpenModal from './modals/providers/GiteeOpenModal'; | ||||||
| import GiteeSaveModal from './modals/providers/GiteeSaveModal'; | import GiteeSaveModal from './modals/providers/GiteeSaveModal'; | ||||||
| import GiteeWorkspaceModal from './modals/providers/GiteeWorkspaceModal'; | import GiteeWorkspaceModal from './modals/providers/GiteeWorkspaceModal'; | ||||||
| @ -120,7 +119,6 @@ export default { | |||||||
|     GithubPublishModal, |     GithubPublishModal, | ||||||
|     GistSyncModal, |     GistSyncModal, | ||||||
|     GistPublishModal, |     GistPublishModal, | ||||||
|     GiteeAccountModal, |  | ||||||
|     GiteeOpenModal, |     GiteeOpenModal, | ||||||
|     GiteeSaveModal, |     GiteeSaveModal, | ||||||
|     GiteeWorkspaceModal, |     GiteeWorkspaceModal, | ||||||
|  | |||||||
| @ -252,7 +252,6 @@ export default { | |||||||
|     }, |     }, | ||||||
|     async addGiteeAccount() { |     async addGiteeAccount() { | ||||||
|       try { |       try { | ||||||
|         await store.dispatch('modal/open', { type: 'giteeAccount' }); |  | ||||||
|         await giteeHelper.addAccount(); |         await giteeHelper.addAccount(); | ||||||
|       } catch (e) { /* cancel */ } |       } catch (e) { /* cancel */ } | ||||||
|     }, |     }, | ||||||
|  | |||||||
| @ -1,31 +0,0 @@ | |||||||
| <template> |  | ||||||
|   <modal-inner aria-label="链接Gitee账号"> |  | ||||||
|     <div class="modal__content"> |  | ||||||
|       <div class="modal__image"> |  | ||||||
|         <icon-provider provider-id="gitee"></icon-provider> |  | ||||||
|       </div> |  | ||||||
|       <p>将您的<b>Gitee</b>账号链接到<b>StackEdit</b>。</p> |  | ||||||
|       <div class="form-entry"> |  | ||||||
|         <div class="form-entry__checkbox"> |  | ||||||
|           <label> |  | ||||||
|             <input type="checkbox" v-model="repoFullAccess"> 授予您私人仓库的访问权限 |  | ||||||
|           </label> |  | ||||||
|         </div> |  | ||||||
|       </div> |  | ||||||
|     </div> |  | ||||||
|     <div class="modal__button-bar"> |  | ||||||
|       <button class="button" @click="config.reject()">取消</button> |  | ||||||
|       <button class="button button--resolve" @click="config.resolve()">确认</button> |  | ||||||
|     </div> |  | ||||||
|   </modal-inner> |  | ||||||
| </template> |  | ||||||
| 
 |  | ||||||
| <script> |  | ||||||
| import modalTemplate from '../common/modalTemplate'; |  | ||||||
| 
 |  | ||||||
| export default modalTemplate({ |  | ||||||
|   computedLocalSettings: { |  | ||||||
|     repoFullAccess: 'giteeRepoFullAccess', |  | ||||||
|   }, |  | ||||||
| }); |  | ||||||
| </script> |  | ||||||
| @ -70,7 +70,6 @@ export default new Provider({ | |||||||
|       token = store.getters['data/giteeTokensBySub'][workspace.sub]; |       token = store.getters['data/giteeTokensBySub'][workspace.sub]; | ||||||
|     } |     } | ||||||
|     if (!token) { |     if (!token) { | ||||||
|       await store.dispatch('modal/open', { type: 'giteeAccount' }); |  | ||||||
|       token = await giteeHelper.addAccount(); |       token = await giteeHelper.addAccount(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -69,10 +69,12 @@ export default { | |||||||
|    * https://developer.gitee.com/apps/building-oauth-apps/authorization-options-for-oauth-apps/
 |    * https://developer.gitee.com/apps/building-oauth-apps/authorization-options-for-oauth-apps/
 | ||||||
|    */ |    */ | ||||||
|   async startOauth2(lastToken, silent = false, isMain) { |   async startOauth2(lastToken, silent = false, isMain) { | ||||||
|     const giteeClientIds = store.getters['data/serverConf'].giteeClientId.split(','); |  | ||||||
|     const clientId = giteeClientIds[Math.floor((giteeClientIds.length * Math.random()))]; |  | ||||||
|     let tokenBody; |     let tokenBody; | ||||||
|     if (!silent) { |     if (!silent) { | ||||||
|  |       const clientId = (await networkSvc.request({ | ||||||
|  |         method: 'GET', | ||||||
|  |         url: 'giteeClientId', | ||||||
|  |       })).body; | ||||||
|       // Get an OAuth2 code
 |       // Get an OAuth2 code
 | ||||||
|       const { code } = await networkSvc.startOauth2( |       const { code } = await networkSvc.startOauth2( | ||||||
|         'https://gitee.com/oauth/authorize', |         'https://gitee.com/oauth/authorize', | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user