1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

fix: 修复日志文件下载不全的问题 (#2313)

This commit is contained in:
zhengkunwang 2023-09-15 18:02:16 +08:00 committed by GitHub
parent 4e7350aaae
commit a3bf4513e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 11 deletions

View File

@ -42,6 +42,7 @@ type WebsiteLog struct {
Enable bool `json:"enable"` Enable bool `json:"enable"`
Content string `json:"content"` Content string `json:"content"`
End bool `json:"end"` End bool `json:"end"`
Path string `json:"path"`
} }
type PHPConfig struct { type PHPConfig struct {

View File

@ -941,6 +941,7 @@ func (w WebsiteService) OpWebsiteLog(req request.WebsiteLogReq) (*response.Websi
return nil, err return nil, err
} }
res.End = end res.End = end
res.Path = filePath
res.Content = strings.Join(lines, "\n") res.Content = strings.Join(lines, "\n")
return res, nil return res, nil
case constant.DisableLog: case constant.DisableLog:

View File

@ -90,6 +90,7 @@ export namespace Website {
enable: boolean; enable: boolean;
content: string; content: string;
end: boolean; end: boolean;
path: string;
} }
export interface Domain { export interface Domain {

View File

@ -4,19 +4,14 @@
<el-form-item :label="$t('website.enable')"> <el-form-item :label="$t('website.enable')">
<el-switch v-model="data.enable" @change="updateEnable"></el-switch> <el-switch v-model="data.enable" @change="updateEnable"></el-switch>
</el-form-item> </el-form-item>
<div style="margin-top: 10px"> <div class="mt-2.5">
<el-checkbox border v-model="tailLog" style="float: left" @change="changeTail"> <el-checkbox border v-model="tailLog" class="float-left" @change="changeTail">
{{ $t('commons.button.watch') }} {{ $t('commons.button.watch') }}
</el-checkbox> </el-checkbox>
<el-button <el-button class="ml-5" @click="onDownload" icon="Download" :disabled="data.content === ''">
style="margin-left: 20px"
@click="onDownload"
icon="Download"
:disabled="data.content === ''"
>
{{ $t('file.download') }} {{ $t('file.download') }}
</el-button> </el-button>
<el-button style="margin-left: 20px" @click="cleanLog" icon="Delete" :disabled="data.content === ''"> <el-button class="ml-5" @click="cleanLog" icon="Delete" :disabled="data.content === ''">
{{ $t('commons.button.clean') }} {{ $t('commons.button.clean') }}
</el-button> </el-button>
</div> </div>
@ -46,8 +41,8 @@ import { javascript } from '@codemirror/lang-javascript';
import { oneDark } from '@codemirror/theme-one-dark'; import { oneDark } from '@codemirror/theme-one-dark';
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, shallowRef } from 'vue'; import { computed, nextTick, onMounted, onUnmounted, reactive, ref, shallowRef } from 'vue';
import { OpWebsiteLog } from '@/api/modules/website'; import { OpWebsiteLog } from '@/api/modules/website';
import { dateFormatForName, downloadWithContent } from '@/utils/util';
import { useDeleteData } from '@/hooks/use-delete-data'; import { useDeleteData } from '@/hooks/use-delete-data';
import { downloadFile } from '@/utils/util';
const extensions = [javascript(), oneDark]; const extensions = [javascript(), oneDark];
const props = defineProps({ const props = defineProps({
@ -70,6 +65,7 @@ const loading = ref(false);
const data = ref({ const data = ref({
enable: false, enable: false,
content: '', content: '',
path: '',
}); });
const tailLog = ref(false); const tailLog = ref(false);
let timer: NodeJS.Timer | null = null; let timer: NodeJS.Timer | null = null;
@ -165,7 +161,7 @@ const cleanLog = async () => {
}; };
const onDownload = async () => { const onDownload = async () => {
downloadWithContent(data.value.content, logType.value + '-' + dateFormatForName(new Date()) + '.log'); downloadFile(data.value.path);
}; };
const onCloseLog = async () => { const onCloseLog = async () => {