feat: add deps page
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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}`)
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user