From 56acfb275b31fb549764174f4470f6b5a31b4e55 Mon Sep 17 00:00:00 2001 From: Jasery Date: Wed, 29 Oct 2025 18:58:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=8C=E4=BC=98=E5=8C=96=20Git=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=92=8C=E6=96=87=E4=BB=B6=E5=A4=B9=E9=80=89=E6=8B=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=EF=BC=8C=E8=B0=83=E6=95=B4=E6=A8=A1=E6=9D=BF=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 28 ++--- buildAssets/builder/config.js | 24 ++-- package.json | 4 +- src/main/IPCs.ts | 46 +++++-- src/preload/index.ts | 1 + .../components/layout/HeaderLayout.vue | 4 +- src/renderer/screens/CreateTemplateScreen.vue | 113 +++++++----------- src/renderer/screens/MainScreen.vue | 10 +- src/renderer/screens/TemplateListScreen.vue | 12 +- 9 files changed, 120 insertions(+), 122 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 58101cf..e489447 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,17 +24,17 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - + - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - + - name: Configure Git to use HTTPS instead of SSH run: | git config --global url."https://github.com/".insteadOf git@github.com: git config --global url."https://".insteadOf git:// - + - name: Setup pnpm uses: pnpm/action-setup@v4 with: @@ -42,12 +42,12 @@ jobs: run_install: | - recursive: true args: [--frozen-lockfile=false] - + - name: Get pnpm store directory id: pnpm-cache run: | echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT - + - name: Setup pnpm cache uses: actions/cache@v4 with: @@ -55,39 +55,39 @@ jobs: key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}-pnpm-store- - + - name: Install dependencies run: pnpm install --no-frozen-lockfile env: NPM_CONFIG_LEGACY_PEER_DEPS: true - + - name: Setup Git user run: | git config --global user.name 'github-actions[bot]' git config --global user.email 'github-actions[bot]@users.noreply.github.com' - + - name: Bump version and generate changelog run: | # 根据 commit 信息自动更新版本和生成 changelog pnpm release - + # 获取新版本号 VERSION=$(node -p "require('./package.json').version") echo "VERSION=$VERSION" >> $GITHUB_ENV - + - name: Push changes run: | git push origin main git push origin v${{ env.VERSION }} - + - name: Build for all platforms - run: pnpm build:all + run: pnpm build:win env: # 在 macOS 上禁用代码签名 CSC_IDENTITY_AUTO_DISCOVERY: false # GitHub token 用于发布 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - + - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: @@ -99,4 +99,4 @@ jobs: files: | release/${{ env.VERSION }}/* env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/buildAssets/builder/config.js b/buildAssets/builder/config.js index 7f38cb8..a88819f 100644 --- a/buildAssets/builder/config.js +++ b/buildAssets/builder/config.js @@ -56,18 +56,18 @@ const baseConfig = { win: { icon: 'buildAssets/icons/icon.ico', target: [ - { - target: 'appx', - arch: 'x64' - }, - { - target: 'zip', - arch: 'x64' - }, - { - target: 'portable', - arch: 'x64' - }, + // { + // target: 'appx', + // arch: 'x64' + // }, + // { + // target: 'zip', + // arch: 'x64' + // }, + // { + // target: 'portable', + // arch: 'x64' + // }, { target: 'nsis', arch: 'x64' diff --git a/package.json b/package.json index 1d4859b..a9d7b72 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "vutron", - "appId": "com.vutron.vutron", + "name": "gdt-tool", + "appId": "com.tool.gdt", "version": "0.0.2", "description": "Quick Start Templates for Vite + Vue 3 + Electron", "homepage": "https://vutron.cdget.com", diff --git a/src/main/IPCs.ts b/src/main/IPCs.ts index d72290f..7cc84c3 100644 --- a/src/main/IPCs.ts +++ b/src/main/IPCs.ts @@ -57,13 +57,37 @@ export default class IPCs { if (!dialogResult.canceled && dialogResult.filePaths.length > 0) { return { canceled: false, - filePath: dialogResult.filePaths[0] + filePath: dialogResult.filePaths[0], + isDirectory: true } } return { canceled: true } }) + // Select file or directory + ipcMain.handle('msgSelectFileOrFolder', async () => { + const dialogResult = await dialog.showOpenDialog({ + properties: ['openFile', 'openDirectory'] + }) + + if (!dialogResult.canceled && dialogResult.filePaths.length > 0) { + const filePath = dialogResult.filePaths[0]; + const fs = require('fs'); + const isDirectory = fs.statSync(filePath).isDirectory(); + + return { + canceled: false, + filePath: filePath, + isDirectory: isDirectory + } + } + + return { canceled: true } + }) + + + // Find all files in a folder recursively ipcMain.handle( 'msgFindFilesInFolder', @@ -71,16 +95,16 @@ export default class IPCs { try { const { readdirSync, statSync } = require('fs') const { join } = require('path') - + const foundFiles: string[] = [] - + const searchFiles = (dir: string) => { const items = readdirSync(dir) - + for (const item of items) { const fullPath = join(dir, item) const stats = statSync(fullPath) - + if (stats.isDirectory()) { // Recursively search in subdirectories searchFiles(fullPath) @@ -90,9 +114,9 @@ export default class IPCs { } } } - + searchFiles(folderPath) - + return foundFiles } catch (error) { console.error('Error finding files in folder:', error) @@ -188,21 +212,21 @@ export default class IPCs { } return allNodes; }; - + // Collect all nodes from the tree structure if (template.treeStructure && template.treeStructure.length > 0) { const allNodes = collectAllNodes(template.treeStructure); - + // Process all nodes, making sure directories are created before files for (const node of allNodes) { const nodePath = join(baseDirPath, node.path); - + if (node.type === 'directory') { ensureDirSync(nodePath); } else if (node.type === 'file') { const fileDir = dirname(nodePath); ensureDirSync(fileDir); - + if (node.sourceFilePath) { // Copy from source file const sourceContent = readFileSync(node.sourceFilePath); diff --git a/src/preload/index.ts b/src/preload/index.ts index b707727..73bdeab 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -11,6 +11,7 @@ const mainAvailChannels: string[] = [ 'msgOpenExternalLink', 'msgOpenFile', 'msgSelectDirectory', + 'msgSelectFileOrFolder', 'msgLoadData', 'msgSaveData', 'msgExecuteTemplate', diff --git a/src/renderer/components/layout/HeaderLayout.vue b/src/renderer/components/layout/HeaderLayout.vue index 7118a20..0df88a9 100644 --- a/src/renderer/components/layout/HeaderLayout.vue +++ b/src/renderer/components/layout/HeaderLayout.vue @@ -36,7 +36,9 @@ const headerMenus: {