mirror of
https://github.com/heyman/heynote.git
synced 2025-06-28 13:31:38 +02:00
Fix broken sub directories on Windows
Don't use hard coded path separator 🤦
This commit is contained in:
parent
da523d70e7
commit
ee06b01b60
@ -1,4 +1,5 @@
|
|||||||
const { contextBridge } = require('electron')
|
const { contextBridge } = require('electron')
|
||||||
|
import { sep } from "path"
|
||||||
import themeMode from "./theme-mode"
|
import themeMode from "./theme-mode"
|
||||||
import { isMac, isWindows, isLinux, isDev } from "../detect-platform"
|
import { isMac, isWindows, isLinux, isDev } from "../detect-platform"
|
||||||
import { ipcRenderer } from "electron"
|
import { ipcRenderer } from "electron"
|
||||||
@ -116,6 +117,8 @@ contextBridge.exposeInMainWorld("heynote", {
|
|||||||
setLibraryPathChangeCallback(callback) {
|
setLibraryPathChangeCallback(callback) {
|
||||||
ipcRenderer.on("library:pathChanged", callback)
|
ipcRenderer.on("library:pathChanged", callback)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pathSeparator: sep,
|
||||||
},
|
},
|
||||||
|
|
||||||
settings: CONFIG.get("settings"),
|
settings: CONFIG.get("settings"),
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
import { SCRATCH_FILE_NAME } from "../common/constants"
|
import { SCRATCH_FILE_NAME } from "../common/constants"
|
||||||
import { useHeynoteStore } from "../stores/heynote-store"
|
import { useHeynoteStore } from "../stores/heynote-store"
|
||||||
|
|
||||||
|
const pathSep = window.heynote.buffer.pathSeparator
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
headline: String,
|
headline: String,
|
||||||
@ -47,8 +49,8 @@
|
|||||||
return sortScore
|
return sortScore
|
||||||
} else {
|
} else {
|
||||||
// then notes in root
|
// then notes in root
|
||||||
const aIsRoot = a.path.indexOf("/") === -1
|
const aIsRoot = a.path.indexOf(pathSep) === -1
|
||||||
const bIsRoot = b.path.indexOf("/") === -1
|
const bIsRoot = b.path.indexOf(pathSep) === -1
|
||||||
if (aIsRoot && !bIsRoot) {
|
if (aIsRoot && !bIsRoot) {
|
||||||
return -1
|
return -1
|
||||||
} else if (!aIsRoot && bIsRoot) {
|
} else if (!aIsRoot && bIsRoot) {
|
||||||
@ -105,7 +107,7 @@
|
|||||||
return {
|
return {
|
||||||
"path": path,
|
"path": path,
|
||||||
"name": metadata?.name || path,
|
"name": metadata?.name || path,
|
||||||
"folder": path.split("/").slice(0, -1).join("/"),
|
"folder": path.split(pathSep).slice(0, -1).join(pathSep),
|
||||||
"scratch": path === SCRATCH_FILE_NAME,
|
"scratch": path === SCRATCH_FILE_NAME,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
import FolderSelector from './folder-selector/FolderSelector.vue'
|
import FolderSelector from './folder-selector/FolderSelector.vue'
|
||||||
|
|
||||||
|
const pathSep = window.heynote.buffer.pathSeparator
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -42,7 +44,7 @@
|
|||||||
const getNodeFromList = (list, part) => list.find(node => node.name === part)
|
const getNodeFromList = (list, part) => list.find(node => node.name === part)
|
||||||
|
|
||||||
directories.forEach((path) => {
|
directories.forEach((path) => {
|
||||||
const parts = path.split("/")
|
const parts = path.split(pathSep)
|
||||||
let currentLevel = rootNode
|
let currentLevel = rootNode
|
||||||
let currentParts = []
|
let currentParts = []
|
||||||
parts.forEach(part => {
|
parts.forEach(part => {
|
||||||
@ -51,7 +53,7 @@
|
|||||||
if (node) {
|
if (node) {
|
||||||
currentLevel = node
|
currentLevel = node
|
||||||
} else {
|
} else {
|
||||||
const currentPath = currentParts.join("/")
|
const currentPath = currentParts.join(pathSep)
|
||||||
node = {
|
node = {
|
||||||
name: part,
|
name: part,
|
||||||
children: [],
|
children: [],
|
||||||
@ -78,7 +80,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
currentNoteDirectory() {
|
currentNoteDirectory() {
|
||||||
return this.currentBufferPath.split("/").slice(0, -1).join("/")
|
return this.currentBufferPath.split(pathSep).slice(0, -1).join(pathSep)
|
||||||
},
|
},
|
||||||
|
|
||||||
nameInputClass() {
|
nameInputClass() {
|
||||||
@ -132,7 +134,7 @@
|
|||||||
this.errors.name = true
|
this.errors.name = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const parentPathPrefix = this.parentPath === "" ? "" : this.parentPath + "/"
|
const parentPathPrefix = this.parentPath === "" ? "" : this.parentPath + pathSep
|
||||||
let path;
|
let path;
|
||||||
for (let i=0; i<1000; i++) {
|
for (let i=0; i<1000; i++) {
|
||||||
let filename = slug + ".txt"
|
let filename = slug + ".txt"
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
import FolderSelector from './folder-selector/FolderSelector.vue'
|
import FolderSelector from './folder-selector/FolderSelector.vue'
|
||||||
|
|
||||||
|
const pathSep = window.heynote.buffer.pathSeparator
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -47,7 +49,7 @@
|
|||||||
const getNodeFromList = (list, part) => list.find(node => node.name === part)
|
const getNodeFromList = (list, part) => list.find(node => node.name === part)
|
||||||
|
|
||||||
directories.forEach((path) => {
|
directories.forEach((path) => {
|
||||||
const parts = path.split("/")
|
const parts = path.split(pathSep)
|
||||||
let currentLevel = rootNode
|
let currentLevel = rootNode
|
||||||
let currentParts = []
|
let currentParts = []
|
||||||
parts.forEach(part => {
|
parts.forEach(part => {
|
||||||
@ -56,7 +58,7 @@
|
|||||||
if (node) {
|
if (node) {
|
||||||
currentLevel = node
|
currentLevel = node
|
||||||
} else {
|
} else {
|
||||||
const currentPath = currentParts.join("/")
|
const currentPath = currentParts.join(pathSep)
|
||||||
node = {
|
node = {
|
||||||
name: part,
|
name: part,
|
||||||
children: [],
|
children: [],
|
||||||
@ -80,7 +82,7 @@
|
|||||||
]),
|
]),
|
||||||
|
|
||||||
currentNoteDirectory() {
|
currentNoteDirectory() {
|
||||||
return this.currentBufferPath.split("/").slice(0, -1).join("/")
|
return this.currentBufferPath.split(pathSep).slice(0, -1).join(pathSep)
|
||||||
},
|
},
|
||||||
|
|
||||||
nameInputClass() {
|
nameInputClass() {
|
||||||
@ -140,7 +142,7 @@
|
|||||||
this.errors.name = true
|
this.errors.name = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const parentPathPrefix = this.parentPath === "" ? "" : this.parentPath + "/"
|
const parentPathPrefix = this.parentPath === "" ? "" : this.parentPath + pathSep
|
||||||
let path;
|
let path;
|
||||||
for (let i=0; i<1000; i++) {
|
for (let i=0; i<1000; i++) {
|
||||||
let filename = slug + ".txt"
|
let filename = slug + ".txt"
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
import FolderItem from "./FolderItem.vue"
|
import FolderItem from "./FolderItem.vue"
|
||||||
import NewFolderItem from "./NewFolderItem.vue"
|
import NewFolderItem from "./NewFolderItem.vue"
|
||||||
|
|
||||||
|
const pathSep = window.heynote.buffer.pathSeparator
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
directoryTree: Object,
|
directoryTree: Object,
|
||||||
@ -144,7 +146,7 @@
|
|||||||
node.createNewFolder = false
|
node.createNewFolder = false
|
||||||
node.children.unshift({
|
node.children.unshift({
|
||||||
name: name,
|
name: name,
|
||||||
path: parentPath === "" ? name : parentPath + "/" + name,
|
path: parentPath === "" ? name : parentPath + pathSep + name,
|
||||||
children: [],
|
children: [],
|
||||||
newFolder: true,
|
newFolder: true,
|
||||||
})
|
})
|
||||||
@ -163,7 +165,7 @@
|
|||||||
//console.log("Remove newly created folder:", path)
|
//console.log("Remove newly created folder:", path)
|
||||||
const node = this.getNode(path)
|
const node = this.getNode(path)
|
||||||
if (node.newFolder && path) {
|
if (node.newFolder && path) {
|
||||||
const parentPath = path.split("/").slice(0, -1).join("/")
|
const parentPath = path.split(pathSep).slice(0, -1).join(pathSep)
|
||||||
const parent = this.getNode(parentPath)
|
const parent = this.getNode(parentPath)
|
||||||
parent.children = parent.children.filter(child => child.path !== path)
|
parent.children = parent.children.filter(child => child.path !== path)
|
||||||
this.selected--
|
this.selected--
|
||||||
@ -173,7 +175,7 @@
|
|||||||
|
|
||||||
getNode(path) {
|
getNode(path) {
|
||||||
const getNodeFromList = (list, part) => list.find(node => node.name === part)
|
const getNodeFromList = (list, part) => list.find(node => node.name === part)
|
||||||
const parts = path.split("/")
|
const parts = path.split(pathSep)
|
||||||
let currentLevel = this.tree
|
let currentLevel = this.tree
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
const node = getNodeFromList(currentLevel.children, part)
|
const node = getNodeFromList(currentLevel.children, part)
|
||||||
|
@ -217,6 +217,8 @@ const Heynote = {
|
|||||||
removeOnChangeCallback(path, callback) {
|
removeOnChangeCallback(path, callback) {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
pathSeparator: "/",
|
||||||
},
|
},
|
||||||
|
|
||||||
mainProcess: {
|
mainProcess: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user