mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
feat: better error message when token expire
this fixes https://github.com/tiddly-gittly/TiddlyGit-Desktop/issues/100
This commit is contained in:
parent
65cd4cff54
commit
fe41e3b13e
3 changed files with 38 additions and 11 deletions
|
|
@ -186,7 +186,8 @@
|
|||
"CheckingLocalSyncState": "Detecting whether the local state needs to be synchronized to the cloud",
|
||||
"CheckingRebaseStatus": "Analyzing the rebase processing plan",
|
||||
"InitializeWikiGit": "Initializing Wiki and Git",
|
||||
"InitializeWorkspaceView": "Initializing workspace and browser view, and loading the web content, please wait"
|
||||
"InitializeWorkspaceView": "Initializing workspace and browser view, and loading the web content, please wait",
|
||||
"GitTokenExpireOrWrong": "The Git credential (Token) has expired and you need to log in again, or the credential does not correspond to the user name"
|
||||
},
|
||||
"Cancel": "Cancel",
|
||||
"Preference": {
|
||||
|
|
@ -274,7 +275,8 @@
|
|||
"ToggleMenuBar": "Toggle Menu Bar",
|
||||
"NoAttach": "Resume Window Mode",
|
||||
"AlwaysOnTop": "Always on top",
|
||||
"AlwaysOnTopDetail": "Keep TiddlyGit’s main window always on top of other windows, and will not be covered by other windows"
|
||||
"AlwaysOnTopDetail": "Keep TiddlyGit’s main window always on top of other windows, and will not be covered by other windows",
|
||||
"RequireRestart": "Need to restart"
|
||||
},
|
||||
"Error": {
|
||||
"InitWikiGitError": "E-1 InitWikiGitError",
|
||||
|
|
@ -291,7 +293,9 @@
|
|||
"InitWikiGitSyncedWikiNoGitUserInfoErrorDescription": "E-6 Initializing the note repository synchronized to the cloud requires you to select a cloud git repository address and provide the certification credentials for the corresponding cloud service. However, this information is not currently available.",
|
||||
"MainWindowMissing": "E-7 This program can't access main window data, can't run normally.",
|
||||
"WorkspaceFailedToLoadError": "E-8 WorkspaceFailedToLoadError",
|
||||
"WorkspaceFailedToLoadErrorDescription": "E-8 The Wiki page corresponding to the workspace failed to load. There are many reasons, but it is basically because of program bugs."
|
||||
"WorkspaceFailedToLoadErrorDescription": "E-8 The Wiki page corresponding to the workspace failed to load. There are many reasons, but it is basically because of program bugs.",
|
||||
"ViewLoadUrlError": "E-9 Failed to load the webpage error",
|
||||
"ViewLoadUrlErrorDescription": "E-9 The Wiki page corresponding to the workspace failed to load, but we will try again soon"
|
||||
},
|
||||
"Loading": "Loading",
|
||||
"Yes": "Yes",
|
||||
|
|
|
|||
|
|
@ -181,7 +181,8 @@
|
|||
"CantSyncGitNotInitialized": "无法同步,这个文件夹没有初始化为 Git 仓库",
|
||||
"HaveThingsToCommit": "有需要提交(Commit)的内容,正在自动提交",
|
||||
"PreparingUserInfo": "正在配置身份信息",
|
||||
"GitTokenMissing": "Git 身份信息缺失",
|
||||
"GitTokenMissing": "Git 凭证(Token)缺失",
|
||||
"GitTokenExpireOrWrong": "Git 凭证(Token)已过期,需要重新登录一次,或凭证与用户名不对应",
|
||||
"AddingFiles": "开始添加(Git Add)待备份的文件",
|
||||
"AddComplete": "添加(Git Add)成功",
|
||||
"FetchingData": "正在拉取云端数据,以便进行数据比对",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ipcMain } from 'electron';
|
||||
import { ipcMain, dialog } from 'electron';
|
||||
import { injectable, inject } from 'inversify';
|
||||
import { debounce } from 'lodash';
|
||||
import {
|
||||
|
|
@ -28,15 +28,18 @@ import { Observer } from 'rxjs';
|
|||
// eslint-disable-next-line import/no-webpack-loader-syntax
|
||||
import workerURL from 'threads-plugin/dist/loader?name=gitWorker!./gitWorker.ts';
|
||||
import { LOCAL_GIT_DIRECTORY } from '@/constants/appPaths';
|
||||
import { WindowNames } from '@services/windows/WindowProperties';
|
||||
import { lazyInject } from '@services/container';
|
||||
import { IWindowService } from '@services/windows/interface';
|
||||
|
||||
@injectable()
|
||||
export class Git implements IGitService {
|
||||
@lazyInject(serviceIdentifier.Window) private readonly windowService!: IWindowService;
|
||||
@lazyInject(serviceIdentifier.View) private readonly viewService!: IViewService;
|
||||
|
||||
private gitWorker?: ModuleThread<GitWorker>;
|
||||
|
||||
constructor(
|
||||
@inject(serviceIdentifier.View) private readonly viewService: IViewService,
|
||||
@inject(serviceIdentifier.Preference) private readonly preferenceService: IPreferenceService,
|
||||
) {
|
||||
constructor(@inject(serviceIdentifier.Preference) private readonly preferenceService: IPreferenceService) {
|
||||
void this.initWorker();
|
||||
this.debounceCommitAndSync = this.commitAndSync.bind(this);
|
||||
void this.preferenceService.get('syncDebounceInterval').then((syncDebounceInterval) => {
|
||||
|
|
@ -196,9 +199,28 @@ export class Git implements IGitService {
|
|||
logger.error('↑Translated→: ' + error?.message ?? error);
|
||||
}
|
||||
|
||||
private popGitErrorNotificationToUser(step: GitStep, message: string): void {
|
||||
if (step === GitStep.GitPushFailed && message.includes('403')) {
|
||||
const mainWindow = this.windowService.get(WindowNames.main);
|
||||
if (mainWindow !== undefined) {
|
||||
void dialog.showMessageBox(mainWindow, {
|
||||
title: i18n.t('Log.GitTokenMissing'),
|
||||
message: `${i18n.t('Log.GitTokenExpireOrWrong')} (${message})`,
|
||||
buttons: ['OK'],
|
||||
cancelId: 0,
|
||||
defaultId: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly getWorkerObserver = (resolve: () => void, reject: (error: Error) => void): Observer<IGitLogMessage> => ({
|
||||
next: (message) => {
|
||||
logger.log(message.level, this.translateMessage(message.message), message.meta);
|
||||
next: (messageObject) => {
|
||||
const { message, meta, level } = messageObject;
|
||||
if (typeof meta === 'object' && meta !== null && 'step' in meta) {
|
||||
this.popGitErrorNotificationToUser((meta as { step: GitStep }).step, message);
|
||||
}
|
||||
logger.log(level, this.translateMessage(message), meta);
|
||||
},
|
||||
error: (error) => {
|
||||
this.translateAndLogErrorMessage(error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue