Browse Source

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

pull/2315/head
zhengkunwang 1 year ago committed by GitHub
parent
commit
a3bf4513e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      backend/app/dto/response/website.go
  2. 1
      backend/app/service/website.go
  3. 1
      frontend/src/api/interface/website.ts
  4. 18
      frontend/src/views/website/website/config/log/log-fiile/index.vue

1
backend/app/dto/response/website.go

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

1
backend/app/service/website.go

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

1
frontend/src/api/interface/website.ts

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

18
frontend/src/views/website/website/config/log/log-fiile/index.vue

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

Loading…
Cancel
Save