feat: add deps page

This commit is contained in:
engigu
2025-12-23 23:14:51 +08:00
parent 4de4073ae2
commit 95242410d5
3 changed files with 11 additions and 2 deletions
@@ -87,6 +87,7 @@ func (c *DependencyController) Install(ctx *gin.Context) {
Name string `json:"name" binding:"required"`
Version string `json:"version"`
Type string `json:"type" binding:"required"`
Remark string `json:"remark"`
}
if err := ctx.ShouldBindJSON(&req); err != nil {
@@ -98,6 +99,7 @@ func (c *DependencyController) Install(ctx *gin.Context) {
Name: req.Name,
Version: req.Version,
Type: req.Type,
Remark: req.Remark,
}
if err := c.service.Install(dep); err != nil {
+1 -1
View File
@@ -200,7 +200,7 @@ export const api = {
create: (data: { name: string; version?: string; type: string; remark?: string }) =>
request<Dependency>('/deps', { method: 'POST', body: JSON.stringify(data) }),
delete: (id: number) => request(`/deps/${id}`, { method: 'DELETE' }),
install: (data: { name: string; version?: string; type: string }) =>
install: (data: { name: string; version?: string; type: string; remark?: string }) =>
request('/deps/install', { method: 'POST', body: JSON.stringify(data) }),
uninstall: (id: number) => request(`/deps/uninstall/${id}`, { method: 'POST' }),
getInstalled: (type: string) => request<Dependency[]>(`/deps/installed?type=${type}`)
+8 -1
View File
@@ -20,6 +20,7 @@ const installing = ref(false)
const showInstallDialog = ref(false)
const newPkgName = ref('')
const newPkgVersion = ref('')
const newPkgRemark = ref('')
// 删除确认
const showDeleteDialog = ref(false)
@@ -54,6 +55,7 @@ async function loadDeps() {
function openInstallDialog() {
newPkgName.value = ''
newPkgVersion.value = ''
newPkgRemark.value = ''
showInstallDialog.value = true
}
@@ -67,7 +69,8 @@ async function installPackage() {
await api.deps.install({
name: newPkgName.value.trim(),
version: newPkgVersion.value.trim() || undefined,
type: activeTab.value
type: activeTab.value,
remark: newPkgRemark.value.trim() || undefined
})
toast.success('安装成功')
showInstallDialog.value = false
@@ -203,6 +206,10 @@ onMounted(loadDeps)
<Label class="text-right">版本</Label>
<Input v-model="newPkgVersion" placeholder="可选,如 1.0.0" class="col-span-3" />
</div>
<div class="grid grid-cols-4 items-center gap-4">
<Label class="text-right">备注</Label>
<Input v-model="newPkgRemark" placeholder="可选" class="col-span-3" />
</div>
</div>
<DialogFooter>
<Button variant="outline" @click="showInstallDialog = false">取消</Button>