package.json

{
    "name": "",
    "version": "1.0.0",
    "description": "",
    "author": "",
    "main": "main.js",
    "scripts": {
        "start": "electron ."
    },
    "repository": "",
    "keywords": [],
    "license": "",
    "devDependencies": {
        "electron": "^17.0.1",
        "electron-builder": "^22.14.13"
    },
    "build": {
        "productName": "",
        "appId": "",
        "copyright": "",
        "compression": "maximum",
        "directories": {
            "output": "build"
        },
        "asar": false,
        "win": {
            "icon": "logo/256.ico",
            "artifactName": "${productName}_setup_${version}.${ext}"
        },
        "mac": {
            "icon": "logo/512.png",
            "artifactName": "${productName}_setup_${version}.${ext}"
        },
        "linux": {
            "icon": "logo/256.ico",
            "artifactName": "${productName}_setup_${version}.${ext}"
        },
        "nsis": {
            "oneClick": false,
            "perMachine": true,
            "allowElevation": true,
            "allowToChangeInstallationDirectory": true,
            "installerIcon": "logo/256.ico",
            "uninstallerIcon": "logo/256.ico",
            "installerHeaderIcon": "logo/256.ico",
            "createDesktopShortcut": true,
            "createStartMenuShortcut": true,
            "shortcutName": ""
        }
    }
}

全局安装 electron-builder

npm install electron-builder -g

打包程序

electron-builder --ia32
# ia32 / x64

读取到的文件默认是根据修改时间排序的,如果要根据文件名排序可以使用

fileInfos.OrderBy(f => f.Name);

得到的顺序为:1、10、2、3 ... 9,使用以下方法即可解决

DirectoryInfo directoryInfo=new DirectoryInfo(folderPath);
FileInfo[] fileInfos= directoryInfo.GetFiles();

List<string> files=new List<string>();
Array.Sort(fileInfos, (x1, x2) => int.Parse(Regex.Match(x1.Name, @"\d+").Value).CompareTo(int.Parse(Regex.Match(x2.Name, @"\d+").Value)));
foreach (FileInfo file in fileInfos)
{
    files.Add(file.FullName);
}

原文链接:https://www.jianshu.com/p/d69461e7cbd7

密码过期可以使用命令行登录

mysqld -uroot -p***

此时如果执行其他命令会报错

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

执行以下命令重置密码即可

alter user user() identified by "123456";

如果要设置密码永不过期可以执行

set global default_password_lifetime = 0;

# 32位
electron-packager . 'ProjectName' --platform=win32 --arch=ia32 --icon=logo.ico --out=./OutputPath --asar --app-version=1.0.0

# 64位
electron-packager . 'ProjectName' --platform=win32 --arch=x64 --icon=logo.ico --out=./OutputPath --asar --app-version=1.0.0