feat(task): support custom repo sync dir name and fix UI copy (#132)
This commit is contained in:
@@ -487,7 +487,7 @@ export interface RepoConfig {
|
||||
commenttotask?: string
|
||||
concurrency?: number
|
||||
repo_source?: string
|
||||
dir_name?: string
|
||||
repo_dir_name?: string
|
||||
}
|
||||
|
||||
export interface ExecutionResult {
|
||||
|
||||
@@ -28,14 +28,15 @@ export async function copyToClipboard(text: string): Promise<boolean> {
|
||||
textarea.style.opacity = '0'
|
||||
textarea.style.left = '-9999px'
|
||||
|
||||
document.body.appendChild(textarea)
|
||||
const parent = document.activeElement?.parentNode || document.body
|
||||
parent.appendChild(textarea)
|
||||
|
||||
// 兼容 iOS 的选中方式
|
||||
textarea.select()
|
||||
textarea.setSelectionRange(0, 99999)
|
||||
|
||||
const success = document.execCommand('copy')
|
||||
document.body.removeChild(textarea)
|
||||
parent.removeChild(textarea)
|
||||
|
||||
if (success) {
|
||||
return true
|
||||
|
||||
@@ -127,7 +127,7 @@ export function parseBaihuCommand(command: string): ParsedRepoResult | null {
|
||||
}
|
||||
break
|
||||
case '--repo-name':
|
||||
repoConfig.dir_name = value
|
||||
repoConfig.repo_dir_name = value
|
||||
break
|
||||
case '--pre-command':
|
||||
task.pre_command = value
|
||||
@@ -216,8 +216,8 @@ export function generateBaihuCommand(task: Task): string {
|
||||
if (config.branch) {
|
||||
args.push('--branch', config.branch)
|
||||
}
|
||||
if (config.dir_name) {
|
||||
args.push('--repo-name', config.dir_name)
|
||||
if (config.repo_dir_name) {
|
||||
args.push('--repo-name', config.repo_dir_name)
|
||||
}
|
||||
if (config.sparse_path) {
|
||||
args.push('--path', config.sparse_path)
|
||||
|
||||
@@ -63,7 +63,7 @@ const repoConfig = ref<RepoConfig>({
|
||||
concurrency: 1,
|
||||
repo_source: '',
|
||||
proxy: '',
|
||||
dir_name: ''
|
||||
repo_dir_name: ''
|
||||
})
|
||||
|
||||
const allAgents = ref<Agent[]>([])
|
||||
@@ -99,7 +99,7 @@ function exportBaihuCommand() {
|
||||
if (repoConfig.value.source_url) parts.push(`--source-url "${repoConfig.value.source_url}"`)
|
||||
if (repoConfig.value.target_path) parts.push(`--target-path "${repoConfig.value.target_path}"`)
|
||||
if (repoConfig.value.branch) parts.push(`--branch "${repoConfig.value.branch}"`)
|
||||
if (repoConfig.value.dir_name) parts.push(`--repo-name "${repoConfig.value.dir_name}"`)
|
||||
if (repoConfig.value.repo_dir_name) parts.push(`--repo-name "${repoConfig.value.repo_dir_name}"`)
|
||||
if (repoConfig.value.sparse_path) parts.push(`--path "${repoConfig.value.sparse_path}"`)
|
||||
if (repoConfig.value.single_file) parts.push(`--single-file`)
|
||||
if (repoConfig.value.proxy && repoConfig.value.proxy !== 'none') parts.push(`--proxy ${repoConfig.value.proxy}`)
|
||||
@@ -231,7 +231,7 @@ watch(() => props.open, async (val: boolean) => {
|
||||
commenttotask: 'false',
|
||||
concurrency: 1,
|
||||
repo_source: '',
|
||||
dir_name: ''
|
||||
repo_dir_name: ''
|
||||
}
|
||||
const configStr = props.task?.config
|
||||
if (configStr) {
|
||||
@@ -308,7 +308,11 @@ async function save() {
|
||||
}
|
||||
emit('update:open', false)
|
||||
emit('saved')
|
||||
} catch { toast.error('保存失败') }
|
||||
} catch (error: any) {
|
||||
toast.error('保存失败', {
|
||||
description: error.response?.data?.error || error.response?.data?.message || error.message || '未知错误'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -419,7 +423,7 @@ async function save() {
|
||||
<div v-if="repoConfig.source_type === 'git'" class="grid grid-cols-1 sm:grid-cols-4 items-center gap-3">
|
||||
<Label class="sm:text-right text-xs text-foreground/70 uppercase tracking-wider font-medium">目录名定制</Label>
|
||||
<div class="sm:col-span-3 relative">
|
||||
<Input v-model="repoConfig.dir_name" placeholder="自定义生成目录名 (输入 . 表示不追加子目录)" class="h-9 bg-muted/30 border-muted-foreground/20 focus:bg-background transition-all" autocomplete="off" />
|
||||
<Input v-model="repoConfig.repo_dir_name" placeholder="留空则默认为 username_reponame 拼接" class="h-9 bg-muted/30 border-muted-foreground/20 focus:bg-background transition-all" autocomplete="off" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="repoConfig.source_type === 'git'" class="grid grid-cols-1 sm:grid-cols-4 items-center gap-3">
|
||||
|
||||
Reference in New Issue
Block a user