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: {