TagSpaces is an offline, open source, document manager with tagging support
fix: loading images in dev mode
Ilian Sapundshiev2ec107260d36
diff --git a/.erb/configs/webpack.config.renderer.dev.ts b/.erb/configs/webpack.config.renderer.dev.tsindex c2aa8ae60..8e3061948 100644--- a/.erb/configs/webpack.config.renderer.dev.ts+++ b/.erb/configs/webpack.config.renderer.dev.ts@@ -188,18 +188,27 @@ const configuration: webpack.Configuration = {},hot: true,headers: { 'Access-Control-Allow-Origin': '*' },- static: {- // directory: webpackPaths.distRendererPath, //'src/renderer/'),- publicPath: '/', //`http://localhost:${port}/renderer`, //'/', //'/src/renderer',//'/release/app/dist', //'/assets',- //staticOptions: {},- //serveIndex: true,- //watch: true- /*watch: {- aggregateTimeout: 300,- ignored: /node_modules/,- poll: 100,- },*/- },+ static: [+ {+ // directory: webpackPaths.distRendererPath, //'src/renderer/'),+ publicPath: '/', //`http://localhost:${port}/renderer`, //'/', //'/src/renderer',//'/release/app/dist', //'/assets',+ //staticOptions: {},+ //serveIndex: true,+ //watch: true+ /*watch: {+ aggregateTimeout: 300,+ ignored: /node_modules/,+ poll: 100,+ },*/+ },+ {+ // Serve release/app/node_modules at /modules so that extension paths+ // like 'modules/@tagspaces/extensions/text-viewer' resolve correctly+ // in dev mode (mirrors the '../../node_modules/' path used in prod).+ directory: webpackPaths.appNodeModulesPath,+ publicPath: '/modules',+ },+ ],historyApiFallback: {verbose: true,// disableDotRule: false,diff --git a/src/renderer/utils/CommonLocation.ts b/src/renderer/utils/CommonLocation.tsindex fe242424d..1158e9539 100644--- a/src/renderer/utils/CommonLocation.ts+++ b/src/renderer/utils/CommonLocation.ts@@ -181,11 +181,21 @@ export class CommonLocation implements TS.Location {rest = rest.replace(/^\/+/, '//');}- // 5) ensure a leading slash for non‑HTTP URLs on non‑Windows+ // 6) ensure a leading slash for non‑HTTP URLs on non‑Windowsif (!protocol && !AppConfig.isWin && !rest.startsWith('/')) {rest = '/' + rest;}+ // 7) In Electron, local paths without a protocol must use tsfile:// so they+ // load correctly regardless of the page origin (file:// in prod,+ // http://localhost in dev). Without this, bare paths like /Users/…+ // resolve to http://localhost:1212/Users/… in dev and fail.+ // Windows drive paths (C:/…) need a leading slash: tsfile:///C:/…+ if (!protocol && AppConfig.isElectron) {+ const localRest = rest.startsWith('/') ? rest : '/' + rest;+ return AppConfig.mediaProtocol + '://' + localRest;+ }+return protocol + rest;};@@ -214,9 +224,21 @@ export class CommonLocation implements TS.Location {if (!entry || !entry.path) {return undefined;}- return entry.isFile+ const rawPath = entry.isFile? getThumbFileLocationForFile(entry.path, this.getDirSeparator(), encoded): getThumbFileLocationForDirectory(entry.path, this.getDirSeparator());+ // In Electron, prefix bare paths with tsfile:// so they load correctly from+ // any page origin (file:// in prod, http://localhost in dev).+ if (rawPath && AppConfig.isElectron) {+ // Normalize backslashes (Windows) and ensure a leading slash so the+ // resulting URL is tsfile:///… on all platforms (tsfile:///C:/… on Win).+ const normalized = rawPath.replaceAll(this.getDirSeparator(), '/');+ const withLeadingSlash = normalized.startsWith('/')+ ? normalized+ : '/' + normalized;+ return AppConfig.mediaProtocol + '://' + withLeadingSlash;+ }+ return rawPath;};/*** @param path