mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 18:27:13 +08:00
feat: 添加磁盘管理工具到工具箱 (#1195)
* Initial plan * 实现磁盘管理工具的后端和前端基础功能 Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * 完成磁盘管理工具功能实现并验证构建成功 Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * 添加输入验证防止命令注入攻击 Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * 移除命令注入验证并修复评审意见 Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> * feat: merge main * feat: merge main * feat: 分区优化 * feat: fstab管理 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com> Co-authored-by: 耗子 <haozi@loli.email>
This commit is contained in:
46
web/src/api/panel/toolbox-disk/index.ts
Normal file
46
web/src/api/panel/toolbox-disk/index.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { http } from '@/utils'
|
||||
|
||||
export default {
|
||||
// 获取磁盘列表
|
||||
list: (): any => http.Get('/toolbox_disk/list'),
|
||||
// 获取分区列表
|
||||
partitions: (device: string): any => http.Post('/toolbox_disk/partitions', { device }),
|
||||
// 挂载分区
|
||||
mount: (
|
||||
device: string,
|
||||
path: string,
|
||||
write_fstab: boolean = false,
|
||||
mount_option: string = ''
|
||||
): any => http.Post('/toolbox_disk/mount', { device, path, write_fstab, mount_option }),
|
||||
// 卸载分区
|
||||
umount: (path: string): any => http.Post('/toolbox_disk/umount', { path }),
|
||||
// 格式化分区
|
||||
format: (device: string, fs_type: string): any =>
|
||||
http.Post('/toolbox_disk/format', { device, fs_type }),
|
||||
// 初始化磁盘
|
||||
init: (device: string, fs_type: string): any =>
|
||||
http.Post('/toolbox_disk/init', { device, fs_type }),
|
||||
// 获取 fstab 列表
|
||||
fstabList: (): any => http.Get('/toolbox_disk/fstab'),
|
||||
// 删除 fstab 条目
|
||||
fstabDelete: (mount_point: string): any => http.Delete('/toolbox_disk/fstab', { mount_point }),
|
||||
// 获取LVM信息
|
||||
lvmInfo: (): any => http.Get('/toolbox_disk/lvm'),
|
||||
// 创建物理卷
|
||||
createPV: (device: string): any => http.Post('/toolbox_disk/lvm/pv', { device }),
|
||||
// 删除物理卷
|
||||
removePV: (device: string): any => http.Delete('/toolbox_disk/lvm/pv', { device }),
|
||||
// 创建卷组
|
||||
createVG: (name: string, devices: string[]): any =>
|
||||
http.Post('/toolbox_disk/lvm/vg', { name, devices }),
|
||||
// 删除卷组
|
||||
removeVG: (name: string): any => http.Delete('/toolbox_disk/lvm/vg', { name }),
|
||||
// 创建逻辑卷
|
||||
createLV: (name: string, vg_name: string, size: number): any =>
|
||||
http.Post('/toolbox_disk/lvm/lv', { name, vg_name, size }),
|
||||
// 删除逻辑卷
|
||||
removeLV: (path: string): any => http.Delete('/toolbox_disk/lvm/lv', { path }),
|
||||
// 扩容逻辑卷
|
||||
extendLV: (path: string, size: number, resize: boolean): any =>
|
||||
http.Post('/toolbox_disk/lvm/lv/extend', { path, size, resize })
|
||||
}
|
||||
1020
web/src/views/toolbox/DiskView.vue
Normal file
1020
web/src/views/toolbox/DiskView.vue
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,8 +4,9 @@ defineOptions({
|
||||
})
|
||||
|
||||
import BenchmarkView from '@/views/toolbox/BenchmarkView.vue'
|
||||
import DiskView from '@/views/toolbox/DiskView.vue'
|
||||
import ProcessView from '@/views/toolbox/ProcessView.vue'
|
||||
import SSHView from '@/views/toolbox/SSHView.vue'
|
||||
import SshView from '@/views/toolbox/SshView.vue'
|
||||
import SystemView from '@/views/toolbox/SystemView.vue'
|
||||
import WebHookView from '@/views/toolbox/WebHookView.vue'
|
||||
import { useGettext } from 'vue3-gettext'
|
||||
@@ -21,6 +22,7 @@ const current = ref('process')
|
||||
<n-tab name="process" :tab="$gettext('Process')" />
|
||||
<n-tab name="system" :tab="$gettext('System')" />
|
||||
<n-tab name="ssh" tab="SSH" />
|
||||
<n-tab name="disk" :tab="$gettext('Disk')" />
|
||||
<n-tab name="webhook" :tab="$gettext('WebHook')" />
|
||||
<n-tab name="benchmark" :tab="$gettext('Benchmark')" />
|
||||
</n-tabs>
|
||||
@@ -28,7 +30,8 @@ const current = ref('process')
|
||||
<n-flex vertical>
|
||||
<process-view v-if="current === 'process'" />
|
||||
<system-view v-if="current === 'system'" />
|
||||
<s-s-h-view v-if="current === 'ssh'" />
|
||||
<ssh-view v-if="current === 'ssh'" />
|
||||
<disk-view v-if="current === 'disk'" />
|
||||
<web-hook-view v-if="current === 'webhook'" />
|
||||
<benchmark-view v-if="current === 'benchmark'" />
|
||||
</n-flex>
|
||||
|
||||
@@ -224,20 +224,16 @@ onMounted(() => {
|
||||
<template>
|
||||
<n-spin :show="loading">
|
||||
<n-flex vertical :size="24">
|
||||
<!-- SSH 服务状态 -->
|
||||
<!-- SSH 服务 -->
|
||||
<n-card :title="$gettext('SSH Service')">
|
||||
<n-flex align="center" :size="12">
|
||||
<n-text strong>{{ $gettext('SSH Service Status') }}</n-text>
|
||||
<n-switch :value="sshStatus" :loading="loading" @update:value="handleToggleSSH" />
|
||||
<n-button :loading="loading" @click="handleRestartSSH">
|
||||
{{ $gettext('Restart') }}
|
||||
</n-button>
|
||||
</n-flex>
|
||||
</n-card>
|
||||
|
||||
<!-- SSH 基础设置 -->
|
||||
<n-card :title="$gettext('SSH Basic Settings')">
|
||||
<n-flex vertical :size="16">
|
||||
<n-flex align="center" :size="12">
|
||||
<n-text strong>{{ $gettext('SSH Service Status') }}</n-text>
|
||||
<n-switch :value="sshStatus" :loading="loading" @update:value="handleToggleSSH" />
|
||||
<n-button :loading="loading" @click="handleRestartSSH">
|
||||
{{ $gettext('Restart') }}
|
||||
</n-button>
|
||||
</n-flex>
|
||||
<!-- SSH 密码登录 -->
|
||||
<n-flex vertical :size="4">
|
||||
<n-flex align="center" :size="12">
|
||||
@@ -250,7 +246,6 @@ onMounted(() => {
|
||||
</n-flex>
|
||||
<n-text depth="3">{{ $gettext('Allow password authentication for SSH login') }}</n-text>
|
||||
</n-flex>
|
||||
|
||||
<!-- SSH 密钥登录 -->
|
||||
<n-flex vertical :size="4">
|
||||
<n-flex align="center" :size="12">
|
||||
@@ -265,7 +260,6 @@ onMounted(() => {
|
||||
$gettext('Allow public key authentication for SSH login')
|
||||
}}</n-text>
|
||||
</n-flex>
|
||||
|
||||
<!-- SSH 端口 -->
|
||||
<n-flex vertical :size="4">
|
||||
<n-flex align="center" :size="12">
|
||||
@@ -299,7 +293,6 @@ onMounted(() => {
|
||||
@update:value="handleUpdateRootLogin"
|
||||
/>
|
||||
</n-flex>
|
||||
|
||||
<!-- Root 密码 -->
|
||||
<n-flex vertical :size="8">
|
||||
<n-text strong>{{ $gettext('Root Password') }}</n-text>
|
||||
@@ -332,7 +325,6 @@ onMounted(() => {
|
||||
}}
|
||||
</n-text>
|
||||
</n-flex>
|
||||
|
||||
<!-- Root 密钥 -->
|
||||
<n-flex vertical :size="4">
|
||||
<n-flex align="center" :size="12">
|
||||
@@ -290,7 +290,7 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<n-flex vertical>
|
||||
<n-flex justify="end">
|
||||
<n-flex>
|
||||
<n-button type="primary" @click="createModal = true">
|
||||
{{ $gettext('Create WebHook') }}
|
||||
</n-button>
|
||||
|
||||
Reference in New Issue
Block a user