1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 16:29:17 +08:00

fix: daemon.json 路径逻辑调整

This commit is contained in:
ssongliu 2023-01-05 17:29:27 +08:00
parent 5a20546fc6
commit 8674cf0b53
14 changed files with 194 additions and 198 deletions

View File

@ -28,22 +28,6 @@ func (b *BaseApi) GetSettingInfo(c *gin.Context) {
helper.SuccessWithData(c, setting) helper.SuccessWithData(c, setting)
} }
// Load daemon.json path
// @Tags System Setting
// @Summary Load daemon.json path
// @Description 加载 docker 配置路径
// @Success 200 {string} path
// @Security ApiKeyAuth
// @Router /settings/daemonjson [get]
func (b *BaseApi) GetDaemonjson(c *gin.Context) {
value, err := settingService.GetDaemonjson()
if err != nil {
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
return
}
helper.SuccessWithData(c, value)
}
// @Tags System Setting // @Tags System Setting
// @Summary Update system setting // @Summary Update system setting
// @Description 更新系统配置 // @Description 更新系统配置

View File

@ -7,6 +7,7 @@ type DaemonJsonUpdateByFile struct {
type DaemonJsonConf struct { type DaemonJsonConf struct {
Status string `json:"status"` Status string `json:"status"`
Version string `json:"version"`
Mirrors []string `json:"registryMirrors"` Mirrors []string `json:"registryMirrors"`
Registries []string `json:"insecureRegistries"` Registries []string `json:"insecureRegistries"`
LiveRestore bool `json:"liveRestore"` LiveRestore bool `json:"liveRestore"`

View File

@ -2,14 +2,17 @@ package service
import ( import (
"bufio" "bufio"
"context"
"encoding/json" "encoding/json"
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"path"
"strings" "strings"
"github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/utils/docker"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -53,31 +56,33 @@ func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
if string(stdout) != "active\n" || err != nil { if string(stdout) != "active\n" || err != nil {
status = constant.Stopped status = constant.Stopped
} }
fileSetting, err := settingRepo.Get(settingRepo.WithByKey("DaemonJsonPath")) version := "-"
client, err := docker.NewDockerClient()
if err == nil {
ctx := context.Background()
itemVersion, err := client.ServerVersion(ctx)
if err == nil {
version = itemVersion.Version
}
}
if _, err := os.Stat(constant.DaemonJsonPath); err != nil {
return &dto.DaemonJsonConf{Status: status, Version: version}
}
file, err := ioutil.ReadFile(constant.DaemonJsonPath)
if err != nil { if err != nil {
return &dto.DaemonJsonConf{Status: status} return &dto.DaemonJsonConf{Status: status, Version: version}
}
if len(fileSetting.Value) == 0 {
return &dto.DaemonJsonConf{Status: status}
}
if _, err := os.Stat(fileSetting.Value); err != nil {
return &dto.DaemonJsonConf{Status: status}
}
file, err := ioutil.ReadFile(fileSetting.Value)
if err != nil {
return &dto.DaemonJsonConf{Status: status}
} }
var conf daemonJsonItem var conf daemonJsonItem
deamonMap := make(map[string]interface{}) deamonMap := make(map[string]interface{})
if err := json.Unmarshal(file, &deamonMap); err != nil { if err := json.Unmarshal(file, &deamonMap); err != nil {
return &dto.DaemonJsonConf{Status: status} return &dto.DaemonJsonConf{Status: status, Version: version}
} }
arr, err := json.Marshal(deamonMap) arr, err := json.Marshal(deamonMap)
if err != nil { if err != nil {
return &dto.DaemonJsonConf{Status: status} return &dto.DaemonJsonConf{Status: status, Version: version}
} }
if err := json.Unmarshal(arr, &conf); err != nil { if err := json.Unmarshal(arr, &conf); err != nil {
return &dto.DaemonJsonConf{Status: status} return &dto.DaemonJsonConf{Status: status, Version: version}
} }
driver := "cgroupfs" driver := "cgroupfs"
for _, opt := range conf.ExecOpts { for _, opt := range conf.ExecOpts {
@ -88,6 +93,7 @@ func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
} }
data := dto.DaemonJsonConf{ data := dto.DaemonJsonConf{
Status: status, Status: status,
Version: version,
Mirrors: conf.Mirrors, Mirrors: conf.Mirrors,
Registries: conf.Registries, Registries: conf.Registries,
LiveRestore: conf.LiveRestore, LiveRestore: conf.LiveRestore,
@ -98,22 +104,16 @@ func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf {
} }
func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error { func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error {
fileSetting, err := settingRepo.Get(settingRepo.WithByKey("DaemonJsonPath")) if _, err := os.Stat(constant.DaemonJsonPath); err != nil && os.IsNotExist(err) {
if err != nil { if err = os.MkdirAll(path.Dir(constant.DaemonJsonPath), os.ModePerm); err != nil {
return err
}
if len(fileSetting.Value) == 0 {
return errors.New("error daemon.json path in request")
}
if _, err := os.Stat(fileSetting.Value); err != nil && os.IsNotExist(err) {
if err = os.MkdirAll(fileSetting.Value, os.ModePerm); err != nil {
if err != nil { if err != nil {
return err return err
} }
} }
_, _ = os.Create(constant.DaemonJsonPath)
} }
file, err := ioutil.ReadFile(fileSetting.Value) file, err := ioutil.ReadFile(constant.DaemonJsonPath)
if err != nil { if err != nil {
return err return err
} }
@ -155,7 +155,7 @@ func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error {
if err != nil { if err != nil {
return err return err
} }
if err := ioutil.WriteFile(fileSetting.Value, newJson, 0640); err != nil { if err := ioutil.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil {
return err return err
} }

View File

@ -176,24 +176,17 @@ func (u *ImageRepoService) checkConn(host, user, password string) error {
} }
func (u *ImageRepoService) handleRegistries(newHost, delHost, handle string) error { func (u *ImageRepoService) handleRegistries(newHost, delHost, handle string) error {
fileSetting, err := settingRepo.Get(settingRepo.WithByKey("DaemonJsonPath")) if _, err := os.Stat(constant.DaemonJsonPath); err != nil && os.IsNotExist(err) {
if err != nil { if err = os.MkdirAll(path.Dir(constant.DaemonJsonPath), os.ModePerm); err != nil {
return err
}
if len(fileSetting.Value) == 0 {
return errors.New("error daemon.json in settings")
}
if _, err := os.Stat(path.Dir(fileSetting.Value)); err != nil && os.IsNotExist(err) {
if err = os.MkdirAll(fileSetting.Value, os.ModePerm); err != nil {
if err != nil { if err != nil {
return err return err
} }
} }
_, _ = os.Create(fileSetting.Value) _, _ = os.Create(constant.DaemonJsonPath)
} }
deamonMap := make(map[string]interface{}) deamonMap := make(map[string]interface{})
file, err := ioutil.ReadFile(fileSetting.Value) file, err := ioutil.ReadFile(constant.DaemonJsonPath)
if err != nil { if err != nil {
return err return err
} }
@ -229,7 +222,7 @@ func (u *ImageRepoService) handleRegistries(newHost, delHost, handle string) err
if err != nil { if err != nil {
return err return err
} }
if err := ioutil.WriteFile(fileSetting.Value, newJson, 0640); err != nil { if err := ioutil.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil {
return err return err
} }
return nil return nil

View File

@ -16,7 +16,6 @@ type SettingService struct{}
type ISettingService interface { type ISettingService interface {
GetSettingInfo() (*dto.SettingInfo, error) GetSettingInfo() (*dto.SettingInfo, error)
GetDaemonjson() (string, error)
Update(c *gin.Context, key, value string) error Update(c *gin.Context, key, value string) error
UpdatePassword(c *gin.Context, old, new string) error UpdatePassword(c *gin.Context, old, new string) error
HandlePasswordExpired(c *gin.Context, old, new string) error HandlePasswordExpired(c *gin.Context, old, new string) error
@ -47,14 +46,6 @@ func (u *SettingService) GetSettingInfo() (*dto.SettingInfo, error) {
return &info, err return &info, err
} }
func (u *SettingService) GetDaemonjson() (string, error) {
setting, err := settingRepo.Get(settingRepo.WithByKey("DaemonJsonPath"))
if err != nil {
return "", err
}
return setting.Value, nil
}
func (u *SettingService) Update(c *gin.Context, key, value string) error { func (u *SettingService) Update(c *gin.Context, key, value string) error {
if key == "ExpirationDays" { if key == "ExpirationDays" {
timeout, _ := strconv.Atoi(value) timeout, _ := strconv.Atoi(value)

View File

@ -16,4 +16,5 @@ const (
TmpDockerBuildDir = "/opt/1Panel/data/docker/build" TmpDockerBuildDir = "/opt/1Panel/data/docker/build"
TmpComposeBuildDir = "/opt/1Panel/data/docker/compose" TmpComposeBuildDir = "/opt/1Panel/data/docker/compose"
DaemonJsonPath = "/tmp/docker/daemon.json"
) )

View File

@ -114,10 +114,6 @@ var AddTableSetting = &gormigrate.Migration{
return err return err
} }
if err := tx.Create(&model.Setting{Key: "DaemonJsonPath", Value: "/opt/1Panel/docker/conf/daemon.json"}).Error; err != nil {
return err
}
if err := tx.Create(&model.Setting{Key: "MessageType", Value: "none"}).Error; err != nil { if err := tx.Create(&model.Setting{Key: "MessageType", Value: "none"}).Error; err != nil {
return err return err
} }

View File

@ -23,7 +23,6 @@ func (s *SettingRouter) InitSettingRouter(Router *gin.RouterGroup) {
settingRouter.POST("/time/sync", baseApi.SyncTime) settingRouter.POST("/time/sync", baseApi.SyncTime)
settingRouter.POST("/monitor/clean", baseApi.CleanMonitor) settingRouter.POST("/monitor/clean", baseApi.CleanMonitor)
settingRouter.GET("/mfa", baseApi.GetMFA) settingRouter.GET("/mfa", baseApi.GetMFA)
settingRouter.GET("/daemonjson", baseApi.GetDaemonjson)
settingRouter.POST("/mfa/bind", baseApi.MFABind) settingRouter.POST("/mfa/bind", baseApi.MFABind)
} }
} }

View File

@ -236,7 +236,6 @@ export namespace Container {
} }
export interface DaemonJsonUpdateByFile { export interface DaemonJsonUpdateByFile {
path: string;
file: string; file: string;
} }
export interface DockerOperate { export interface DockerOperate {
@ -244,6 +243,7 @@ export namespace Container {
} }
export interface DaemonJsonConf { export interface DaemonJsonConf {
status: string; status: string;
version: string;
registryMirrors: Array<string>; registryMirrors: Array<string>;
insecureRegistries: Array<string>; insecureRegistries: Array<string>;
liveRestore: boolean; liveRestore: boolean;

View File

@ -359,6 +359,7 @@ export default {
rdbInfo: 'Rule list has 0 value, please confirm and try again!', rdbInfo: 'Rule list has 0 value, please confirm and try again!',
}, },
container: { container: {
containerList: 'Container list',
operatorHelper: '{0} will be performed on the selected container. Do you want to continue?', operatorHelper: '{0} will be performed on the selected container. Do you want to continue?',
start: 'Start', start: 'Start',
stop: 'Stop', stop: 'Stop',

View File

@ -372,6 +372,7 @@ export default {
rdbInfo: '规则列表存在 0 请确认后重试', rdbInfo: '规则列表存在 0 请确认后重试',
}, },
container: { container: {
containerList: '容器列表',
operatorHelper: '将对选中容器进行 {0} 操作是否继续', operatorHelper: '将对选中容器进行 {0} 操作是否继续',
start: '启动', start: '启动',
stop: '停止', stop: '停止',

View File

@ -1,31 +1,42 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<LayoutContent :header="composeName" back-name="Compose" :reload="true"> <div class="app-content" style="margin-top: 20px">
<div v-if="createdBy === '1Panel'"> <el-card class="app-card">
<el-card> <el-row :gutter="20">
<template #header> <el-col :lg="3" :xl="2">
<div class="card-header"> <div>
<span>{{ $t('container.compose') }}</span> <el-tag effect="dark" type="success">{{ composeName }}</el-tag>
</div> </div>
</template> </el-col>
<el-button-group> <el-col :lg="8" :xl="12">
<el-button @click="onComposeOperate('start')">{{ $t('container.start') }}</el-button> <div v-if="createdBy === '1Panel'">
<el-button @click="onComposeOperate('stop')">{{ $t('container.stop') }}</el-button> <el-button link type="primary" @click="onComposeOperate('start')">
<el-button @click="onComposeOperate('down')"> {{ $t('container.start') }}
</el-button>
<el-divider direction="vertical" />
<el-button link type="primary" @click="onComposeOperate('stop')">
{{ $t('container.stop') }}
</el-button>
<el-divider direction="vertical" />
<el-button link type="primary" @click="onComposeOperate('down')">
{{ $t('container.remove') }} {{ $t('container.remove') }}
</el-button> </el-button>
</el-button-group>
</el-card>
</div> </div>
<div v-else> <div v-else>
<el-alert :closable="false" show-icon :title="$t('container.composeDetailHelper')" type="info" /> <el-alert
style="margin-top: -5px"
:closable="false"
show-icon
:title="$t('container.composeDetailHelper')"
type="info"
/>
</div>
</el-col>
</el-row>
</el-card>
</div> </div>
<el-card style="margin-top: 20px"> <el-card style="margin-top: 20px">
<template #header> <LayoutContent :header="$t('container.containerList')" back-name="Compose" :reload="true">
<div class="card-header">
<span>{{ $t('container.container') }}</span>
</div>
</template>
<ComplexTable <ComplexTable
:pagination-config="paginationConfig" :pagination-config="paginationConfig"
v-model:selects="selects" v-model:selects="selects"
@ -103,8 +114,8 @@
<CreateDialog @search="search" ref="dialogCreateRef" /> <CreateDialog @search="search" ref="dialogCreateRef" />
<MonitorDialog ref="dialogMonitorRef" /> <MonitorDialog ref="dialogMonitorRef" />
<TerminalDialog ref="dialogTerminalRef" /> <TerminalDialog ref="dialogTerminalRef" />
</el-card>
</LayoutContent> </LayoutContent>
</el-card>
</div> </div>
</template> </template>
@ -314,3 +325,18 @@ defineExpose({
acceptParams, acceptParams,
}); });
</script> </script>
<style lang="scss">
.app-card {
font-size: 14px;
height: 60px;
}
.app-content {
height: 50px;
}
body {
margin: 0;
}
</style>

View File

@ -1,6 +1,10 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<Submenu activeName="compose" /> <Submenu activeName="compose" />
<div v-show="isOnDetail">
<ComposeDetial @back="backList" ref="composeDetailRef" />
</div>
<el-card width="30%" v-if="dockerStatus != 'Running'" class="mask-prompt"> <el-card width="30%" v-if="dockerStatus != 'Running'" class="mask-prompt">
<span style="font-size: 14px">{{ $t('container.serviceUnavailable') }}</span> <span style="font-size: 14px">{{ $t('container.serviceUnavailable') }}</span>
<el-button type="primary" link style="font-size: 14px; margin-bottom: 5px" @click="goSetting"> <el-button type="primary" link style="font-size: 14px; margin-bottom: 5px" @click="goSetting">
@ -8,8 +12,8 @@
</el-button> </el-button>
<span style="font-size: 14px">{{ $t('container.startIn') }}</span> <span style="font-size: 14px">{{ $t('container.startIn') }}</span>
</el-card> </el-card>
<el-card style="margin-top: 20px" :class="{ mask: dockerStatus != 'Running' }"> <el-card v-if="!isOnDetail" style="margin-top: 20px" :class="{ mask: dockerStatus != 'Running' }">
<div v-if="!isOnDetail"> <div>
<ComplexTable <ComplexTable
:pagination-config="paginationConfig" :pagination-config="paginationConfig"
v-model:selects="selects" v-model:selects="selects"
@ -54,9 +58,6 @@
/> />
</ComplexTable> </ComplexTable>
</div> </div>
<div v-show="isOnDetail">
<ComposeDetial @back="backList" ref="composeDetailRef" />
</div>
</el-card> </el-card>
<EditDialog ref="dialogEditRef" /> <EditDialog ref="dialogEditRef" />

View File

@ -1,14 +1,33 @@
<template> <template>
<div v-loading="loading"> <div v-loading="loading">
<Submenu activeName="setting" /> <Submenu activeName="setting" />
<el-form :model="form" ref="formRef" label-width="120px"> <div class="app-content" style="margin-top: 20px">
<el-card style="margin-top: 20px"> <el-card class="app-card">
<el-row style="margin-top: 20px"> <el-row :gutter="20">
<el-col :span="1"><br /></el-col> <el-col :lg="3" :xl="2">
<el-col :span="10"> <div>
<el-form-item :label="$t('container.dockerStatus')"> <el-tag effect="dark" type="success">Docker</el-tag>
</div>
</el-col>
<el-col :lg="3" :xl="2">
<div>
{{ $t('app.version') }}:
<el-tag type="info">{{ form.version }}</el-tag>
</div>
</el-col>
<el-col :lg="3" :xl="2">
<div>
{{ $t('commons.table.status') }}:
<el-tag v-if="form.status === 'Running'" type="success">
{{ $t('commons.status.running') }}
</el-tag>
<el-tag v-if="form.status === 'Stopped'" type="info">
{{ $t('commons.status.stopped') }}
</el-tag>
</div>
</el-col>
<el-col :lg="4" :xl="6">
<div v-if="form.status === 'Running'"> <div v-if="form.status === 'Running'">
<el-tag type="success">{{ $t('commons.status.running') }}</el-tag>
<el-button type="primary" @click="onOperator('stop')" link style="margin-left: 20px"> <el-button type="primary" @click="onOperator('stop')" link style="margin-left: 20px">
{{ $t('container.stop') }} {{ $t('container.stop') }}
</el-button> </el-button>
@ -18,7 +37,6 @@
</el-button> </el-button>
</div> </div>
<div v-if="form.status === 'Stopped'"> <div v-if="form.status === 'Stopped'">
<el-tag type="info">{{ $t('commons.status.stopped') }}</el-tag>
<el-button type="primary" @click="onOperator('start')" link style="margin-left: 20px"> <el-button type="primary" @click="onOperator('start')" link style="margin-left: 20px">
{{ $t('container.start') }} {{ $t('container.start') }}
</el-button> </el-button>
@ -27,20 +45,11 @@
{{ $t('container.restart') }} {{ $t('container.restart') }}
</el-button> </el-button>
</div> </div>
</el-form-item>
<el-form-item :label="$t('container.daemonJsonPath')">
<el-input disabled v-model="daemonJsonPath">
<template #append>
<FileList @choose="loadLoadDir" :dir="false"></FileList>
</template>
</el-input>
<span class="input-help">{{ $t('container.daemonJsonPathHelper') }}</span>
<el-button type="primary" @click="savePath">{{ $t('commons.button.save') }}</el-button>
</el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-card> </el-card>
<el-card style="margin-top: 10px"> </div>
<el-card style="margin-top: 20px">
<el-radio-group v-model="confShowType" @change="changeMode"> <el-radio-group v-model="confShowType" @change="changeMode">
<el-radio-button label="base">{{ $t('database.baseConf') }}</el-radio-button> <el-radio-button label="base">{{ $t('database.baseConf') }}</el-radio-button>
<el-radio-button label="all">{{ $t('database.allConf') }}</el-radio-button> <el-radio-button label="all">{{ $t('database.allConf') }}</el-radio-button>
@ -48,6 +57,7 @@
<el-row style="margin-top: 20px" v-if="confShowType === 'base'"> <el-row style="margin-top: 20px" v-if="confShowType === 'base'">
<el-col :span="1"><br /></el-col> <el-col :span="1"><br /></el-col>
<el-col :span="10"> <el-col :span="10">
<el-form :model="form" ref="formRef" label-width="120px">
<el-form-item :label="$t('container.mirrors')" prop="mirrors"> <el-form-item :label="$t('container.mirrors')" prop="mirrors">
<el-input <el-input
type="textarea" type="textarea"
@ -80,6 +90,7 @@
{{ $t('commons.button.save') }} {{ $t('commons.button.save') }}
</el-button> </el-button>
</el-form-item> </el-form-item>
</el-form>
</el-col> </el-col>
</el-row> </el-row>
@ -103,7 +114,6 @@
</el-button> </el-button>
</div> </div>
</el-card> </el-card>
</el-form>
<ConfirmDialog ref="confirmDialogRef" @confirm="onSubmitSave"></ConfirmDialog> <ConfirmDialog ref="confirmDialogRef" @confirm="onSubmitSave"></ConfirmDialog>
</div> </div>
@ -111,7 +121,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ElMessage, FormInstance } from 'element-plus'; import { ElMessage, FormInstance } from 'element-plus';
import FileList from '@/components/file-list/index.vue';
import { onMounted, reactive, ref } from 'vue'; import { onMounted, reactive, ref } from 'vue';
import Submenu from '@/views/container/index.vue'; import Submenu from '@/views/container/index.vue';
import { Codemirror } from 'vue-codemirror'; import { Codemirror } from 'vue-codemirror';
@ -121,20 +130,15 @@ import { LoadFile } from '@/api/modules/files';
import ConfirmDialog from '@/components/confirm-dialog/index.vue'; import ConfirmDialog from '@/components/confirm-dialog/index.vue';
import i18n from '@/lang'; import i18n from '@/lang';
import { dockerOperate, loadDaemonJson, updateDaemonJson, updateDaemonJsonByfile } from '@/api/modules/container'; import { dockerOperate, loadDaemonJson, updateDaemonJson, updateDaemonJsonByfile } from '@/api/modules/container';
import { loadDaemonJsonPath, updateSetting } from '@/api/modules/setting';
const loading = ref(false); const loading = ref(false);
const extensions = [javascript(), oneDark]; const extensions = [javascript(), oneDark];
const confShowType = ref('base'); const confShowType = ref('base');
const daemonJsonPath = ref();
const loadLoadDir = async (path: string) => {
daemonJsonPath.value = path;
};
const form = reactive({ const form = reactive({
status: '', status: '',
version: '',
mirrors: '', mirrors: '',
registries: '', registries: '',
liveRestore: false, liveRestore: false,
@ -177,22 +181,9 @@ const onOperator = async (operation: string) => {
ElMessage.success(i18n.global.t('commons.msg.operationSuccess')); ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
}; };
const savePath = async () => {
let param = {
key: 'DaemonJsonPath',
value: daemonJsonPath.value,
};
await updateSetting(param);
changeMode();
ElMessage.success(i18n.global.t('commons.msg.operationSuccess'));
};
const onSubmitSave = async () => { const onSubmitSave = async () => {
if (confShowType.value === 'all') { if (confShowType.value === 'all') {
let param = { let param = { file: dockerConf.value };
file: dockerConf.value,
path: daemonJsonPath.value,
};
loading.value = true; loading.value = true;
await updateDaemonJsonByfile(param) await updateDaemonJsonByfile(param)
.then(() => { .then(() => {
@ -208,6 +199,7 @@ const onSubmitSave = async () => {
let itemRegistries = form.registries.split('\n'); let itemRegistries = form.registries.split('\n');
let param = { let param = {
status: form.status, status: form.status,
version: '',
registryMirrors: itemMirrors.filter(function (el) { registryMirrors: itemMirrors.filter(function (el) {
return el !== null && el !== '' && el !== undefined; return el !== null && el !== '' && el !== undefined;
}), }),
@ -229,19 +221,14 @@ const onSubmitSave = async () => {
}); });
}; };
const loadMysqlConf = async () => { const loadDockerConf = async () => {
const res = await LoadFile({ path: daemonJsonPath.value }); const res = await LoadFile({ path: '/etc/docker/daemon.json' });
dockerConf.value = res.data; dockerConf.value = res.data;
}; };
const loadPath = async () => {
const res = await loadDaemonJsonPath();
daemonJsonPath.value = res.data;
};
const changeMode = async () => { const changeMode = async () => {
if (confShowType.value === 'all') { if (confShowType.value === 'all') {
loadMysqlConf(); loadDockerConf();
} else { } else {
search(); search();
} }
@ -250,6 +237,7 @@ const changeMode = async () => {
const search = async () => { const search = async () => {
const res = await loadDaemonJson(); const res = await loadDaemonJson();
form.status = res.data.status; form.status = res.data.status;
form.version = res.data.version;
form.cgroupDriver = res.data.cgroupDriver; form.cgroupDriver = res.data.cgroupDriver;
form.liveRestore = res.data.liveRestore; form.liveRestore = res.data.liveRestore;
form.mirrors = res.data.registryMirrors ? res.data.registryMirrors.join('\n') : ''; form.mirrors = res.data.registryMirrors ? res.data.registryMirrors.join('\n') : '';
@ -257,7 +245,21 @@ const search = async () => {
}; };
onMounted(() => { onMounted(() => {
loadPath();
search(); search();
}); });
</script> </script>
<style lang="scss">
.app-card {
font-size: 14px;
height: 60px;
}
.app-content {
height: 50px;
}
body {
margin: 0;
}
</style>