在电子中保存Lokijs DB

时间:2016-10-21 11:41:32

标签: electron lokijs asar


从“main.js”电子内部有一些方法可以将文件保存在asar之外? 我正在用这个命令来指出离开只写区域的方法,但是我不能这样做 路径在 #import "ViewController.h" @interface ViewController () { BOOL animating; CGRect aimFrame; } @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; animating = YES; //To set if we are showing the alert or not aimFrame = [[UIApplication sharedApplication] statusBarFrame]; [self setNeedsStatusBarAppearanceUpdate]; } - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; UIView *notificationView = [[UIView alloc] init]; [notificationView setFrame:aimFrame]; [notificationView setBackgroundColor:[UIColor redColor]]; [self.view addSubview:notificationView]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [notificationView removeFromSuperview]; animating = NO; [self setNeedsStatusBarAppearanceUpdate]; }); } - (BOOL)prefersStatusBarHidden { // Toggle based upon if we are showing the alert if (animating) { return YES; } else { return NO; } } @end 内部并且即使没有电子封装也可以工作。

/my-project/resources/

1 个答案:

答案 0 :(得分:1)

尝试在应用程序安装目录中编写文件是个坏主意,通常用户无权这样做。相反,您应该将文件写入app.getPath('userData')返回的位置。