A full-featured download manager.
fix(settings): reveal the configuration file in its folder (#2384)
Dr_rOot828293069565
diff --git a/src/main/ipc/commands.test.ts b/src/main/ipc/commands.test.tsindex 2c8aa4be..1a41bbdf 100644--- a/src/main/ipc/commands.test.ts+++ b/src/main/ipc/commands.test.ts@@ -85,6 +85,7 @@ const ipcHandleMock = vi.fn()const ipcRemoveHandlerMock = vi.fn()const openExternalMock = vi.fn()const openPathMock = vi.fn()+const showItemInFolderMock = vi.fn()const showOpenDialogMock = vi.fn()const showSaveDialogMock = vi.fn()vi.mock('electron', () => ({@@ -103,7 +104,7 @@ vi.mock('electron', () => ({shell: {openExternal: (...args: unknown[]) => openExternalMock(...args),openPath: (...args: unknown[]) => openPathMock(...args),- showItemInFolder: vi.fn(),+ showItemInFolder: (...args: unknown[]) => showItemInFolderMock(...args),},}))@@ -315,25 +316,35 @@ function fakeCtx() {}describe('buildCommandHandlers', () => {- it('opens only the active settings directory and reports shell failures', async () => {- const ctx = fakeCtx()- const handler = buildCommandHandlers({- ...ctx,- settingsManager: {- ...ctx.settingsManager,- getFilePath: () => '/custom profile/settings.json',- },- } as unknown as CommandContext)[Commands.OpenSettingsDirectory]!- openPathMock.mockReset().mockResolvedValue('')- await expect(handler({ path: '/unrelated' })).rejects.toThrow()- expect(openPathMock).not.toHaveBeenCalled()- await expect(handler()).resolves.toBe(true)- expect(openPathMock).toHaveBeenCalledExactlyOnceWith('/custom profile')- openPathMock.mockResolvedValueOnce('No file manager available')- await expect(handler()).resolves.toBe(false)- openPathMock.mockRejectedValueOnce(new Error('Shell unavailable'))- await expect(handler()).rejects.toThrow('Shell unavailable')- })+ it.each([+ '/custom profile/settings.json',+ 'C:\\Users\\Example\\配置\\settings.json',+ '\\\\server\\share\\profile\\settings.json',+ ])(+ 'reveals the full active settings file %s and rejects caller paths',+ async (filePath) => {+ const ctx = fakeCtx()+ const handler = buildCommandHandlers({+ ...ctx,+ settingsManager: {+ ...ctx.settingsManager,+ getFilePath: () => filePath,+ },+ } as unknown as CommandContext)[Commands.OpenSettingsDirectory]!+ openPathMock.mockReset().mockResolvedValue('')+ showItemInFolderMock.mockReset()+ await expect(handler({ path: '/unrelated' })).rejects.toThrow()+ expect(openPathMock).not.toHaveBeenCalled()+ expect(showItemInFolderMock).not.toHaveBeenCalled()+ await expect(handler()).resolves.toBe(true)+ expect(showItemInFolderMock).toHaveBeenCalledExactlyOnceWith(filePath)+ expect(openPathMock).not.toHaveBeenCalled()+ showItemInFolderMock.mockImplementationOnce(() => {+ throw new Error('Shell unavailable')+ })+ await expect(handler()).rejects.toThrow('Shell unavailable')+ }+ )it('downloads registry packages through the injected plugin transport and serializes failures', async () => {const dir = await mkdtemp(path.join(tmpdir(), 'plugin-network-command-'))diff --git a/src/main/ipc/commands.ts b/src/main/ipc/commands.tsindex 24e7850c..dd1489b1 100644--- a/src/main/ipc/commands.ts+++ b/src/main/ipc/commands.ts@@ -1080,10 +1080,9 @@ export function buildCommandHandlers(ctx: CommandContext): CommandHandlerMap {[Commands.OpenSettingsDirectory]: async (payload: unknown) => {z.undefined().parse(payload)- const error = await shell.openPath(- path.dirname(settingsManager.getFilePath())- )- return error === ''+ shell.showItemInFolder(settingsManager.getFilePath())+ // The native reveal API does not report a completion result.+ return true},[Commands.UpdateSettings]: async (partial: unknown) => {