Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add server.setVDocRoot api function #147

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

stxh
Copy link

@stxh stxh commented Jan 22, 2025

Description

Implements a virtual document root for local folders. When building an application to access local files, system functions can be used to read and display file content. However, if a file (such as an HTML document) references other local files (e.g., images in the same folder), these references typically fail to resolve (see #1291).

Changes proposed

Adds a setVDocRoot function to designate a local folder as the virtual document root for resources.

export function setVDocRoot(path: string): Promise<void> {
    return sendMessage('server.setVDocRoot', { path });
}

How to test it

Before opening a local HTML file containing referenced images, use setVDocRoot to set the virtual document root to the folder containing the HTML file and images. Verify that the images are displayed correctly.

Deploy notes

This change introduces a new function, setVDocRoot, which may require adjustments to existing build processes or deployment scripts if they rely on specific file paths. Ensure that the correct path is passed to setVDocRoot during application initialization. Consider adding documentation or examples demonstrating its usage.

You need update your neutralino.js too

Usage

      Neutralino.server
         .setVDocRoot(path)
         .then((resault) => {
            console.log("setVDocRoot:", resault)
        })
        .catch((error) => {
          console.error("setVDocRoot error:", error);
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant