mirror of
https://github.com/earthjasonlin/zzz-signal-search-export.git
synced 2024-11-23 05:40:21 +08:00
feat: save data only in the current program directory
This commit is contained in:
parent
8ff629b655
commit
e307d21bb2
@ -1,4 +1,4 @@
|
|||||||
const { readJSON, saveJSON, decipherAes, cipherAes, detectLocale, userDataPath, globalUserDataPath } = require('./utils')
|
const { readJSON, saveJSON, decipherAes, cipherAes, detectLocale, userDataPath } = require('./utils')
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
urls: [],
|
urls: [],
|
||||||
@ -14,9 +14,7 @@ const config = {
|
|||||||
|
|
||||||
const getLocalConfig = async () => {
|
const getLocalConfig = async () => {
|
||||||
let localConfig = await readJSON(userDataPath, 'config.json')
|
let localConfig = await readJSON(userDataPath, 'config.json')
|
||||||
if (!localConfig) {
|
|
||||||
localConfig = await readJSON(globalUserDataPath, 'config.json')
|
|
||||||
}
|
|
||||||
if (!localConfig) return
|
if (!localConfig) return
|
||||||
const configTemp = {}
|
const configTemp = {}
|
||||||
for (let key in localConfig) {
|
for (let key in localConfig) {
|
||||||
|
@ -3,7 +3,7 @@ const util = require('util')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const { URL } = require('url')
|
const { URL } = require('url')
|
||||||
const { app, ipcMain, shell } = require('electron')
|
const { app, ipcMain, shell } = require('electron')
|
||||||
const { sleep, request, sendMsg, readJSON, saveJSON, detectLocale, getCacheText, userDataPath, userPath, localIp, langMap, globalUserDataPath } = require('./utils')
|
const { sleep, request, sendMsg, readJSON, saveJSON, detectLocale, getCacheText, userDataPath, userPath, localIp, langMap } = require('./utils')
|
||||||
const config = require('./config')
|
const config = require('./config')
|
||||||
const i18n = require('./i18n')
|
const i18n = require('./i18n')
|
||||||
const { enableProxy, disableProxy } = require('./module/system-proxy')
|
const { enableProxy, disableProxy } = require('./module/system-proxy')
|
||||||
@ -42,10 +42,8 @@ const findDataFiles = async (dataPath, fileMap) => {
|
|||||||
|
|
||||||
const collectDataFiles = async () => {
|
const collectDataFiles = async () => {
|
||||||
await fs.ensureDir(userDataPath)
|
await fs.ensureDir(userDataPath)
|
||||||
await fs.ensureDir(globalUserDataPath)
|
|
||||||
const fileMap = new Map()
|
const fileMap = new Map()
|
||||||
await findDataFiles(userDataPath, fileMap)
|
await findDataFiles(userDataPath, fileMap)
|
||||||
await findDataFiles(globalUserDataPath, fileMap)
|
|
||||||
return fileMap
|
return fileMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ const isDev = !app.isPackaged
|
|||||||
const userPath = app.getPath('userData')
|
const userPath = app.getPath('userData')
|
||||||
const appRoot = isDev ? path.resolve(__dirname, '..', '..') : path.resolve(app.getAppPath(), '..', '..')
|
const appRoot = isDev ? path.resolve(__dirname, '..', '..') : path.resolve(app.getAppPath(), '..', '..')
|
||||||
const userDataPath = path.resolve(appRoot, 'userData')
|
const userDataPath = path.resolve(appRoot, 'userData')
|
||||||
const globalUserDataPath = path.resolve(userPath, 'userData')
|
// const globalUserDataPath = path.resolve(userPath, 'userData')
|
||||||
|
|
||||||
let win = null
|
let win = null
|
||||||
const initWindow = () => {
|
const initWindow = () => {
|
||||||
@ -147,9 +147,6 @@ const detectLocale = (value) => {
|
|||||||
const saveJSON = async (name, data) => {
|
const saveJSON = async (name, data) => {
|
||||||
try {
|
try {
|
||||||
await fs.outputJSON(path.join(userDataPath, name), data)
|
await fs.outputJSON(path.join(userDataPath, name), data)
|
||||||
if (!isDev) {
|
|
||||||
await fs.outputJSON(path.join(globalUserDataPath, name), data)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendMsg(e, 'ERROR')
|
sendMsg(e, 'ERROR')
|
||||||
await sleep(3)
|
await sleep(3)
|
||||||
@ -221,5 +218,5 @@ async function getCacheText(gamePath) {
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
sleep, request, hash, cipherAes, decipherAes, saveLog, getCacheText,
|
sleep, request, hash, cipherAes, decipherAes, saveLog, getCacheText,
|
||||||
sendMsg, readJSON, saveJSON, initWindow, getWin, localIp, userPath, detectLocale, langMap,
|
sendMsg, readJSON, saveJSON, initWindow, getWin, localIp, userPath, detectLocale, langMap,
|
||||||
appRoot, userDataPath, globalUserDataPath
|
appRoot, userDataPath
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user