mirror of https://github.com/halo-dev/halo-admin
feat: add supports for download log file in actuator page (#867)
#### What type of PR is this? /kind feature #### What this PR does / why we need it: 在系统概览页面支持下载运行日志。 #### Which issue(s) this PR fixes: Fixes https://github.com/halo-dev/halo/issues/3188 #### Screenshots: <img width="1676" alt="image" src="https://user-images.githubusercontent.com/21301288/220023373-44616cd3-b42a-466a-a928-9abce78cc16d.png"> #### Special notes for your reviewer: 测试方式: 1. 进入系统概览页面,点击运行日志的下载按钮。 2. 检查是否成功下载了日志文件。 #### Does this PR introduce a user-facing change? ```release-note Console 端的系统概览页面支持下载运行日志。 ```pull/866/head^2
parent
2705fc35d0
commit
7b3007ec9f
|
@ -85,6 +85,28 @@ const handleCopy = () => {
|
|||
|
||||
Toast.success("复制成功");
|
||||
};
|
||||
|
||||
const handleDownloadLogfile = () => {
|
||||
axios
|
||||
.get(`${import.meta.env.VITE_API_URL}/actuator/logfile`)
|
||||
.then((response) => {
|
||||
const blob = new Blob([response.data]);
|
||||
const downloadElement = document.createElement("a");
|
||||
const href = window.URL.createObjectURL(blob);
|
||||
downloadElement.href = href;
|
||||
downloadElement.download = `halo-log-${formatDatetime(new Date())}.log`;
|
||||
document.body.appendChild(downloadElement);
|
||||
downloadElement.click();
|
||||
document.body.removeChild(downloadElement);
|
||||
window.URL.revokeObjectURL(href);
|
||||
|
||||
Toast.success("下载成功");
|
||||
})
|
||||
.catch((e) => {
|
||||
Toast.error("下载失败");
|
||||
console.log("Failed to download log file.", e);
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -233,6 +255,16 @@ const handleCopy = () => {
|
|||
{{ info.os.name }} {{ info.os.version }} / {{ info.os.arch }}
|
||||
</dd>
|
||||
</div>
|
||||
<div
|
||||
class="items-center bg-white px-4 py-5 hover:bg-gray-50 sm:grid sm:grid-cols-6 sm:gap-4 sm:px-6"
|
||||
>
|
||||
<dt class="text-sm font-medium text-gray-900">运行日志</dt>
|
||||
<dd class="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
|
||||
<VButton size="sm" @click="handleDownloadLogfile()">
|
||||
下载
|
||||
</VButton>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue