* fix(Markdown): eliminate hydration error from image `<div>` nested in `<p>` Signed-off-by: Chan Lee <Leetimemp@gmail.com> * feat: add support for reading local files in binary format Signed-off-by: Chan Lee <Leetimemp@gmail.com> * refactor(ImageViewer): Consolidate image rendering for unified display and context menu Signed-off-by: Chan Lee <Leetimemp@gmail.com> --------- Signed-off-by: Chan Lee <Leetimemp@gmail.com>
10 lines
350 B
TypeScript
10 lines
350 B
TypeScript
import fs from 'fs/promises'
|
|
|
|
export default class FileService {
|
|
public static async readFile(_: Electron.IpcMainInvokeEvent, pathOrUrl: string, encoding?: BufferEncoding) {
|
|
const path = pathOrUrl.startsWith('file://') ? new URL(pathOrUrl) : pathOrUrl
|
|
if (encoding) return fs.readFile(path, { encoding })
|
|
return fs.readFile(path)
|
|
}
|
|
}
|