Skip to content

Commit 21bb721

Browse files
authored
Merge pull request #260 from opensumi/v2.4
chore(release): release v2.4.4
2 parents e305fda + 93a6365 commit 21bb721

File tree

14 files changed

+71
-26
lines changed

14 files changed

+71
-26
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
3-
"version": "2.4.3"
3+
"version": "2.4.4"
44
}

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-cli",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-cli",
55
"main": "lib/commander.js",
66
"files": [

packages/code-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-code-api",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-code-api",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/code-api/src/common/config.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CodePlatform, ICodePlatform } from './types';
2+
import merge from 'lodash/merge';
23

34
export interface ICodePlatformConfig {
45
platform: CodePlatform | string;
@@ -219,18 +220,7 @@ export class CodePlatformRegistry {
219220
if (!provider) {
220221
return;
221222
}
222-
if (Array.isArray(data.hostname)) {
223-
provider.hostname.push(...data.hostname);
224-
}
225-
if (data.origin) {
226-
provider.origin = data.origin;
227-
}
228-
if (data.endpoint) {
229-
provider.endpoint = data.endpoint;
230-
}
231-
if (data.token) {
232-
provider.token = data.token;
233-
}
223+
merge(provider, data);
234224
}
235225

236226
load(configs: Record<string, ICodePlatformConfig>) {

packages/code-api/src/gitee/gitee.service.ts

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class GiteeAPIService implements ICodeAPIService {
5252

5353
private redirectUrl = this.config.redirectUrl;
5454

55-
private client_id = '';
55+
private client_id = this.config.clientId;
5656

5757
get PRIVATE_TOKEN() {
5858
if (!this._PRIVATE_TOKEN) {
@@ -104,9 +104,64 @@ export class GiteeAPIService implements ICodeAPIService {
104104
throw new Error('Method not implemented.');
105105
}
106106

107+
private sleep(t: number) {
108+
return new Promise(res => {
109+
setTimeout(() => {
110+
res(undefined);
111+
}, t);
112+
});
113+
}
114+
107115
private async checkAccessToken(): Promise<boolean> {
108116
return new Promise<boolean>(async (resolve, reject) => {
109117
resolve(true);
118+
// 一开始就弹出弹窗会有颜色闪烁问题,先临时 sleep 处理,后面再优化
119+
await this.sleep(300);
120+
const btn = await this.helper.showDialog({
121+
message: '检测到 OAuth 未授权',
122+
type: MessageType.Info,
123+
closable: false,
124+
buttons: ['去授权'],
125+
});
126+
127+
let popupWindow;
128+
if (btn === '去授权') {
129+
popupWindow = window.open(
130+
`${this.config.origin}/oauth/authorize?client_id=${this.client_id}&response_type=code&redirect_uri=${this.redirectUrl}`,
131+
'_blank',
132+
'directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=800,height=520,top=150,left=150'
133+
);
134+
}
135+
const handleMessage = async (event: MessageEvent) => {
136+
try {
137+
const { data } = event;
138+
if (isObject(data) && data.type === 'gitee') {
139+
const {
140+
data: { token },
141+
} = data;
142+
popupWindow?.close();
143+
if (!token) {
144+
resolve(false);
145+
return;
146+
}
147+
148+
// 清理过期的 token;
149+
this.clearToken();
150+
151+
this.helper.GITEE_TOKEN = token;
152+
this.helper.reinitializeCodeService(true);
153+
if(this.helper.GITEE_TOKEN){
154+
// 需重新加载否则scm插件报错
155+
window.location.reload();
156+
}
157+
resolve(true);
158+
}
159+
} catch (error) {
160+
console.log(error);
161+
reject(error);
162+
}
163+
};
164+
window.addEventListener('message', handleMessage);
110165
});
111166
}
112167

@@ -470,6 +525,6 @@ export class GiteeAPIService implements ICodeAPIService {
470525

471526
clearToken() {
472527
this._PRIVATE_TOKEN = null;
473-
this.helper.ATOMGIT_TOKEN = null;
528+
this.helper.GITEE_TOKEN = null;
474529
}
475530
}

packages/code-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-code-service",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-code-service",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-common",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-common",
55
"main": "lib/index.js",
66
"typing": "lib/index.d.ts",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-core",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-core",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/i18n/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-i18n",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-i18n",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-plugin",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-plugin",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/registry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-registry",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-registry",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/startup/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-startup",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-startup",
55
"main": "lib/index.js",
66
"typing": "types/index.d.ts",

packages/sumi-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-sumi-core",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "core",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/toolkit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codeblitzjs/ide-toolkit",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"description": "@codeblitzjs/ide-toolkit",
55
"main": "index.js",
66
"files": [

0 commit comments

Comments
 (0)