//点击任意出关闭右键弹窗 $(document).off('click').on('click', function(e) { $scope.iscontextMenus = false; if (!$scope.$$phase) { $scope.$apply(); } })
//二人会话和群会话消息,右键打开文件功能 $scope.openRightClick = function ($event) { openRightFile ($event); } function openRightFile ($event) { $event.stopPropagation(); $event.preventDefault(); $scope.iscontextMenus = false; var content_type = items.content_type,//消息的类型是文本消息还是图片消息还是文档消息 $curTarget = angular.element($event.currentTarget); switch (content_type){ case eucTypes.rcsTypes.ContentType.ContentTypePICTURE: const exec = require('child_process').exec; exec('"' + items.file_path + '"'); break; case eucTypes.rcsTypes.ContentType.ContentTypeOTHER: if ((messageService.FILE_STATE.RECEIVE_SUCCESS == items.file_state) || (messageService.FILE_STATE.SEND_SUCCESS == items.file_state)) { const exec = require('child_process').exec; exec('"' +items.file_path + '"'); } break; default : break; } }; //二人会话和群会话消息,右键保存文件功能 const remote = require('electron').remote; var fs = require('fs'); $scope.preserveRightClick = function($event){ $event.stopPropagation(); $event.preventDefault(); $scope.iscontextMenus = false; electron调用后返回的回调是一个文件的路径; const saveFilePath = remote.dialog.showSaveDialog(remote.getCurrentWindow(), {defaultPath:items.file_name} ); var fileReadStream = fs.createReadStream(items.file_path); var fileWriteStream = fs.createWriteStream(saveFilePath); fileReadStream.pipe(fileWriteStream); fileWriteStream.on('close',function(){ console.log('copy over'); }); }
electron框架提供的应用;const remote = require('electron').remote;remote.dialog.showSaveDialog(remote.getCurrentWindow(), {defaultPath:"abc.txt"});node.js fs模块文件的读入和写出var fs = require('fs'); var fileReadStream = fs.createReadStream('./myjpg.jpg'); var fileWriteStream = fs.createWriteStream('./new_myjpg.jpg'); fileReadStream.pipe(fileWriteStream); fileWriteStream.on('close',function(){ console.log('copy over'); });
上下文contenxmenu属性的应用; id="supermenu"