Skip to content

Commit 8d13c8b

Browse files
author
Deep-sea-school
committed
回滚代码
1 parent a7a79a8 commit 8d13c8b

6 files changed

Lines changed: 70 additions & 247 deletions

File tree

src/components/github-oauth-modal/github-oauth-modal.jsx

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,10 @@ const GitHubOAuthModal = props => {
156156
});
157157
}
158158

159-
// 检查是否在桌面环境中,如果是,检查是否有待处理的 OAuth 回调
160-
const isDesktop = typeof EditorPreload !== 'undefined';
161-
if (isDesktop) {
162-
// 在桌面环境中,我们不依赖 URL 参数
163-
// 而是依赖主进程发送的 token
164-
} else {
165-
// 检查 URL 参数是否包含 OAuth 回调
166-
const params = new URLSearchParams(window.location.search);
167-
if (params.has('code')) {
168-
handleOAuthCallback();
169-
}
159+
// 检查 URL 参数是否包含 OAuth 回调
160+
const params = new URLSearchParams(window.location.search);
161+
if (params.has('code')) {
162+
handleOAuthCallback();
170163
}
171164
}
172165
}, [isOpen]);
@@ -191,42 +184,6 @@ const GitHubOAuthModal = props => {
191184
setIsAuthenticating(false);
192185
}
193186
};
194-
195-
// 桌面环境中的 OAuth 令牌接收处理
196-
React.useEffect(() => {
197-
let unsubscribe = null;
198-
199-
if (isOpen && typeof EditorPreload !== 'undefined') {
200-
// 在桌面环境中监听来自主进程的 OAuth 令牌
201-
unsubscribe = EditorPreload.receiveOAuthToken(async (token) => {
202-
try {
203-
setIsAuthenticating(true);
204-
setError('');
205-
206-
// 使用接收到的令牌处理用户信息
207-
const result = await githubOAuth.processToken(token);
208-
setUserInfo({
209-
...result.user,
210-
email: result.email
211-
});
212-
213-
onSuccess && onSuccess(result);
214-
} catch (err) {
215-
console.error('OAuth token processing failed:', err);
216-
setError(err.message);
217-
onError && onError(err);
218-
} finally {
219-
setIsAuthenticating(false);
220-
}
221-
});
222-
}
223-
224-
return () => {
225-
if (unsubscribe) {
226-
unsubscribe();
227-
}
228-
};
229-
}, [isOpen]);
230187

231188
const handleAuthenticate = async () => {
232189
try {

src/components/gui/gui.jsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,6 @@ const GUIComponent = props => {
829829
onClickGitCommit={handleClickGitCommit}
830830
onGitQuickAction={handleGitQuickAction}
831831
showGitQuickButtons={hasGitRepository() && hasGitToken()}
832-
onClickGitHubOAuth={() => setIsOAuthModalOpen(true)}
833832
/>
834833
)}
835834
<Box className={styles.bodyWrapper}>
@@ -1138,8 +1137,6 @@ GUIComponent.propTypes = {
11381137
fontsModalVisible: PropTypes.bool,
11391138
unknownPlatformModalVisible: PropTypes.bool,
11401139
invalidProjectModalVisible: PropTypes.bool,
1141-
githubOAuthModalVisible: PropTypes.bool,
1142-
onClickGitHubOAuth: PropTypes.func,
11431140
vm: PropTypes.instanceOf(VM).isRequired
11441141
};
11451142
GUIComponent.defaultProps = {

src/components/menu-bar/menu-bar.jsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,29 +1079,6 @@ class MenuBar extends React.Component {
10791079
</span>
10801080
</div>
10811081
</div>}
1082-
{<div className={styles.menuBarItem}>
1083-
<div
1084-
className={classNames(styles.menuBarItem, styles.hoverable)}
1085-
onClick={this.props.onClickGitHubOAuth}
1086-
>
1087-
<svg
1088-
className={styles.githubIcon}
1089-
width="20"
1090-
height="20"
1091-
viewBox="0 0 24 24"
1092-
fill="currentColor"
1093-
>
1094-
<path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
1095-
</svg>
1096-
<span className={styles.collapsibleLabel}>
1097-
<FormattedMessage
1098-
defaultMessage="GitHub"
1099-
description="Button to open GitHub OAuth"
1100-
id="gui.menuBar.github"
1101-
/>
1102-
</span>
1103-
</div>
1104-
</div>}
11051082
{/* Git 快捷按钮 */}
11061083
{this.props.vm && this.props.vm.runtime && this.props.vm.runtime.platform &&
11071084
this.props.vm.runtime.platform.git && this.props.vm.runtime.platform.git.repository &&
@@ -1220,7 +1197,6 @@ MenuBar.propTypes = {
12201197
onClickSaveAsCopy: PropTypes.func,
12211198
onClickSettings: PropTypes.func,
12221199
onClickSettingsModal: PropTypes.func,
1223-
onClickGitHubOAuth: PropTypes.func,
12241200
onLogOut: PropTypes.func,
12251201
onOpenRegistration: PropTypes.func,
12261202
onOpenTipLibrary: PropTypes.func,

src/containers/gui.jsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ import {
2222
closeCostumeLibrary,
2323
closeBackdropLibrary,
2424
closeTelemetryModal,
25-
openExtensionLibrary,
26-
openGitHubOAuthModal,
27-
closeGitHubOAuthModal
25+
openExtensionLibrary
2826
} from '../reducers/modals';
2927

3028
import FontLoaderHOC from '../lib/font-loader-hoc.jsx';
@@ -103,9 +101,6 @@ class GUI extends React.Component {
103101
return (
104102
<GUIComponent
105103
loading={fetchingProject || isLoading || loadingStateVisible}
106-
githubOAuthModalVisible={githubOAuthModalVisible}
107-
onOpenGitHubOAuthModal={onOpenGitHubOAuthModal}
108-
onRequestCloseGitHubOAuthModal={onRequestCloseGitHubOAuthModal}
109104
{...componentProps}
110105
>
111106
{children}
@@ -137,9 +132,6 @@ GUI.propTypes = {
137132
projectHost: PropTypes.string,
138133
projectId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
139134
telemetryModalVisible: PropTypes.bool,
140-
githubOAuthModalVisible: PropTypes.bool,
141-
onOpenGitHubOAuthModal: PropTypes.func,
142-
onRequestCloseGitHubOAuthModal: PropTypes.func,
143135
vm: PropTypes.instanceOf(VM).isRequired
144136
};
145137

@@ -185,7 +177,6 @@ const mapStateToProps = state => {
185177
fontsModalVisible: state.scratchGui.modals.fontsModal,
186178
unknownPlatformModalVisible: state.scratchGui.modals.unknownPlatformModal,
187179
invalidProjectModalVisible: state.scratchGui.modals.invalidProjectModal,
188-
githubOAuthModalVisible: state.scratchGui.modals.githubOAuthModal,
189180
vm: state.scratchGui.vm
190181
};
191182
};
@@ -197,9 +188,7 @@ const mapDispatchToProps = dispatch => ({
197188
onActivateSoundsTab: () => dispatch(activateTab(SOUNDS_TAB_INDEX)),
198189
onRequestCloseBackdropLibrary: () => dispatch(closeBackdropLibrary()),
199190
onRequestCloseCostumeLibrary: () => dispatch(closeCostumeLibrary()),
200-
onRequestCloseTelemetryModal: () => dispatch(closeTelemetryModal()),
201-
onRequestOpenGitHubOAuthModal: () => dispatch(openGitHubOAuthModal()),
202-
onRequestCloseGitHubOAuthModal: () => dispatch(closeGitHubOAuthModal())
191+
onRequestCloseTelemetryModal: () => dispatch(closeTelemetryModal())
203192
});
204193

205194
const ConnectedGUI = injectIntl(connect(

0 commit comments

Comments
 (0)