From 471a1565d33b735fbf2a4016ed0b99f64306dfc0 Mon Sep 17 00:00:00 2001 From: luanfreitasdev Date: Fri, 29 Nov 2024 11:37:50 -0300 Subject: [PATCH 1/6] WIP --- src/main/main.ts | 5 +- src/renderer/App.vue | 2 +- src/renderer/components/CodeSnippet.vue | 188 ++++++++++++++++++ src/renderer/components/DumpItem.vue | 21 +- src/renderer/components/DumpLink.vue | 86 +++++--- src/renderer/components/DumpLog.vue | 26 ++- src/renderer/components/DumpScreens.vue | 2 +- .../components/HeaderColorsFilter.vue | 4 +- src/renderer/components/Icons/IconPencil.vue | 16 ++ src/renderer/components/NavBarCollapse.vue | 2 +- src/renderer/components/TheNavBar.vue | 2 +- src/renderer/styles.css | 8 + src/renderer/types/Payload.ts | 8 +- 13 files changed, 320 insertions(+), 50 deletions(-) create mode 100644 src/renderer/components/CodeSnippet.vue create mode 100644 src/renderer/components/Icons/IconPencil.vue diff --git a/src/main/main.ts b/src/main/main.ts index 465975f..ec9ecaf 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -45,7 +45,7 @@ function createWindow(): BrowserWindow { const browserWindowOptions: BrowserWindowConstructorOptions = { fullscreen: false, fullscreenable: false, - width: isDev ? 1080 : 650, + width: isDev ? 1080 : 690, height: 640, resizable: true, alwaysOnTop: false, @@ -64,7 +64,8 @@ function createWindow(): BrowserWindow { } if (isMac) { - browserWindowOptions.titleBarStyle = "hidden"; + browserWindowOptions.titleBarStyle = "hiddenInset"; + browserWindowOptions.trafficLightPosition = { x: 12, y: 11 }; } const win: BrowserWindow = new BrowserWindow(browserWindowOptions); diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 6e059da..c0684ec 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -600,7 +600,6 @@ const dispatch = (type: string, event: EventType, content: any): void => { const serializablePayload = JSON.parse(JSON.stringify(payload.value.filter((payload: Payload) => payload.screen?.screen_name === content.screen.screen_name))); - console.log(payload); if (content.screen.new_window) { screenStore.hidden(content.screen.screen_name); @@ -789,6 +788,7 @@ function registerDefaultLocalShortcuts() { }" >
+import { computed, defineProps, ref } from "vue"; +import { Payload } from "@/types/Payload"; +import hljs from "highlight.js/lib/core"; +import DumpLink from "@/components/DumpLink.vue"; + +const props = defineProps<{ + payload: Payload; +}>(); + +const activeFileIndex = ref(0); + +const toggleFileVisibility = (index: number) => { + activeFileIndex.value = activeFileIndex.value === index ? null : index; +}; + +const getFileLineDisplay = (codeSnippet: any) => { + return `${codeSnippet.route} ${codeSnippet.line}`; +}; + +const getLineContent = (lineContent: string) => { + return hljs.highlight(lineContent, { language: "php" }).value; +}; + +const containerSize = ref(0); +const observeContainer = (id: string) => { + const element = document.getElementById(id); + if (element) { + const resizeObserver = new ResizeObserver((entries) => { + for (const entry of entries) { + containerSize.value = entry.contentRect.width; + } + }); + resizeObserver.observe(element); + } +}; + +const containerWidth = computed(() => containerSize.value - 58 + "px"); + +observeContainer("dumps-base"); + + + + diff --git a/src/renderer/components/DumpItem.vue b/src/renderer/components/DumpItem.vue index 9e9754a..a68ed2b 100644 --- a/src/renderer/components/DumpItem.vue +++ b/src/renderer/components/DumpItem.vue @@ -116,22 +116,21 @@ const isDuplicated = (sql) => { const badgeClasses = computed(() => { const { label, color } = props.payload; - const baseClass = - "badge font-medium text-xs text-neutral-content bg-neutral border border-neutral-content/20 shadow-lg rounded-box w-auto"; + const baseClass = "badge font-medium text-xs text-neutral-content bg-neutral border border-neutral-content/20 shadow-lg rounded-box w-auto"; const dynamicClass = { - '!bg-error !text-error-content': ['error', 'emergency'].includes(label) || color === 'red', - '!bg-info !text-info-content': label === 'info' || color === 'blue', - '!bg-warning !text-warning-content': label === 'warning' || color === 'orange', - '!bg-gray-400! text-warning-content': label === 'debug', - '!bg-success !text-success-content': color === 'green', - '!bg-black': color === 'black', + "!bg-error !text-error-content": ["error", "emergency"].includes(label) || color === "red", + "!bg-info !text-info-content": label === "info" || color === "blue", + "!bg-warning !text-warning-content": label === "warning" || color === "orange", + "!bg-gray-400! text-warning-content": label === "debug", + "!bg-success !text-success-content": color === "green", + "!bg-black": color === "black" }; const additionalClasses = Object.entries(dynamicClass) .filter(([_, condition]) => condition) .map(([className]) => className) - .join(' '); + .join(" "); return `${baseClass} ${additionalClasses}`; }); @@ -149,6 +148,7 @@ watch(collapseStore, (value) => { [bgColor]: typeof bgColor !== 'undefined', 'collapse-open': open }" + id="" class="collapse bg-base-200/70 bg-laravel border border-base-content/5" >
{
+ :class="badgeClasses" + > {{ props.payload.label ?? props.payload.type }}
diff --git a/src/renderer/components/DumpLink.vue b/src/renderer/components/DumpLink.vue index b876d36..23f6276 100644 --- a/src/renderer/components/DumpLink.vue +++ b/src/renderer/components/DumpLink.vue @@ -2,11 +2,28 @@ import { computed, defineProps, onMounted, ref, watch } from "vue"; import { useIDEHandlerStore } from "@/store/ide-handler"; import { IdeHandle } from "@/types/IdeHandle"; +import IconPencil from "@/components/Icons/IconPencil.vue"; + +const props = defineProps<{ + ideHandler?: IdeHandle; + label?: string; + showIcon: boolean; +}>(); const IDEHandler = useIDEHandlerStore(); const link = ref(); +onMounted(() => { + generateLink(IDEHandler.value); +}); + +watch(IDEHandler.value, (value) => { + const ide = value; + + generateLink(ide); +}); + const generateLink = (ide: string) => { const projectPath = props.ideHandler.project_path; const realPath = props.ideHandler.real_path; @@ -17,11 +34,13 @@ const generateLink = (ide: string) => { const linkPath = projectPath + relativePath; + console.log(realPath); if (realPath != null) { if (IDEHandler.value.includes("wsl_config")) { if (wsl_config != undefined) { link.value = ide.replace("{wsl_config}", wsl_config).replace("{filepath}", linkPath).replace("{line}", props.ideHandler.line); + console.log(link.value); return; } @@ -29,15 +48,16 @@ const generateLink = (ide: string) => { return; } + link.value = ide.replace("{filepath}", linkPath).replace("{line}", props.ideHandler.line); } }; -onMounted(() => { - generateLink(IDEHandler.value ?? "phpstorm://open?file={filepath}&line={line}"); -}); - const label = computed(() => { + if (props.label) { + return props.label; + } + if (props.ideHandler.line?.toString() !== "") { return props.ideHandler.class_name + ":" + props.ideHandler.line; } @@ -48,27 +68,45 @@ const label = computed(() => { return ""; }); - -const props = defineProps<{ - ideHandler: IdeHandle; -}>(); - -watch(IDEHandler, (value) => { - const ide = value.value; - - generateLink(ide); -}); diff --git a/src/renderer/components/DumpLog.vue b/src/renderer/components/DumpLog.vue index 2bc10d8..8fb9a87 100644 --- a/src/renderer/components/DumpLog.vue +++ b/src/renderer/components/DumpLog.vue @@ -1,27 +1,39 @@ diff --git a/src/renderer/components/DumpScreens.vue b/src/renderer/components/DumpScreens.vue index fa3a073..806a0b7 100644 --- a/src/renderer/components/DumpScreens.vue +++ b/src/renderer/components/DumpScreens.vue @@ -1,5 +1,5 @@ diff --git a/src/renderer/components/NavBarCollapse.vue b/src/renderer/components/NavBarCollapse.vue index 337c176..8a76002 100644 --- a/src/renderer/components/NavBarCollapse.vue +++ b/src/renderer/components/NavBarCollapse.vue @@ -9,7 +9,7 @@ const collapseStore = useCollapse();