Deluze / electron-vue-template

Simple Vue3 + Electron starter template in TypeScript, including ViteJS and Electron Builder
MIT License
579 stars 108 forks source link

tray icon path #41

Closed xiezhengyun closed 1 year ago

xiezhengyun commented 1 year ago

tray icon path

The path of the pallet cannot be found after packaging

image

in createWindow function

image

How should I fill in the path

Thank you.

Deluze commented 1 year ago

Did you change any Electron Builder config?

By default every file in /src/main/static is packaged in app.getAppPath() + '/static/...'.

If not, unpack the app.asar file in dist. Do you see a static directory there?

xiezhengyun commented 1 year ago

I change Electron Build config, But just add main/utils && nisi && publish

{
    "appId": "pacsclient",
    "directories": {
        "output": "dist"
    },
    "nsis": {
        "oneClick": false,
        "perMachine": false,
        "allowToChangeInstallationDirectory": true,
        "shortcutName": "pacsclient",
        "deleteAppDataOnUninstall": true,
        "include": "scripts/urlProtoco.nsh"
    },
    "win": {
        "target": "nsis"
    },
    "linux": {
        "target": ["snap"]
    },
    "publish": [{
        "provider": "generic",
        "url": "http://127.0.0.1:9005/"
    }],
    "files": [
        "build/main/**/*",
        {
            "from": "build/renderer",
            "to": "renderer",
            "filter": ["**/*"]
        },
        {
            "from": "src/main/static",
            "to": "static",
            "filter": ["**/*"]
        },
        {
            "from": "src/main/utils",
            "to": "utils",
            "filter": ["**/*"]
        },
        "!**/node_modules/*/{CHANGELOG.md,README.md,README,readme.md,readme}",
        "!**/node_modules/*/{test,__tests__,tests,powered-test,example,examples}",
        "!**/node_modules/*.d.ts",
        "!**/node_modules/.bin",
        "!src",
        "!config",
        "!README.md",
        "!scripts",
        "!build/renderer",
        "!dist"
    ]
}

image

This is the result of packaging

'main/static/appTray' is not in result

now i add 'renderer/public/trayIcon.png', This in 'build/renderer/trayIcon.png'

so:

image

this work


I want to make some suggestions

  1. checkUpdate
  2. Distinguish between production environment and test environment when packaging
Deluze commented 1 year ago

The static directory is only copied to the build directory when the dev-server.js script is ran (npm run dev). When the app is being packaged, the static directory is directly copied over from src/main/static.

In both production and development, static files are always available at app.getAppPath() + '/static/myFile.txt'.

If you unpack the app.asar file, the structure should look something like this:

image

I can't immediately tell what's causing the issue you're facing. Do you have a repo with minimal reproduction?

xiezhengyun commented 1 year ago

Thank you very much for your patience

This is my problem. I opened the app.asar file as you said, and then changed the path. It's successful

But this seems to be the same as my previous writing

But now it's all right😂

image

reproduction

https://github.com/xiezhengyun/electron-vue-template

Deluze commented 1 year ago

But now it's all right😂

Are you implying it's working as intended?

I packaged the app you sent me, the tray icon appears on both dev & packaged builds

xiezhengyun commented 1 year ago

Yes, no problem now