-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f52348
commit 9216470
Showing
9 changed files
with
122 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ npm-debug.log | |
npm-debug.log.* | ||
thumbs.db | ||
!.gitkeep | ||
marisa-win32-x64 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"name": "marisa", | ||
"productName": "marisa", | ||
"version": "0.0.0", | ||
"version": "0.0.001", | ||
"author": "gutrse3321 <[email protected]>", | ||
"description": "An electron-vue project", | ||
"description": "大家的老朋友,莎莎", | ||
"license": "", | ||
"main": "./dist/electron/main.js", | ||
"scripts": { | ||
|
@@ -24,6 +24,8 @@ | |
}, | ||
"dependencies": { | ||
"axios": "^0.16.1", | ||
"fs-extra": "^6.0.1", | ||
"lowdb": "^1.0.0", | ||
"vue": "^2.3.3", | ||
"vue-electron": "^1.0.6", | ||
"vue-router": "^2.5.3", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Datastore from 'lowdb' | ||
import FileSync from 'lowdb/adapters/FileSync' | ||
import path from 'path' | ||
import fs from 'fs-extra' | ||
import { app, remote } from 'electron' | ||
|
||
// 根据process.type判断在那个模式使用 | ||
const APP = process.type === 'renderer' ? remote.app : app | ||
|
||
// 获取electron应用的用户目录 | ||
const STORE_PATH = APP.getPath('userData') | ||
|
||
if (process.type !== 'renderer') { | ||
if (!fs.pathExistsSync(STORE_PATH)) { | ||
fs.mkdirpSync(STORE_PATH) | ||
} | ||
} | ||
|
||
// 初始化lowdb读取的json文件名以及存储路径 | ||
const adapter = new FileSync(path.join(STORE_PATH, '/data.json')) | ||
|
||
const db = Datastore(adapter) | ||
|
||
// | ||
if (!db.has('memorise').value()) { | ||
db.set('memorise', []).write() | ||
} | ||
|
||
export default db |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters