Skip to content

Commit 0a429c6

Browse files
author
guqiankun.gqk
committed
chore: bug fix
1 parent a82a642 commit 0a429c6

4 files changed

Lines changed: 32 additions & 31 deletions

File tree

packages/acr/src/modules/common-commands/index.contribution.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,25 +85,6 @@ export class CommonCommandsContribution implements CommandContribution {
8585
},
8686
});
8787

88-
// 注册命令 供外部调用props
89-
commandRegistry.registerCommand(
90-
{
91-
id: 'antcode-cr.props',
92-
},
93-
{
94-
execute: async () => {
95-
const { comments, annotations, projectMeta, pullRequestChangeList, noteIdToReplyIdSet } =
96-
this.antCodeService;
97-
return {
98-
comments,
99-
annotations,
100-
projectMeta,
101-
pullRequestChangeList,
102-
noteIdToReplyIdSet: noteIdToReplyIdSet,
103-
};
104-
},
105-
}
106-
);
10788
commandRegistry.registerCommand(
10889
{
10990
id: 'antcode-cr.setBadge',

packages/acr/src/normalize.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ html {
1212
// 全局默认字体颜色
1313
color: var(--foreground);
1414
background-color: var(--editor-background);
15+
16+
// 全局设置滚动条样式
17+
// scrollbar 重置为应用的值,react-custom-scrollbars 用的 body 滚动条宽度,mac 上为 15px,windows 上为 17px
1518
// 这里如果设置为 kaitian 的 10px,会导致无法滚到到顶部,有 5~7px 的偏差
1619
// issue 见 https://baiyan.alipay.com/task/122717?bqlKey=fc2b39b
1720
::-webkit-scrollbar {

packages/integrations/src/antcode-cr/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { useEffect } from 'react';
2+
import { useEffect, useRef } from 'react';
33
import ReactDOM from 'react-dom';
44
import { Button, Switch } from 'antd';
55
import 'antd/dist/antd.css';
@@ -51,7 +51,7 @@ const App = () => {
5151
const fileReadMarkChange$ = useFileReadMarkChange$(diffsPack?.diffs ?? [], readMarks);
5252

5353
useEffect(() => {
54-
if (!CodeScaningPlugin.ready) {
54+
if (!CodeScaningPlugin?.ready) {
5555
return;
5656
}
5757
// map 需要转译
@@ -72,16 +72,28 @@ const App = () => {
7272
);
7373
}, [commentPack.updateFlag]);
7474
useEffect(() => {
75-
if (!CodeScaningPlugin.ready) {
75+
if (!CodeScaningPlugin?.ready) {
7676
return;
7777
}
7878
CodeScaningPlugin.commands?.executeCommand('antcode-cr.update', 'annotations', annotationPacks);
7979
}, [annotationPacks]);
8080

81-
// const extensionMetadata = useLoadLocalExtensionMetadata()
82-
// if(!extensionMetadata) return null
81+
const extensionMetadata = useLoadLocalExtensionMetadata();
82+
if (!extensionMetadata) return null;
8383
if (!diffsPack) return null;
8484

85+
CodeScaningPlugin.setProps({
86+
noteIdToNote: commentPack.noteIdToNote,
87+
annotations: annotationPacks,
88+
projectMeta: {
89+
projectId: project.pathWithNamespace,
90+
prId: pr?.iid,
91+
pullRequestId: pr?.id,
92+
},
93+
pullRequestChangeList: diffsPack?.diffs,
94+
noteIdToReplyIdSet: commentPack.noteIdToReplyIdSet,
95+
});
96+
8597
const props = {
8698
noteIdToReplyIdSet: commentPack.noteIdToReplyIdSet,
8799
addLineNum: diffsPack.addLineNum,
@@ -145,8 +157,8 @@ const App = () => {
145157
.with({ path: path.join('/antcode', project.pathWithNamespace, 'raw') })
146158
.toString(),
147159
plugins: [acrPlugin, CodeScaningPlugin],
148-
extensionMetadata: [CodeScaning],
149-
// extensionMetadata
160+
// extensionMetadata: [CodeScaning],
161+
extensionMetadata,
150162
},
151163
} as IAntcodeCRProps;
152164

packages/integrations/src/common/code-scaning.plugin.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export class Plugin implements IPluginModule {
55

66
private _commands: IPluginAPI['commands'] | null = null;
77

8+
private _ready: boolean = false;
9+
10+
private props: null = null;
11+
812
get commands() {
913
return this._commands;
1014
}
@@ -13,15 +17,16 @@ export class Plugin implements IPluginModule {
1317
return this._ready;
1418
}
1519

16-
private _ready: boolean = false;
20+
setProps(props) {
21+
this.props = props;
22+
}
1723

1824
async activate({ context, commands }: IPluginAPI) {
1925
this._commands = commands;
2026
context.subscriptions.push(
21-
// 判断 extension 注册成功
22-
commands.registerCommand('antcode-cr.plugin.ready', async () => {
23-
this._ready = (await commands.executeCommand('antcode-cr.ready')) as boolean;
24-
return true;
27+
commands.registerCommand('antcode-cr.plugin.props', async () => {
28+
this._ready = true;
29+
return this.props;
2530
})
2631
);
2732
}

0 commit comments

Comments
 (0)