feat: add qlrepo sync crontab
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch } from 'vue'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from '@/components/ui/dialog'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { ScrollArea } from '@/components/ui/scroll-area'
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'
|
||||
import DirTreeSelect from '@/components/DirTreeSelect.vue'
|
||||
import { X, Globe, GitBranch, Shield, Zap, Clock } from 'lucide-vue-next'
|
||||
import { api, type Task, type RepoConfig, type Agent } from '@/api'
|
||||
import { X, Globe, GitBranch, Shield, Zap, Clock, Download, Plus, Search, Check, ChevronsUpDown, Loader2, AlertCircle } from 'lucide-vue-next'
|
||||
import { api, type Task, type RepoConfig, type Agent, type MiseLanguage } from '@/api'
|
||||
import { toast } from 'vue-sonner'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { getCronDescription } from '@/utils/cron'
|
||||
@@ -56,7 +57,12 @@ const repoConfig = ref<RepoConfig>({
|
||||
proxy_url: '',
|
||||
auth_token: '',
|
||||
whitelist_paths: '',
|
||||
blacklist: '',
|
||||
dependence: '',
|
||||
extensions: '',
|
||||
auto_add_cron: false,
|
||||
concurrency: 1,
|
||||
repo_source: '',
|
||||
proxy: ''
|
||||
})
|
||||
const cleanType = ref('none')
|
||||
@@ -64,7 +70,171 @@ const cleanKeep = ref(30)
|
||||
const allAgents = ref<Agent[]>([])
|
||||
const selectedAgentId = ref<string>('local')
|
||||
const tagInput = ref('')
|
||||
const whitelistInput = ref('')
|
||||
|
||||
const autoAddCron = computed({
|
||||
get: () => !!repoConfig.value.auto_add_cron,
|
||||
set: (val: boolean) => {
|
||||
repoConfig.value.auto_add_cron = val
|
||||
}
|
||||
})
|
||||
|
||||
// === 语言环境相关 ===
|
||||
const installedLangs = ref<MiseLanguage[]>([])
|
||||
const loadingLangs = ref(false)
|
||||
const selectedLangs = ref<{ name: string; version: string; availableVersions: string[] }[]>([])
|
||||
const availablePlugins = ref<string[]>([])
|
||||
const pluginSearch = ref('')
|
||||
const versionSearch = ref('')
|
||||
|
||||
const filteredPlugins = computed(() => {
|
||||
if (!pluginSearch.value) return availablePlugins.value
|
||||
const s = pluginSearch.value.toLowerCase()
|
||||
return availablePlugins.value.filter(p => p.toLowerCase().includes(s))
|
||||
})
|
||||
|
||||
function getFilteredVersions(versions: string[]) {
|
||||
if (!versionSearch.value) return versions
|
||||
const s = versionSearch.value.toLowerCase()
|
||||
return versions.filter(v => v.toLowerCase().includes(s))
|
||||
}
|
||||
|
||||
async function fetchInstalledLangs() {
|
||||
loadingLangs.value = true
|
||||
try {
|
||||
installedLangs.value = await api.mise.list()
|
||||
const plugins = new Set<string>()
|
||||
installedLangs.value.forEach(l => plugins.add(l.plugin))
|
||||
availablePlugins.value = Array.from(plugins).sort()
|
||||
} catch (e) {
|
||||
console.error('Fetch installed langs failed', e)
|
||||
} finally {
|
||||
loadingLangs.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getLangIcon(plugin: string) {
|
||||
const name = plugin?.toLowerCase().trim()
|
||||
const mapping: Record<string, string> = {
|
||||
'python': 'python/python-original.svg',
|
||||
'node': 'nodejs/nodejs-original.svg',
|
||||
'nodejs': 'nodejs/nodejs-original.svg',
|
||||
'go': 'go/go-original.svg',
|
||||
'rust': 'rust/rust-original.svg',
|
||||
'ruby': 'ruby/ruby-plain.svg',
|
||||
'php': 'php/php-plain.svg',
|
||||
'java': 'java/java-plain.svg',
|
||||
'deno': 'deno/deno-plain.svg',
|
||||
'bun': 'bun/bun-plain.svg',
|
||||
'zig': 'zig/zig-original.svg',
|
||||
'dotnet': 'dot-net/dot-net-original.svg',
|
||||
'.net': 'dot-net/dot-net-original.svg',
|
||||
'elixir': 'elixir/elixir-original.svg',
|
||||
'erlang': 'erlang/erlang-original.svg',
|
||||
'crystal': 'crystal/crystal-original.svg',
|
||||
'lua': 'lua/lua-original.svg',
|
||||
'julia': 'julia/julia-original.svg',
|
||||
'nim': 'nim/nim-original.svg',
|
||||
'perl': 'perl/perl-original.svg',
|
||||
'scala': 'scala/scala-original.svg',
|
||||
'kotlin': 'kotlin/kotlin-original.svg',
|
||||
'clojure': 'clojure/clojure-line.svg',
|
||||
'dart': 'dart/dart-original.svg',
|
||||
'flutter': 'flutter/flutter-original.svg',
|
||||
'terraform': 'terraform/terraform-original.svg',
|
||||
'docker': 'docker/docker-original.svg',
|
||||
'kubernetes': 'kubernetes/kubernetes-plain.svg',
|
||||
'ansible': 'ansible/ansible-original.svg',
|
||||
}
|
||||
|
||||
if (mapping[name]) {
|
||||
return `https://fastly.jsdelivr.net/gh/devicons/devicon/icons/${mapping[name]}`
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function updateAvailableVersions(lang: { name: string; version: string; availableVersions: string[] }) {
|
||||
if (lang.name) {
|
||||
lang.availableVersions = installedLangs.value
|
||||
.filter(l => l.plugin === lang.name)
|
||||
.map(l => l.version)
|
||||
.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }))
|
||||
} else {
|
||||
lang.availableVersions = []
|
||||
}
|
||||
}
|
||||
|
||||
function addLang() {
|
||||
selectedLangs.value.push({ name: '', version: '', availableVersions: [] })
|
||||
}
|
||||
|
||||
function removeLang(index: number) {
|
||||
selectedLangs.value.splice(index, 1)
|
||||
}
|
||||
|
||||
function updateLangName(index: number, name: string) {
|
||||
const lang = selectedLangs.value[index]
|
||||
if (!lang) return
|
||||
lang.name = name
|
||||
lang.version = '' // reset version
|
||||
updateAvailableVersions(lang)
|
||||
}
|
||||
|
||||
const showQlImportDialog = ref(false)
|
||||
const qlCommandInput = ref('')
|
||||
|
||||
function importFromQl() {
|
||||
qlCommandInput.value = ''
|
||||
showQlImportDialog.value = true
|
||||
}
|
||||
|
||||
function submitQlImport() {
|
||||
const s = qlCommandInput.value.trim()
|
||||
if (!s) {
|
||||
showQlImportDialog.value = false
|
||||
return
|
||||
}
|
||||
if (!s.startsWith('ql repo')) {
|
||||
toast.error('无效的指令:必须以 ql repo 开头')
|
||||
return
|
||||
}
|
||||
|
||||
// Parse arguments handling quotes
|
||||
const args: string[] = []
|
||||
const regex = /[^\s"']+|"([^"]*)"|'([^']*)'/g
|
||||
let match
|
||||
while ((match = regex.exec(s)) !== null) {
|
||||
args.push(match[1] || match[2] || match[0])
|
||||
}
|
||||
|
||||
if (args[2]) {
|
||||
repoConfig.value.source_url = args[2]
|
||||
repoConfig.value.source_type = 'git'
|
||||
// form task name
|
||||
let name = '同步 '
|
||||
try {
|
||||
const urlPaths = args[2].split('/')
|
||||
if (urlPaths.length > 0) {
|
||||
name += urlPaths[urlPaths.length - 1].replace('.git', '')
|
||||
} else {
|
||||
name += '未命名仓库'
|
||||
}
|
||||
} catch {
|
||||
name += '未命名仓库'
|
||||
}
|
||||
form.value.name = name
|
||||
}
|
||||
|
||||
if (args[3]) repoConfig.value.whitelist_paths = args[3]
|
||||
if (args[4]) repoConfig.value.blacklist = args[4]
|
||||
if (args[5]) repoConfig.value.dependence = args[5]
|
||||
if (args[6]) repoConfig.value.branch = args[6]
|
||||
if (args[7]) repoConfig.value.extensions = args[7]
|
||||
|
||||
repoConfig.value.auto_add_cron = true
|
||||
repoConfig.value.repo_source = 'ql'
|
||||
toast.success('指令解析成功,已开启自动添加任务,请继续完善其他设置')
|
||||
showQlImportDialog.value = false
|
||||
}
|
||||
|
||||
const cronDescription = computed(() => {
|
||||
if (!form.value.schedule) return ''
|
||||
@@ -87,21 +257,6 @@ function removeTag(tagToRemove: string) {
|
||||
form.value.tags = currentTags.filter(t => t !== tagToRemove).join(',')
|
||||
}
|
||||
|
||||
function addWhitelistPath() {
|
||||
const val = whitelistInput.value.trim()
|
||||
if (!val) return
|
||||
const current = repoConfig.value.whitelist_paths ? repoConfig.value.whitelist_paths.split(',').filter(Boolean) : []
|
||||
if (!current.includes(val)) {
|
||||
current.push(val)
|
||||
repoConfig.value.whitelist_paths = current.join(',')
|
||||
}
|
||||
whitelistInput.value = ''
|
||||
}
|
||||
|
||||
function removeWhitelistPath(path: string) {
|
||||
const current = repoConfig.value.whitelist_paths ? repoConfig.value.whitelist_paths.split(',').filter(Boolean) : []
|
||||
repoConfig.value.whitelist_paths = current.filter(p => p !== path).join(',')
|
||||
}
|
||||
|
||||
const concurrencyEnabled = computed({
|
||||
get: () => repoConfig.value.concurrency === 1,
|
||||
@@ -162,7 +317,12 @@ watch(() => props.open, async (val) => {
|
||||
proxy_url: '',
|
||||
auth_token: '',
|
||||
whitelist_paths: '',
|
||||
concurrency: 1
|
||||
blacklist: '',
|
||||
dependence: '',
|
||||
extensions: '',
|
||||
auto_add_cron: false,
|
||||
concurrency: 1,
|
||||
repo_source: ''
|
||||
}
|
||||
const configStr = props.task?.config
|
||||
if (configStr) {
|
||||
@@ -180,10 +340,27 @@ watch(() => props.open, async (val) => {
|
||||
} else {
|
||||
repoConfig.value = defaultConfig
|
||||
}
|
||||
|
||||
// 解析语言环境
|
||||
selectedLangs.value = []
|
||||
if (props.task?.languages && Array.isArray(props.task.languages)) {
|
||||
selectedLangs.value = props.task.languages.map((l: any) => ({
|
||||
name: l.name || '',
|
||||
version: l.version || '',
|
||||
availableVersions: []
|
||||
}))
|
||||
}
|
||||
|
||||
// 仓库任务暂时仅支持本地执行
|
||||
selectedAgentId.value = 'local'
|
||||
// 加载 Agent 列表
|
||||
await loadAgents()
|
||||
if (selectedAgentId.value === 'local') {
|
||||
await fetchInstalledLangs()
|
||||
selectedLangs.value.forEach(lang => {
|
||||
updateAvailableVersions(lang)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -194,6 +371,13 @@ async function loadAgents() {
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (repoConfig.value.auto_add_cron) {
|
||||
if (selectedLangs.value.length === 0 || !selectedLangs.value[0].name) {
|
||||
toast.error('您开启了“自动添加任务”,请先至少添加并选择一个运行语言环境和版本')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
form.value.clean_config = cleanConfig.value
|
||||
form.value.type = 'repo'
|
||||
@@ -205,6 +389,12 @@ async function save() {
|
||||
'$task_concurrency': concurrencyEnabled.value ? 1 : 0
|
||||
}
|
||||
|
||||
// 保存语言环境
|
||||
form.value.languages = selectedLangs.value.map(l => ({
|
||||
name: l.name,
|
||||
version: l.version
|
||||
}))
|
||||
|
||||
form.value.config = JSON.stringify(configToSave)
|
||||
form.value.command = `[${repoConfig.value.source_type}] ${repoConfig.value.source_url}`
|
||||
form.value.agent_id = selectedAgentId.value === 'local' ? null : selectedAgentId.value
|
||||
@@ -228,9 +418,15 @@ async function save() {
|
||||
|
||||
<div class="flex flex-col max-h-[85vh]">
|
||||
<DialogHeader class="px-6 pt-6 pb-2 shrink-0">
|
||||
<DialogTitle class="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-foreground to-foreground/70">
|
||||
{{ isEdit ? '编辑仓库同步' : '新建仓库同步' }}
|
||||
</DialogTitle>
|
||||
<div class="flex items-center justify-between">
|
||||
<DialogTitle class="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-foreground to-foreground/70">
|
||||
{{ isEdit ? '编辑仓库同步' : '新建仓库同步' }}
|
||||
</DialogTitle>
|
||||
<Button v-if="!isEdit" variant="outline" size="sm" @click="importFromQl" class="h-8 gap-1.5 bg-primary/5 hover:bg-primary/10 border-primary/20 hover:border-primary/40 text-primary">
|
||||
<Download class="w-3.5 h-3.5" />
|
||||
青龙格式导入
|
||||
</Button>
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
<ScrollArea class="flex-1 min-h-0 px-6">
|
||||
@@ -325,36 +521,6 @@ async function save() {
|
||||
<Input v-else v-model="repoConfig.target_path" placeholder="Agent 上的目标路径" class="h-9 bg-muted/30 border-muted-foreground/20" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增:白名单路径 -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-4 items-start gap-3">
|
||||
<Label class="sm:text-right text-xs text-muted-foreground uppercase tracking-wider pt-2.5">
|
||||
白名单路径
|
||||
</Label>
|
||||
<div class="sm:col-span-3 space-y-2">
|
||||
<div class="flex gap-2">
|
||||
<div class="relative flex-1">
|
||||
<Input v-model="whitelistInput" placeholder="输入路径或通配符按回车... (如 logs/ 或 *.db)" class="h-9 bg-muted/30 border-muted-foreground/20 pr-12 focus:bg-background" @keydown.enter.prevent="addWhitelistPath" />
|
||||
<Button type="button" variant="ghost" size="sm" class="absolute right-1 top-1 h-7 px-2 text-xs hover:bg-primary/10 hover:text-primary transition-colors" @click="addWhitelistPath">
|
||||
添加
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-1.5 pt-1 min-h-[1.5rem]" v-if="repoConfig.whitelist_paths">
|
||||
<span v-for="path in repoConfig.whitelist_paths.split(',').filter(Boolean)" :key="path"
|
||||
class="flex items-center gap-1.5 bg-blue-500/5 text-blue-500 px-2.5 py-1 rounded-md text-[11px] font-medium border border-blue-500/10 group transition-all hover:bg-blue-500/10">
|
||||
{{ path }}
|
||||
<button type="button" class="text-blue-500/40 hover:text-destructive transition-colors shrink-0" @click.prevent="removeWhitelistPath(path)">
|
||||
<X class="h-3 w-3" />
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<p class="text-[10px] text-muted-foreground mt-1 px-1 leading-relaxed">
|
||||
同步时将保留匹配上述路径的内容(支持 * 通配符)。匹配项在同步前会被暂存,并在同步完成后自动回填还原。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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-muted-foreground uppercase tracking-wider">分支</Label>
|
||||
<Input v-model="repoConfig.branch" placeholder="main (默认)" class="sm:col-span-3 h-9 bg-muted/30 border-muted-foreground/20 focus:bg-background transition-all" autocomplete="off" />
|
||||
@@ -414,6 +580,150 @@ async function save() {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 脚本过滤 Section -->
|
||||
<section class="space-y-4">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<div class="h-4 w-1 bg-primary rounded-full" />
|
||||
<h3 class="text-sm font-semibold text-foreground/80">脚本过滤</h3>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 pl-3 border-l border-muted">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-4 items-center gap-3">
|
||||
<Label class="sm:text-right text-xs text-muted-foreground uppercase tracking-wider">白名单</Label>
|
||||
<div class="sm:col-span-3 relative">
|
||||
<Input v-model="repoConfig.whitelist_paths" placeholder="保活路径或脚本关键词 (如: logs/ | jd_ )" class="h-9 bg-muted/30 border-muted-foreground/20 focus:bg-background transition-all" autocomplete="off" />
|
||||
<p class="text-[10px] text-muted-foreground mt-1 px-1 leading-relaxed">请输入脚本筛选白名单关键词或保活路径(支持 *),多个关键词或路径使用竖线(|)或逗号(,)分割</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-4 items-center gap-3">
|
||||
<Label class="sm:text-right text-xs text-muted-foreground uppercase tracking-wider">脚本黑名单</Label>
|
||||
<div class="sm:col-span-3 relative">
|
||||
<Input v-model="repoConfig.blacklist" placeholder="黑名单关键词 (如: help)" class="h-9 bg-muted/30 border-muted-foreground/20 focus:bg-background transition-all" autocomplete="off" />
|
||||
<p class="text-[10px] text-muted-foreground mt-1 px-1">脚本筛选黑名单关键词,多个关键词竖线(|)分割</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-4 items-center gap-3">
|
||||
<Label class="sm:text-right text-xs text-muted-foreground uppercase tracking-wider">依赖文件</Label>
|
||||
<div class="sm:col-span-3 relative">
|
||||
<Input v-model="repoConfig.dependence" placeholder="依赖文件关键词 (如: ccav | notify)" class="h-9 bg-muted/30 border-muted-foreground/20 focus:bg-background transition-all" autocomplete="off" />
|
||||
<p class="text-[10px] text-muted-foreground mt-1 px-1">脚本依赖文件关键词,多个关键词竖线(|)分割</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-4 items-center gap-3">
|
||||
<Label class="sm:text-right text-xs text-muted-foreground uppercase tracking-wider">文件后缀</Label>
|
||||
<div class="sm:col-span-3 relative">
|
||||
<Input v-model="repoConfig.extensions" placeholder="文件后缀 (如: js | py | sh)" class="h-9 bg-muted/30 border-muted-foreground/20 focus:bg-background transition-all" autocomplete="off" />
|
||||
<p class="text-[10px] text-muted-foreground mt-1 px-1">脚本文件后缀,多个后缀竖线(|)分割</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 运行环境 Section -->
|
||||
<section v-if="selectedAgentId === 'local'" class="space-y-4">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
<div class="h-4 w-1 bg-primary rounded-full" />
|
||||
<h3 class="text-sm font-semibold text-foreground/80">运行环境</h3>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 pl-3 border-l border-muted">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-4 items-start gap-3 mt-2">
|
||||
<Label class="sm:text-right text-xs text-muted-foreground uppercase tracking-wider pt-2.5">语言环境</Label>
|
||||
<div class="sm:col-span-3 space-y-2">
|
||||
<div class="flex items-start gap-2.5 p-3 rounded-xl bg-amber-500/5 border border-amber-500/10 text-amber-600 dark:text-amber-400 text-[11px] leading-relaxed mb-2">
|
||||
<AlertCircle class="h-4 w-4 shrink-0 text-amber-500 mt-0.5" />
|
||||
<p>同步后生成的任务将自动继承此运行环境。如果不指定语言版本,某些依赖特定语言的脚本(如 js, py)将无法顺利解析和运行!</p>
|
||||
</div>
|
||||
|
||||
<div v-for="(clang, idx) in selectedLangs" :key="idx"
|
||||
class="flex gap-2 p-2 rounded-lg bg-muted/20 border border-muted-foreground/10 group/lang relative overflow-hidden">
|
||||
<div class="absolute left-0 top-0 bottom-0 w-0.5 bg-primary/20 group-hover/lang:bg-primary transition-colors" />
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button variant="ghost" role="combobox" class="justify-between flex-1 h-8 text-xs font-normal hover:bg-background/50">
|
||||
<div class="flex items-center gap-2 truncate">
|
||||
<div v-if="clang.name && getLangIcon(clang.name)" class="w-4 h-4 shrink-0 rounded-sm bg-white p-0.5 border shadow-sm">
|
||||
<img :src="getLangIcon(clang.name)" class="w-full h-full object-contain" />
|
||||
</div>
|
||||
<span class="font-medium">{{ clang.name || "选择插件..." }}</span>
|
||||
</div>
|
||||
<ChevronsUpDown class="ml-1 h-3 w-3 opacity-40" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="p-0 w-[240px]" align="start">
|
||||
<div class="p-2 border-b bg-muted/30">
|
||||
<div class="relative">
|
||||
<Search class="absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" />
|
||||
<Input v-model="pluginSearch" placeholder="搜索已安装语言..." class="h-8 pl-8 text-xs bg-background" />
|
||||
</div>
|
||||
</div>
|
||||
<ScrollArea class="h-48 p-1">
|
||||
<div v-if="loadingLangs" class="flex items-center justify-center py-6">
|
||||
<Loader2 class="h-5 w-5 animate-spin text-primary/50" />
|
||||
</div>
|
||||
<div v-else-if="filteredPlugins.length === 0" class="py-6 text-center text-xs text-muted-foreground">
|
||||
未找到匹配项
|
||||
</div>
|
||||
<button v-else v-for="p in filteredPlugins" :key="p" @click="updateLangName(idx, p)"
|
||||
class="w-full flex items-center px-3 py-2 text-xs rounded-md hover:bg-accent text-left transition-all group/item mb-0.5">
|
||||
<div class="mr-3 h-5 w-5 shrink-0 flex items-center justify-center transition-transform group-hover/item:scale-110">
|
||||
<img v-if="getLangIcon(p)" :src="getLangIcon(p)" class="w-full h-full object-contain p-0.5 bg-white rounded border" />
|
||||
<div v-else class="w-full h-full flex items-center justify-center bg-primary/10 rounded-sm text-[8px] font-bold border">
|
||||
{{ p.substring(0, 2) }}
|
||||
</div>
|
||||
</div>
|
||||
<span class="flex-1" :class="{ 'font-bold text-primary': clang.name === p }">{{ p }}</span>
|
||||
<Check v-if="clang.name === p" class="h-3 w-3 text-primary" />
|
||||
</button>
|
||||
</ScrollArea>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
<Popover>
|
||||
<PopoverTrigger asChild :disabled="!clang.name">
|
||||
<Button variant="ghost" role="combobox" class="justify-between w-28 h-8 text-xs font-normal hover:bg-background/50" :disabled="!clang.name">
|
||||
<span class="truncate">{{ clang.version || "版本..." }}</span>
|
||||
<ChevronsUpDown class="h-3 w-3 opacity-40 ml-1" />
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent class="p-0 w-[160px]" align="start">
|
||||
<div class="p-2 border-b bg-muted/30">
|
||||
<div class="relative">
|
||||
<Search class="absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" />
|
||||
<Input v-model="versionSearch" placeholder="搜索版本..." class="h-8 pl-8 text-xs bg-background" />
|
||||
</div>
|
||||
</div>
|
||||
<ScrollArea class="h-48 p-1">
|
||||
<div v-if="getFilteredVersions(clang.availableVersions).length === 0" class="py-6 text-center text-xs text-muted-foreground">
|
||||
无可用版本
|
||||
</div>
|
||||
<button v-else v-for="v in getFilteredVersions(clang.availableVersions)" :key="v" @click="clang.version = v"
|
||||
class="w-full flex items-center px-3 py-2 text-xs rounded-md hover:bg-accent text-left mb-0.5 font-mono">
|
||||
<span class="flex-1 truncate" :class="{ 'font-bold text-primary': clang.version === v }">{{ v }}</span>
|
||||
<Check v-if="clang.version === v" class="h-3 w-3 text-primary" />
|
||||
</button>
|
||||
</ScrollArea>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
<Button variant="ghost" size="icon" class="h-8 w-8 text-muted-foreground hover:text-destructive hover:bg-destructive/10 shrink-0"
|
||||
@click="removeLang(idx)">
|
||||
<X class="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Button variant="outline" size="sm" class="w-full h-9 text-xs border-dashed border-muted-foreground/30 text-muted-foreground hover:text-primary hover:border-primary/50 transition-all bg-muted/10 hover:bg-primary/5"
|
||||
@click="addLang">
|
||||
<Plus class="h-4 w-4 mr-2" /> 必须添加运行语言和版本
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 调度策略 Section -->
|
||||
<section class="space-y-4">
|
||||
<div class="flex items-center gap-2 mb-1">
|
||||
@@ -461,6 +771,20 @@ async function save() {
|
||||
<div class="grid grid-cols-1 sm:grid-cols-4 items-start gap-3">
|
||||
<Label class="sm:text-right text-xs text-muted-foreground uppercase tracking-wider">运行策略</Label>
|
||||
<div class="sm:col-span-3 space-y-4">
|
||||
|
||||
<div class="p-3 rounded-xl bg-muted/20 border border-muted-foreground/10 space-y-2.5">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-2 text-xs font-semibold">
|
||||
<Zap :class="cn('h-3.5 w-3.5', autoAddCron ? 'text-primary' : 'text-muted-foreground')" />
|
||||
自动添加任务
|
||||
</div>
|
||||
<Switch :model-value="autoAddCron" @update:model-value="v => autoAddCron = v" />
|
||||
</div>
|
||||
<p class="text-[11px] text-muted-foreground leading-relaxed">
|
||||
{{ autoAddCron ? '同步完成后将尝试自动分析脚本并注册定时任务。' : '仅拉取脚本,不自动注册成面板任务。' }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex items-center gap-2">
|
||||
<Input :model-value="form.timeout" @update:model-value="v => form.timeout = Number(v || 0)" type="number" :min="0" class="w-20 h-9 bg-muted/30 text-center" />
|
||||
@@ -512,4 +836,34 @@ async function save() {
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<!-- 青龙导入提示对话框 -->
|
||||
<Dialog :open="showQlImportDialog" @update:open="v => showQlImportDialog = v">
|
||||
<DialogContent class="sm:max-w-[425px] p-0 border-none bg-background/95 backdrop-blur-xl shadow-2xl">
|
||||
<DialogHeader class="px-6 pt-6 pb-2">
|
||||
<DialogTitle class="text-xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-foreground to-foreground/70">
|
||||
请输入青龙面板的 ql repo 指令
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div class="px-6 py-4 space-y-4 text-sm text-muted-foreground leading-relaxed">
|
||||
<p>例如:</p>
|
||||
<div class="p-2 rounded-md bg-muted/50 font-mono text-xs select-all text-primary/80 break-all border border-muted-foreground/10">
|
||||
ql repo "https://github.com/a/b.git" "jd_|jx_" "activity" "^jd[^_]" "main" "js|py"
|
||||
</div>
|
||||
<div class="relative mt-2">
|
||||
<Input v-model="qlCommandInput" placeholder="在此处粘贴完整指令,如 ql repo ..." class="h-10 pr-10 focus:ring-primary/20 bg-muted/20" @keydown.enter.prevent="submitQlImport" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DialogFooter class="px-6 pb-6 pt-2">
|
||||
<Button variant="outline" size="sm" @click="showQlImportDialog = false" class="border-border/40 hover:bg-muted/30">
|
||||
取消
|
||||
</Button>
|
||||
<Button size="sm" @click="submitQlImport" class="shadow-sm">
|
||||
确定 <Download class="h-3 w-3 ml-1.5" />
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user