diff --git a/electron-projects/ucap-webmessenger-electron/src/index.ts b/electron-projects/ucap-webmessenger-electron/src/index.ts
index cc623dac..64512f29 100644
--- a/electron-projects/ucap-webmessenger-electron/src/index.ts
+++ b/electron-projects/ucap-webmessenger-electron/src/index.ts
@@ -5,7 +5,8 @@ import {
remote,
Tray,
Menu,
- dialog
+ dialog,
+ shell
} from 'electron';
import * as path from 'path';
import * as url from 'url';
@@ -319,6 +320,38 @@ ipcMain.on(
}
);
+ipcMain.on(
+ FileChannel.OpenFolderItem,
+ async (event: IpcMainEvent, ...args: any[]) => {
+ try {
+ let folderItem: string = args[0];
+ const make: boolean = args[1];
+ if (!folderItem) {
+ folderItem = DefaultFolder.downloads();
+ }
+
+ let isSuccess = true;
+ if (make) {
+ fse.ensureDirSync(folderItem);
+ }
+
+ if (isSuccess && fse.existsSync(folderItem)) {
+ shell.openItem(folderItem);
+ } else {
+ isSuccess = false;
+ }
+
+ if (isSuccess) {
+ event.returnValue = true;
+ } else {
+ event.returnValue = false;
+ }
+ } catch (error) {
+ event.returnValue = false;
+ }
+ }
+);
+
ipcMain.on(
IdleStateChannel.StartCheck,
(event: IpcMainEvent, ...args: any[]) => {
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.html b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.html
index e667e199..61ff2f34 100644
--- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.html
+++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/album-box.component.html
@@ -149,7 +149,11 @@
>
Download All
-
-
+
Open Folder
diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.ts
index c583a335..463bfdba 100644
--- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.ts
+++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/right-drawer/file-box.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core';
+import { Component, OnInit, ViewChild, OnDestroy, Inject } from '@angular/core';
import { MatPaginator, MatTableDataSource, MatSort } from '@angular/material';
import {
FileInfo,
@@ -15,6 +15,8 @@ import { FileUtil } from '@ucap-webmessenger/core';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { KEY_LOGIN_RES_INFO } from '@app/types/login-res-info.type';
+import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
+import { NGXLogger } from 'ngx-logger';
export interface FileInfoTotal {
info: FileInfo;
@@ -46,7 +48,9 @@ export class FileBoxComponent implements OnInit, OnDestroy {
constructor(
private store: Store,
- private sessionStorageService: SessionStorageService
+ private sessionStorageService: SessionStorageService,
+ @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
+ private loggger: NGXLogger
) {
this.loginRes = this.sessionStorageService.get(
KEY_LOGIN_RES_INFO
@@ -212,4 +216,18 @@ export class FileBoxComponent implements OnInit, OnDestroy {
onClickRow(row: FileInfoTotal) {
this.selectedFile = row;
}
+
+ onClickOpenDownloadFolder(): void {
+ this.nativeService
+ .openDefaultDownloadFolder()
+ .then(result => {
+ if (!!result) {
+ } else {
+ throw new Error('response Error');
+ }
+ })
+ .catch(reason => {
+ this.loggger.error(reason);
+ });
+ }
}
diff --git a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts
index 519e7811..c5e4ab72 100644
--- a/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts
+++ b/projects/ucap-webmessenger-native-browser/src/lib/services/browser-native.service.ts
@@ -99,6 +99,22 @@ export class BrowserNativeService extends NativeService {
});
}
+ openDefaultDownloadFolder(): Promise {
+ return new Promise((resolve, reject) => {
+ resolve(true);
+ });
+ }
+ openTargetFolder(folderPath?: string, make?: boolean): Promise {
+ return new Promise((resolve, reject) => {
+ resolve(true);
+ });
+ }
+ openTargetItem(filePath?: string): Promise {
+ return new Promise((resolve, reject) => {
+ resolve(true);
+ });
+ }
+
windowStateChanged(): Observable {
return new Observable(subscriber => {
try {
diff --git a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts
index 06601094..af3876c4 100644
--- a/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts
+++ b/projects/ucap-webmessenger-native-electron/src/lib/services/electron-native.service.ts
@@ -147,6 +147,44 @@ export class ElectronNativeService implements NativeService {
});
}
+ openDefaultDownloadFolder(): Promise {
+ return new Promise((resolve, reject) => {
+ try {
+ resolve(
+ this.ipcRenderer.sendSync(FileChannel.OpenFolderItem, undefined, true)
+ );
+ } catch (error) {
+ reject(error);
+ }
+ });
+ }
+ openTargetFolder(folderPath?: string, make?: boolean): Promise {
+ return new Promise((resolve, reject) => {
+ try {
+ resolve(
+ this.ipcRenderer.sendSync(
+ FileChannel.OpenFolderItem,
+ folderPath,
+ !make ? false : make
+ )
+ );
+ } catch (error) {
+ reject(error);
+ }
+ });
+ }
+ openTargetItem(filePath?: string): Promise {
+ return new Promise((resolve, reject) => {
+ try {
+ resolve(
+ this.ipcRenderer.sendSync(FileChannel.OpenFolderItem, filePath, false)
+ );
+ } catch (error) {
+ reject(error);
+ }
+ });
+ }
+
windowStateChanged(): Observable {
if (!this.windowStateChangedSubject) {
this.windowStateChangedSubject = new Subject();
diff --git a/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts b/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts
index 2b3aa1e1..fe516543 100644
--- a/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts
+++ b/projects/ucap-webmessenger-native-electron/src/lib/types/channel.type.ts
@@ -18,6 +18,7 @@ export enum UpdaterChannel {
}
export enum FileChannel {
+ OpenFolderItem = 'UCAP::file::openFolderItem',
ShowImageViewer = 'UCAP::file::showImageViewer',
SaveFile = 'UCAP::file::saveFile',
ReadFile = 'UCAP::file::readFile'
diff --git a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts
index 735342c8..a4ae7f39 100644
--- a/projects/ucap-webmessenger-native/src/lib/services/native.service.ts
+++ b/projects/ucap-webmessenger-native/src/lib/services/native.service.ts
@@ -27,6 +27,12 @@ export abstract class NativeService {
path?: string
): Promise;
abstract readFile(path: string): Promise;
+ abstract openDefaultDownloadFolder(): Promise;
+ abstract openTargetFolder(
+ folderPath?: string,
+ make?: boolean
+ ): Promise;
+ abstract openTargetItem(filePath?: string): Promise;
abstract windowStateChanged(): Observable;
abstract windowClose(): void;