本文整理匯總了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);
});