✨ 打开外部日志的功能
This commit is contained in:
parent
5ac69de59a
commit
6c4a052bf6
@ -1,4 +1,4 @@
|
|||||||
import { app, ipcMain } from "electron";
|
import { app, ipcMain, shell } from "electron";
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
@ -28,4 +28,17 @@ export const initLoggerApi = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.on("logger.openLog", (event, args) => {
|
||||||
|
console.log('正在打开日志');
|
||||||
|
shell.openPath(logPath).then((errorMessage) => {
|
||||||
|
if (errorMessage) {
|
||||||
|
console.error('Failed to open Logger:', errorMessage);
|
||||||
|
event.reply("Logger.openLog.hook", false);
|
||||||
|
} else {
|
||||||
|
console.log('Logger opened successfully');
|
||||||
|
event.reply("Logger.openLog.hook", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
import {addIcon} from "@iconify/vue/dist/offline";
|
import {addIcon} from "@iconify/vue/dist/offline";
|
||||||
|
|
||||||
/**
|
|
||||||
* 这里存放本地图标,在 src/layout/index.vue 文件中加载,避免在首启动加载
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 本地菜单图标,后端在路由的icon中返回对应的图标字符串并且前端在此处使用addIcon添加即可渲染菜单图标
|
|
||||||
import Cloud from "@iconify-icons/material-symbols/cloud";
|
import Cloud from "@iconify-icons/material-symbols/cloud";
|
||||||
import RocketLaunchRounded from "@iconify-icons/material-symbols/rocket-launch-rounded";
|
import RocketLaunchRounded from "@iconify-icons/material-symbols/rocket-launch-rounded";
|
||||||
import Download from "@iconify-icons/material-symbols/download-2";
|
import Download from "@iconify-icons/material-symbols/download-2";
|
||||||
@ -36,6 +31,7 @@ import deviceReset from "@iconify-icons/material-symbols/device-reset";
|
|||||||
import switchAccessOutlineRounded from "@iconify-icons/material-symbols/switch-access-outline-rounded";
|
import switchAccessOutlineRounded from "@iconify-icons/material-symbols/switch-access-outline-rounded";
|
||||||
import switchAccessRounded from "@iconify-icons/material-symbols/switch-access-rounded";
|
import switchAccessRounded from "@iconify-icons/material-symbols/switch-access-rounded";
|
||||||
import chargerRounded from "@iconify-icons/material-symbols/charger-rounded";
|
import chargerRounded from "@iconify-icons/material-symbols/charger-rounded";
|
||||||
|
import fileOpenRounded from "@iconify-icons/material-symbols/file-open-rounded";
|
||||||
|
|
||||||
addIcon("cloud", Cloud);
|
addIcon("cloud", Cloud);
|
||||||
addIcon("rocket-launch-rounded", RocketLaunchRounded);
|
addIcon("rocket-launch-rounded", RocketLaunchRounded);
|
||||||
@ -67,5 +63,6 @@ addIcon("downloadRounded", downloadRounded);
|
|||||||
addIcon("deviceReset", deviceReset);
|
addIcon("deviceReset", deviceReset);
|
||||||
addIcon("switchAccessOutlineRounded", switchAccessOutlineRounded);
|
addIcon("switchAccessOutlineRounded", switchAccessOutlineRounded);
|
||||||
addIcon("switchAccessRounded", switchAccessRounded);
|
addIcon("switchAccessRounded", switchAccessRounded);
|
||||||
|
addIcon("file-open-rounded", fileOpenRounded);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {defineComponent, onMounted, onUnmounted, ref} from "vue";
|
import { defineComponent, onMounted, onUnmounted, ref } from "vue";
|
||||||
import Breadcrumb from "@/layout/compoenets/Breadcrumb.vue";
|
import Breadcrumb from "@/layout/compoenets/Breadcrumb.vue";
|
||||||
import {ipcRenderer} from "electron";
|
import { ipcRenderer } from "electron";
|
||||||
|
import IconifyIconOffline from "@/components/IconifyIcon/src/iconifyIconOffline";
|
||||||
|
import { useDebounce, useDebounceFn } from "@vueuse/core";
|
||||||
|
import { ElMessage } from "element-plus";
|
||||||
|
|
||||||
defineComponent({
|
defineComponent({
|
||||||
name: "Logger"
|
name: "Logger"
|
||||||
@ -46,15 +49,33 @@ onMounted(() => {
|
|||||||
loggerContent.value = handleLog2Html(args);
|
loggerContent.value = handleLog2Html(args);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on("Logger.openLog.hook", (event, args) => {
|
||||||
|
if (args) {
|
||||||
|
ElMessage({
|
||||||
|
type: "success",
|
||||||
|
message: "打开日志成功"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const openLocalLog = useDebounceFn(() => {
|
||||||
|
console.log('打开啊日志');
|
||||||
|
ipcRenderer.send("logger.openLog");
|
||||||
|
}, 300);
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
ipcRenderer.removeAllListeners("Logger.getLog.hook");
|
ipcRenderer.removeAllListeners("Logger.getLog.hook");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<breadcrumb />
|
<breadcrumb>
|
||||||
|
<el-button plain type="primary" @click="openLocalLog">
|
||||||
|
<IconifyIconOffline icon="file-open-rounded" />
|
||||||
|
</el-button>
|
||||||
|
</breadcrumb>
|
||||||
<div class="app-container-breadcrumb">
|
<div class="app-container-breadcrumb">
|
||||||
<div
|
<div
|
||||||
class="w-full h-full p-2 bg-[#2B2B2B] rounded drop-shadow-lg overflow-y-auto"
|
class="w-full h-full p-2 bg-[#2B2B2B] rounded drop-shadow-lg overflow-y-auto"
|
||||||
|
Loading…
Reference in New Issue
Block a user