本文整理汇总了TypeScript中electron.shell.moveItemToTrash方法的典型用法代码示例。如果您正苦于以下问题:TypeScript shell.moveItemToTrash方法的具体用法?TypeScript shell.moveItemToTrash怎么用?TypeScript shell.moveItemToTrash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.shell
的用法示例。
在下文中一共展示了shell.moveItemToTrash方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: doDelete
protected async doDelete(filePath: string, opts: FileDeleteOptions): Promise<void> {
if (!opts.useTrash) {
return super.doDelete(filePath, opts);
}
const result = shell.moveItemToTrash(filePath);
if (!result) {
throw new Error(isWindows ? localize('binFailed', "Failed to move '{0}' to the recycle bin", basename(filePath)) : localize('trashFailed', "Failed to move '{0}' to the trash", basename(filePath)));
}
}
示例2: updateMenu
//.........这里部分代码省略.........
icon: path.join(__dirname, '..', 'static', 'Icon.png'),
text: 'Created by Sindre Sorhus'
})
);
}
const debugSubmenu: MenuItemConstructorOptions[] = [
{
label: 'Show Settings',
click() {
config.openInEditor();
}
},
{
label: 'Show App Data',
click() {
shell.openItem(app.getPath('userData'));
}
},
{
type: 'separator'
},
{
label: 'Delete Settings',
click() {
config.clear();
app.relaunch();
app.quit();
}
},
{
label: 'Delete App Data',
click() {
shell.moveItemToTrash(app.getPath('userData'));
app.relaunch();
app.quit();
}
}
];
const macosTemplate: MenuItemConstructorOptions[] = [
appMenu([
{
label: 'Caprine Preferences',
submenu: preferencesSubmenu
},
{
label: 'Messenger Preferences…',
accelerator: 'Command+,',
click() {
sendAction('show-preferences');
}
},
{
type: 'separator'
},
...switchItems
]),
{
// @ts-ignore Buggy Electron types
role: 'fileMenu',
submenu: [
newConversationItem,
{
type: 'separator'
},
示例3:
socket.on('shell-moveItemToTrash', (fullPath) => {
const success = shell.moveItemToTrash(fullPath);
socket.emit('shell-moveItemToTrashCompleted', success);
});