systemPreferences - systemPreferences.fileAccessPersist(paths)

概述

对传入的多个文件或目录持久化授权。

基本信息

属性
模块 systemPreferences
类型 Method
鸿蒙支持 支持

OHOS 依赖与基本表现

属性
系统权限依赖 无需申请,module.json5中已经包含所需权限
添加JIT权限 支持
坚盾模式 支持

使用方式差异

属性
使用方式差异 存在差异
差异说明 鸿蒙平台独有接口,单独提供使用Demo,详见Demo

Demo

const { app, BrowserWindow, systemPreferences } = require('electron');
const path = require('path');

function createWindow() {
  const win = new BrowserWindow({
    width: 1000,
    height: 800,
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false
    }
  });
  // paths string[] - 需要持久化授权的文件或目录路径。
  // 对传入的多个文件或目录持久化授权。
  console.log('electron call systemPreferences.fileAccessPersist() result is:',systemPreferences.fileAccessPersist('/your/path'));
}

app.whenReady().then(createWindow);