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"`
|
Name string `json:"name" binding:"required"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Type string `json:"type" binding:"required"`
|
Type string `json:"type" binding:"required"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ctx.ShouldBindJSON(&req); err != nil {
|
if err := ctx.ShouldBindJSON(&req); err != nil {
|
||||||
@@ -98,6 +99,7 @@ func (c *DependencyController) Install(ctx *gin.Context) {
|
|||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
Version: req.Version,
|
Version: req.Version,
|
||||||
Type: req.Type,
|
Type: req.Type,
|
||||||
|
Remark: req.Remark,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.service.Install(dep); err != nil {
|
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 }) =>
|
create: (data: { name: string; version?: string; type: string; remark?: string }) =>
|
||||||
request<Dependency>('/deps', { method: 'POST', body: JSON.stringify(data) }),
|
request<Dependency>('/deps', { method: 'POST', body: JSON.stringify(data) }),
|
||||||
delete: (id: number) => request(`/deps/${id}`, { method: 'DELETE' }),
|
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) }),
|
request('/deps/install', { method: 'POST', body: JSON.stringify(data) }),
|
||||||
uninstall: (id: number) => request(`/deps/uninstall/${id}`, { method: 'POST' }),
|
uninstall: (id: number) => request(`/deps/uninstall/${id}`, { method: 'POST' }),
|
||||||
getInstalled: (type: string) => request<Dependency[]>(`/deps/installed?type=${type}`)
|
getInstalled: (type: string) => request<Dependency[]>(`/deps/installed?type=${type}`)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const installing = ref(false)
|
|||||||
const showInstallDialog = ref(false)
|
const showInstallDialog = ref(false)
|
||||||
const newPkgName = ref('')
|
const newPkgName = ref('')
|
||||||
const newPkgVersion = ref('')
|
const newPkgVersion = ref('')
|
||||||
|
const newPkgRemark = ref('')
|
||||||
|
|
||||||
// 删除确认
|
// 删除确认
|
||||||
const showDeleteDialog = ref(false)
|
const showDeleteDialog = ref(false)
|
||||||
@@ -54,6 +55,7 @@ async function loadDeps() {
|
|||||||
function openInstallDialog() {
|
function openInstallDialog() {
|
||||||
newPkgName.value = ''
|
newPkgName.value = ''
|
||||||
newPkgVersion.value = ''
|
newPkgVersion.value = ''
|
||||||
|
newPkgRemark.value = ''
|
||||||
showInstallDialog.value = true
|
showInstallDialog.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +69,8 @@ async function installPackage() {
|
|||||||
await api.deps.install({
|
await api.deps.install({
|
||||||
name: newPkgName.value.trim(),
|
name: newPkgName.value.trim(),
|
||||||
version: newPkgVersion.value.trim() || undefined,
|
version: newPkgVersion.value.trim() || undefined,
|
||||||
type: activeTab.value
|
type: activeTab.value,
|
||||||
|
remark: newPkgRemark.value.trim() || undefined
|
||||||
})
|
})
|
||||||
toast.success('安装成功')
|
toast.success('安装成功')
|
||||||
showInstallDialog.value = false
|
showInstallDialog.value = false
|
||||||
@@ -203,6 +206,10 @@ onMounted(loadDeps)
|
|||||||
<Label class="text-right">版本</Label>
|
<Label class="text-right">版本</Label>
|
||||||
<Input v-model="newPkgVersion" placeholder="可选,如 1.0.0" class="col-span-3" />
|
<Input v-model="newPkgVersion" placeholder="可选,如 1.0.0" class="col-span-3" />
|
||||||
</div>
|
</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>
|
</div>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
<Button variant="outline" @click="showInstallDialog = false">取消</Button>
|
<Button variant="outline" @click="showInstallDialog = false">取消</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user