mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
electron: Fix asset path on forge build
This commit is contained in:
parent
d1404492a7
commit
e72eb5f27c
@ -15,7 +15,8 @@ module.exports = {
|
||||
...getExtraResourcesForPlatform(),
|
||||
|
||||
// Moved to resources (TriliumNext Notes.app/Contents/Resources on macOS)
|
||||
"translations/"
|
||||
"translations/",
|
||||
"node_modules/@highlightjs/cdn-assets/styles"
|
||||
],
|
||||
afterComplete: [(buildPath, _electronVersion, platform, _arch, callback) => {
|
||||
const extraResources = getExtraResourcesForPlatform();
|
||||
|
@ -7,6 +7,8 @@
|
||||
import fs from "fs";
|
||||
import themeNames from "./code_block_theme_names.json" with { type: "json" }
|
||||
import { t } from "i18next";
|
||||
import { join } from "path";
|
||||
import { getResourceDir } from "./utils.js";
|
||||
|
||||
/**
|
||||
* Represents a color scheme for the code block syntax highlight.
|
||||
@ -28,7 +30,7 @@ interface ColorTheme {
|
||||
* @returns the supported themes, grouped.
|
||||
*/
|
||||
export function listSyntaxHighlightingThemes() {
|
||||
const path = "node_modules/@highlightjs/cdn-assets/styles";
|
||||
const path = join(getResourceDir(), "styles");
|
||||
const systemThemes = readThemesFromFileSystem(path);
|
||||
|
||||
return {
|
||||
|
@ -2,10 +2,8 @@ import i18next from "i18next";
|
||||
import Backend from "i18next-fs-backend";
|
||||
import options from "./options.js";
|
||||
import sql_init from "./sql_init.js";
|
||||
import { fileURLToPath } from "url";
|
||||
import { dirname, join } from "path";
|
||||
import utils from "./utils.js";
|
||||
import env from "./env.js";
|
||||
import { join } from "path";
|
||||
import { getResourceDir } from "./utils.js";
|
||||
|
||||
export async function initializeTranslations() {
|
||||
const resourceDir = getResourceDir();
|
||||
@ -21,14 +19,6 @@ export async function initializeTranslations() {
|
||||
});
|
||||
}
|
||||
|
||||
function getResourceDir() {
|
||||
if (utils.isElectron() && !env.isDev()) {
|
||||
return process.resourcesPath;
|
||||
} else {
|
||||
return join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentLanguage() {
|
||||
let language;
|
||||
if (sql_init.isDbInitialized()) {
|
||||
|
@ -7,6 +7,9 @@ import escape from "escape-html";
|
||||
import sanitize from "sanitize-filename";
|
||||
import mimeTypes from "mime-types";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import env from "./env.js";
|
||||
import { dirname, join } from "path";
|
||||
|
||||
const randtoken = generator({source: 'crypto'});
|
||||
|
||||
@ -315,6 +318,20 @@ function isString(x: any) {
|
||||
return Object.prototype.toString.call(x) === "[object String]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the directory for resources. On Electron builds this corresponds to the `resources` subdirectory inside the distributable package.
|
||||
* On development builds, this simply refers to the root directory of the application.
|
||||
*
|
||||
* @returns the resource dir.
|
||||
*/
|
||||
export function getResourceDir() {
|
||||
if (isElectron() && !env.isDev()) {
|
||||
return process.resourcesPath;
|
||||
} else {
|
||||
return join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
randomSecureToken,
|
||||
randomString,
|
||||
|
Loading…
x
Reference in New Issue
Block a user