首页 > 解决方案 > smoothstate 阻止其他 javascript 运行(电子)

问题描述

基本上我有一个电子应用程序,我在加载按钮工作时添加了最小化/关闭按钮,但是在使用平滑状态切换页面后它们停止工作我找到了各种解决方案(github 常见问题解答,stackoverlow 等),但到目前为止没有一个工作

按钮 html

<div id="title-bar-btns">
    <button class="btn btn-outline" id="min-btn">—&lt;/button>
    <button class="btn btn-outline" id="close-btn">X</button>
</div>

main.js

        $(function() {
        'use strict';
        var $page = $('#main'),
            options = {
                debug: !0,
                prefetch: !0,
                cacheLength: 4,
                onStart: {
                    duration: 350,
                    render: function($container) {
                        $container.addClass('is-exiting');
                        smoothState.restartCSSAnimations()
                    }
                },
                onReady: {
                    duration: 0,
                    render: function($container, $newContent) {
                        $container.removeClass('is-exiting');
                        $container.html($newContent)
                        initfunction();
                    }
                },
                onAfter: function($container, $newContent) {
                    initfunction();
                }
            },
            smoothState = $page.smoothState(options).data('smoothState')
    });
    $(document).ready(function() {
        initfunction();
    });

    function initfunction() {
        (function() {
            const {
                BrowserWindow
            } = require('electron').remote

            function init() {
                document.getElementById("min-btn").addEventListener("click", (e) => {
                    var window = BrowserWindow.getFocusedWindow();
                    window.minimize()
                });
                document.getElementById("close-btn").addEventListener("click", (e) => {
                    var window = BrowserWindow.getFocusedWindow();
                    window.close()
                })
            };
            document.onreadystatechange = () => {
                if (document.readyState == "complete") {
                    init()
                }
            }
        })()
    }

标签: javascriptnode.jselectronsmoothstate.js

解决方案


推荐阅读