mirror of
https://gitee.com/viarotel-org/escrcpy.git
synced 2024-11-29 18:01:34 +08:00
perf: ♻️ Script and directory structure optimization
This commit is contained in:
parent
6ffefe5bb0
commit
68378efb51
11
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
11
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
name: 🐞 Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[Bug] the title of bug report"
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#### Describe the bug
|
10
.github/ISSUE_TEMPLATE/help_wanted.md
vendored
Normal file
10
.github/ISSUE_TEMPLATE/help_wanted.md
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
name: 🥺 Help wanted
|
||||
about: Confuse about the use of electron-vue-vite
|
||||
title: "[Help] the title of help wanted report"
|
||||
labels: help wanted
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#### Describe the problem you confuse
|
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -45,7 +45,9 @@
|
||||
"pair ${this.formData.host}:${this.formData.port} ${this.formData.pair}",
|
||||
"${item.decoder} & ${item.encoder}",
|
||||
" & ",
|
||||
"${key}=${value}"
|
||||
"${key}=${value}",
|
||||
"npm install",
|
||||
"npm run build"
|
||||
],
|
||||
"cSpell.words": [
|
||||
"bhsn"
|
||||
|
@ -14,7 +14,7 @@ import appStore from './helpers/store.js'
|
||||
|
||||
import { getLogoPath } from './configs/index.js'
|
||||
|
||||
import events from './events/index.js'
|
||||
import ipc from './ipc/index.js'
|
||||
|
||||
import control from '$control/electron/main.js'
|
||||
|
||||
@ -87,7 +87,7 @@ function createWindow() {
|
||||
|
||||
loadPage(mainWindow)
|
||||
|
||||
events(mainWindow)
|
||||
ipc(mainWindow)
|
||||
|
||||
control(mainWindow)
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
"build:win": "vite build && electron-builder --win",
|
||||
"build:mac": "vite build && electron-builder --mac",
|
||||
"build:linux": "vite build && electron-builder --linux",
|
||||
"preview": "vite preview",
|
||||
"svgo": "svgo --folder=src/icons/svgo --output=src/icons/svg --config=src/icons/svgo.config.js",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"prepare": "husky install"
|
||||
@ -57,6 +56,8 @@
|
||||
"postcss": "8.4.38",
|
||||
"postcss-nested": "6.0.1",
|
||||
"postcss-scss": "4.0.9",
|
||||
"rimraf": "^6.0.1",
|
||||
"simple-git": "^3.27.0",
|
||||
"unocss": "0.62.3",
|
||||
"unplugin-auto-import": "0.18.2",
|
||||
"unplugin-vue-components": "0.27.4",
|
||||
|
97
scripts/helpers/index.js
Normal file
97
scripts/helpers/index.js
Normal file
@ -0,0 +1,97 @@
|
||||
import simpleGit from 'simple-git'
|
||||
import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import os from 'node:os'
|
||||
import { exec } from 'node:child_process'
|
||||
import { promisify } from 'node:util'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
const execPromise = promisify(exec)
|
||||
|
||||
/**
|
||||
* 在临时目录中克隆GitHub仓库,安装依赖,构建项目,并将构建输出复制到指定目录。
|
||||
*
|
||||
* @param {Object} options - 函数的配置选项。
|
||||
* @param {string} options.repoUrl - 要克隆的GitHub仓库URL。
|
||||
* @param {string} options.buildOutputDir - 构建输出所在的目录(相对于项目根目录)。
|
||||
* @param {string} options.destinationDir - 构建输出应该被复制到的目录。
|
||||
* @param {string} [options.branch] - 要克隆的分支(默认为'main')。
|
||||
* @param {string} [options.installCommand] - 安装依赖的命令。
|
||||
* @param {string} [options.buildCommand] - 构建项目的命令。
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
* @example
|
||||
* gitResolve({
|
||||
* repoUrl: 'https://github.com/user/project.git',
|
||||
* buildOutputDir: 'dist',
|
||||
* destinationDir: './public',
|
||||
* branch: 'main',
|
||||
* installCommand: 'npm install',
|
||||
* buildCommand: 'npm run build'
|
||||
* });
|
||||
*/
|
||||
export async function gitResolve(options) {
|
||||
const {
|
||||
repoUrl,
|
||||
buildOutputDir,
|
||||
destinationDir,
|
||||
branch = 'main',
|
||||
installCommand = 'npm install',
|
||||
buildCommand = 'npm run build',
|
||||
} = options
|
||||
|
||||
const repoName = path.basename(repoUrl, path.extname(repoUrl))
|
||||
|
||||
let tempDir
|
||||
|
||||
try {
|
||||
// 创建临时目录
|
||||
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), `${repoName}-`))
|
||||
console.log(`创建临时目录: ${tempDir}`)
|
||||
|
||||
// 克隆仓库
|
||||
console.log(`正在克隆仓库: ${repoUrl}`)
|
||||
const git = simpleGit()
|
||||
await git.clone(repoUrl, tempDir, ['--depth', '1', '--branch', branch])
|
||||
|
||||
// 切换到临时目录
|
||||
process.chdir(tempDir)
|
||||
|
||||
// 安装依赖
|
||||
console.log('正在安装依赖...')
|
||||
await execPromise(installCommand)
|
||||
|
||||
// 构建项目
|
||||
console.log('正在构建项目...')
|
||||
await execPromise(buildCommand)
|
||||
|
||||
// 复制构建输出到目标目录
|
||||
const sourcePath = path.join(tempDir, buildOutputDir)
|
||||
const finallyDestinationDir = path.join(destinationDir, repoName)
|
||||
|
||||
console.log(
|
||||
`正在将构建输出从 ${sourcePath} 复制到 ${finallyDestinationDir}`,
|
||||
)
|
||||
await fs.cp(sourcePath, finallyDestinationDir, { recursive: true })
|
||||
|
||||
console.log('流程成功完成。')
|
||||
}
|
||||
catch (error) {
|
||||
console.error('发生错误:', error)
|
||||
throw error
|
||||
}
|
||||
finally {
|
||||
if (tempDir) {
|
||||
if (['win32'].includes(process.platform)) {
|
||||
console.log(
|
||||
`注意,在 Windows 中由于文件锁的原因 你需要手动清除缓存目录:\npnpm cleanup ${tempDir}`,
|
||||
)
|
||||
}
|
||||
else {
|
||||
fs.rm(tempDir).catch(e => console.log(e.message))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +1,42 @@
|
||||
<template>
|
||||
<div class="flex items-center space-x-2">
|
||||
<component
|
||||
:is="item.component || 'div'"
|
||||
v-for="(item, index) in actionModel"
|
||||
:key="index"
|
||||
class="flex-none"
|
||||
v-bind="{
|
||||
devices,
|
||||
...(item.command
|
||||
? {
|
||||
onClick: () => handleShell(item),
|
||||
}
|
||||
: {}),
|
||||
}"
|
||||
>
|
||||
<template #default="{ loading = false } = {}">
|
||||
<el-button
|
||||
plain
|
||||
:title="$t(item.tips || item.label)"
|
||||
:loading="loading"
|
||||
>
|
||||
<template #icon>
|
||||
<svg-icon
|
||||
v-if="item.svgIcon"
|
||||
:name="item.svgIcon"
|
||||
:class="item.iconClass"
|
||||
></svg-icon>
|
||||
<el-icon v-else-if="item.elIcon" :class="item.iconClass">
|
||||
<component :is="item.elIcon" />
|
||||
</el-icon>
|
||||
</template>
|
||||
{{ $t('common.batch') }}-{{ $t(item.label) }}
|
||||
</el-button>
|
||||
</template>
|
||||
</component>
|
||||
</div>
|
||||
<Scrollable>
|
||||
<div class="flex items-center space-x-2">
|
||||
<component
|
||||
:is="item.component || 'div'"
|
||||
v-for="(item, index) in actionModel"
|
||||
:key="index"
|
||||
class="flex-none"
|
||||
v-bind="{
|
||||
devices,
|
||||
...(item.command
|
||||
? {
|
||||
onClick: () => handleShell(item),
|
||||
}
|
||||
: {}),
|
||||
}"
|
||||
>
|
||||
<template #default="{ loading = false } = {}">
|
||||
<el-button
|
||||
plain
|
||||
:title="$t(item.tips || item.label)"
|
||||
:loading="loading"
|
||||
>
|
||||
<template #icon>
|
||||
<svg-icon
|
||||
v-if="item.svgIcon"
|
||||
:name="item.svgIcon"
|
||||
:class="item.iconClass"
|
||||
></svg-icon>
|
||||
<el-icon v-else-if="item.elIcon" :class="item.iconClass">
|
||||
<component :is="item.elIcon" />
|
||||
</el-icon>
|
||||
</template>
|
||||
{{ $t('common.batch') }}-{{ $t(item.label) }}
|
||||
</el-button>
|
||||
</template>
|
||||
</component>
|
||||
</div>
|
||||
</Scrollable>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
@ -86,7 +86,7 @@
|
||||
<el-table-column
|
||||
v-slot="{ row, $index }"
|
||||
:label="$t('device.control.name')"
|
||||
min-width="250"
|
||||
min-width="300"
|
||||
align="left"
|
||||
>
|
||||
<MirrorAction
|
||||
|
Loading…
Reference in New Issue
Block a user