Skip to content

Commit

Permalink
update: windows compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
darakuneko committed Jan 23, 2023
1 parent 104cb22 commit f4514f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions command.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const command = {
mainWindow.webContents.send("streamLog", `Cannot POST ${u}`)
},
buildCompleted: () => buildCompleted,
buildCache: (homePath) => {
buildCache: (homePath, isWin) => {
const fwDir = `${homePath}/GPKFW/`
const d = []
const searchFiles = (dirPath) => {
Expand All @@ -114,16 +114,23 @@ const command = {
if (v.isDirectory()) {
const fp = path.join(dirPath, v.name)
f.push(searchFiles(fp))
if(fp.match(/\/keymaps\//)) d.push(fp)
if(isWin) {
if(fp.match(/\\keymaps\\/)) d.push(fp)
} else {
if(fp.match(/\/keymaps\//)) d.push(fp)
}
}
})
}
searchFiles(fwDir)
const keymapsDirs = d.flat().map(v => v.replace(fwDir, '').split("/keymaps/"))
const fd = fwDir.replace(/\//g, '\\')
const keymapsDirs = d.flat().map(v => isWin ? v.replace(fd, '').split("\\keymaps\\") :
v.replace(fwDir, '').split("/keymaps/"))
const kb = Array.from(new Set(keymapsDirs.map(v => v[0])))

return kb.map(k => {
return {
kb: k,
kb: k.replace(/\\/g, '/'),
km: keymapsDirs.filter(v => v[0] === k).map(v => v[1])
}
})
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ipcMain.handle('existSever', async () => await command.existSever())
ipcMain.handle('tags', async () => await command.tags())
ipcMain.handle('build', async (e, dat) => await command.build(dat, mainWindow))
ipcMain.handle('buildCompleted', () => command.buildCompleted())
ipcMain.handle('buildCache', () => command.buildCache(app.getPath('home')))
ipcMain.handle('buildCache', () => command.buildCache(app.getPath('home'), process.platform==='win32'))
ipcMain.handle('generateQMKFile', async (e, dat) => await command.generateQMKFile(dat))
ipcMain.handle('generateVialId', async () => await command.generateVialId())
ipcMain.handle('updateRepository', async (e, fw) => await command.updateRepository(fw, mainWindow))
Expand Down

0 comments on commit f4514f3

Please sign in to comment.