GithubHelp home page GithubHelp logo

Comments (4)

amrbashir avatar amrbashir commented on June 14, 2024

There is no APIs to flash the tray icon.

Alternating between two images should work though, can you provide a minimal repro and information about your OS?

from tray-icon.

nongyehong avatar nongyehong commented on June 14, 2024
#[tauri::command]
pub fn tray_blink(
    app: AppHandle,
    state: tauri::State<TrayState>,
    is_run: bool,
    ms: Option<u64>,
    icon_path_1: Option<String>,
    icon_path_2: Option<String>,
) {

    match state.id.lock().as_deref_mut().map(|x| x.as_mut()) {
        Ok(Some(v)) => v.abort(),
        _ => (),
    }

    if !is_run {
        return;
    }

    *state.id.lock().unwrap() = Some(tokio::spawn(async move {
        let path1 = &icon_path_1.unwrap();
        let path2 = &icon_path_2.unwrap();
        let mut count = 0;

        loop {
            tokio::time::sleep(std::time::Duration::from_millis(ms.unwrap_or_else(|| 500))).await;
            count += 1;

            let path = if count % 2 == 0 {
                path2
            } else {
                path1
            };

            app
                .tray_handle()
                .set_icon(tauri::Icon::File(std::path::PathBuf::from(path)))
                .unwrap();
        }
    }));
    }

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.26080 X64
    ✔ WebView2: 122.0.2365.92
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.77.0 (aedd173a2 2024-03-17)
    ✔ cargo: 1.77.0 (3fe68eabf 2024-02-29)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.10.0
    - pnpm: 8.15.4
    - yarn: 1.22.21
    - npm: 10.2.3

[-] Packages
    - tauri [RUST]: 1.6.1
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.6
    - tao [RUST]: 0.16.5
    - @tauri-apps/api [NPM]: 1.5.3
    - @tauri-apps/cli [NPM]: 1.5.11

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:6130/
    - framework: Vue.js
    - bundler: Rollup

from tray-icon.

nongyehong avatar nongyehong commented on June 14, 2024
QQ2024326-173221-HD.mp4

an icon flashes, similar to wechat

from tray-icon.

amrbashir avatar amrbashir commented on June 14, 2024

I am not sure which icon is yours in the video you showed, but you should be able to simulate what wechat is doing by alternating between a transparent icon and your actual app icon.

I should also note that you're using tauri v1 and this crate is only used in v2.

from tray-icon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.