Skip to content

Commit

Permalink
chore:添加构建命令
Browse files Browse the repository at this point in the history
  • Loading branch information
bibibala committed Oct 8, 2024
1 parent da914b3 commit aba909b
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 34 deletions.
66 changes: 35 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,60 @@ name: Build and Release Electron App

on:
push:
branches: [ main ]
tags:
- 'v*'

jobs:
release:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, windows-latest]
arch: [x64, arm64]
exclude:
- os: windows-latest
arch: arm64
include:
- os: windows-latest
arch: ia32
os: [windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- name: Check out Git repository
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v2
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
node-version: 20

- name: Install dependencies
run: npm install
run: |
npm install
- name: Build Electron app
- name: Build and release Windows x64
if: matrix.os == 'windows-latest'
env:
GH_TOKEN: ${{ secrets.PUBLIC_RELEASE }}
run: npm run build -- --${{ matrix.arch }}
GITHUB_TOKEN: ${{ secrets.PUBLIC_RELEASE }}
run: npm run build:winx64

- name: Create Release
id: create_release
uses: actions/create-release@v1
- name: Build and release Windows ia32
if: matrix.os == 'windows-latest'
env:
GITHUB_TOKEN: ${{ secrets.PUBLIC_RELEASE }}
with:
tag_name: v${{ github.run_number }}-${{ github.run_id }} # Modified tag name
release_name: Release v${{ github.run_number }}
draft: false
prerelease: false
run: npm run build:winia32

- name: Build and release macOS Intel
if: matrix.os == 'macos-latest'
env:
GITHUB_TOKEN: ${{ secrets.PUBLIC_RELEASE }}
run: npm run build:intel

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
- name: Build and release macOS ARM
if: matrix.os == 'macos-latest'
env:
GITHUB_TOKEN: ${{ secrets.PUBLIC_RELEASE }}
run: npm run build:arm

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./release/your-app-name*
asset_name: your-app-name-${{ matrix.os }}-${{ matrix.arch }}
asset_content_type: application/octet-stream
name: ${{ matrix.os }}-builds
files: |
release/**/*.exe
release/**/*.dmg
release/**/*.snap
if-no-files-found: error
40 changes: 40 additions & 0 deletions electron/koffi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// TODO user32.dll 只能在windows下运行
// import koffi from 'koffi'
//
// // Load the shared library
// const lib = koffi.load('user32.dll');
//
// // Declare constants
// const MB_OK = 0x0;
// const MB_YESNO = 0x4;
// const MB_ICONQUESTION = 0x20;
// const MB_ICONINFORMATION = 0x40;
//
// // Find functions
// const MessageBoxA = lib.func('__stdcall', 'MessageBoxA', 'int', [
// 'void *',
// 'str',
// 'str',
// 'uint',
// ]);
// const MessageBoxW = lib.func('__stdcall', 'MessageBoxW', 'int', [
// 'void *',
// 'str16',
// 'str16',
// 'uint',
// ]);
//
// // 封装打开消息框的函数
// function openMessageBoxA(message, title) {
// return MessageBoxA(null, message, title, MB_YESNO | MB_ICONQUESTION);
// }
//
// function openMessageBoxW(message, title) {
// return MessageBoxW(null, message, title, MB_ICONINFORMATION);
// }
//
// // 导出封装的函数
// module.exports = {
// openMessageBoxA,
// openMessageBoxW,
// };
5 changes: 5 additions & 0 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from "node:path";
import os from "node:os";
import { createRequire } from "node:module";
import { fileURLToPath } from "node:url";
// import { get } from "../koffi";
import { app, BrowserWindow, shell, ipcMain, dialog } from "electron";

const require = createRequire(import.meta.url);
Expand Down Expand Up @@ -93,3 +94,7 @@ ipcMain.on("select", async (event, args = {}) => {
event.reply("selectOver", { args, response });
}
});

ipcMain.handle("show-message-box", async (event, type) => {
//
});
2 changes: 2 additions & 0 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ contextBridge.exposeInMainWorld("ipcRenderer", {
console.log("file select cancel");
}
},
showMessageBox: (type: string) =>
ipcRenderer.invoke("show-message-box", type),
});
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,29 @@
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build && electron-builder",
"build:winx64": "vue-tsc --noEmit && vite build && electron-builder --win --x64",
"build:winia32": "vue-tsc --noEmit && vite build && electron-builder --win --ia32",
"build:intel": "vue-tsc --noEmit && vite build && electron-builder --mac --x64",
"build:arm": "vue-tsc --noEmit && vite build && electron-builder --mac --arm64",
"preview": "vite preview",
"format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore"
},
"dependencies": {
"koffi": "^2.9.1"
},
"devDependencies": {
"@mdi/font": "^7.4.47",
"@vitejs/plugin-vue": "^5.0.4",
"electron": "32.1.2",
"electron-builder": "^25.1.7",
"koffi": "^2.9.1",
"pinia": "^2.2.4",
"prettier": "^3.3.3",
"typescript": "^5.4.2",
"vite": "^5.1.5",
"vite-plugin-electron": "^0.28.4",
"vite-plugin-electron-renderer": "^0.14.5",
"vite-plugin-vuetify": "^2.0.4",
"vue": "^3.4.21",
"vue": "^3.5.11",
"vue-router": "^4.4.5",
"vue-tsc": "^2.0.6",
"vuetify": "^3.7.2",
Expand Down
5 changes: 5 additions & 0 deletions src/pages/Home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ function selectFiles(source: string) {
});
}
function open(type) {
window.ipcRenderer.showMessageBox(type);
}
const headers = [
{ title: "KEY", value: "name" },
{ title: "VALUE", value: "text" },
Expand All @@ -35,6 +39,7 @@ const headers = [
>
<template #append>
<v-btn @click="selectFiles('')">选择目录</v-btn>
<v-btn @click="open('A')">弹窗</v-btn>
</template>
</v-text-field>
</template>
Expand Down
1 change: 1 addition & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare global {
select: (args: any) => void;
selectOver: (args: any) => void;
readDir: (pathRoot: string) => string[];
showMessageBox: (type: string) => void;
};
}
}

0 comments on commit aba909b

Please sign in to comment.