Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

fix: impede que o botão de exportação apareça quando não há o que exportar #264

Merged
merged 2 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions browser/events/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,30 @@ export function setDevEvents(isDev: boolean) {
if (!isDev) return;

// A callback desse evento varia conforme o que está sendo testado no momento.
ipcRenderer.on('its-dev-magic', () => {
ipcRenderer.on('dev:magic', () => {
console.log('It\'s dev magic!');

const previous = document.querySelector('#bot_check[ares="test"]');
if (previous) {
previous.remove();
} else {
const botCheck = document.createElement('div');
botCheck.setAttribute('id', 'bot_check');
botCheck.setAttribute('ares', 'test');

const content = document.queryAndAssert('table#contentContainer');
content.appendChild(botCheck);
};
mockRendererProcessError();
});

ipcRenderer.on('emit-mock-error', () => {
const err = new RendererProcessError('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
RendererProcessError.catch(err);
});
ipcRenderer.on('dev:mock-captcha', () => mockCaptcha());
ipcRenderer.on('dev:mock-error', () => mockRendererProcessError());
};

function mockCaptcha(): void {
const previous = document.querySelector('#bot_check[ares="test"]');
if (previous) {
previous.remove();
} else {
const botCheck = document.createElement('div');
botCheck.setAttribute('id', 'bot_check');
botCheck.setAttribute('ares', 'test');

const content = document.queryAndAssert('table#contentContainer');
content.appendChild(botCheck);
};
};

function mockRendererProcessError(): void {
const err = new RendererProcessError('Lorem ipsum dolor sit amet, consectetur adipiscing elit.');
RendererProcessError.catch(err);
};
2 changes: 1 addition & 1 deletion electron/menu/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ export function setModuleDevMenu(browserWindow: Electron.BrowserWindow) {
function castDevMagic() {
const allWebContents = webContents.getAllWebContents();
for (const contents of allWebContents) {
contents.send('its-dev-magic');
contents.send('dev:magic');
};
};
35 changes: 0 additions & 35 deletions modules/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,11 @@ html {
overflow: hidden;
}

.module-nav-bar {
height: 30px;
padding-left: 0.5em;
padding-right: 0.5em;
user-select: none;
}

@mixin module-tabbed-view-wrapper($margin-bottom: 0) {
position: absolute;
top: 30px;
bottom: 0;
width: 100%;
padding-left: 0.3em;
margin-top: 0.5em;
overflow: hidden;
user-select: none;

@if $margin-bottom > 0 {
margin-bottom: $margin-bottom;
}
}

.module-view {
height: 100%;
width: 100%;
overflow-x: hidden;
overflow-y: auto;
user-select: none;
}

.config-divider {
margin-top: 1em !important;
margin-bottom: 0.5em !important;
}

.config-divider:first-of-type {
margin-top: 0.3em !important;
}

.error-log {
margin-bottom: 0.5em;
user-select: text;
}
2 changes: 1 addition & 1 deletion modules/components/ConfigPlunderGridAttack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const props = defineProps<{
}>();

const emit = defineEmits<{
<T extends keyof PlunderConfigType>(event: 'update:config', name: T, value: PlunderConfigType[T]): void;
<T extends keyof PlunderConfigType>(e: 'update:config', name: T, value: PlunderConfigType[T]): void;
}>();

const maxDistance = ref<number>(props.config.maxDistance);
Expand Down
2 changes: 1 addition & 1 deletion modules/components/ConfigPlunderGridGroups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const props = defineProps<{
}>();

const emit = defineEmits<{
<T extends keyof PlunderConfigType>(event: 'update:config', name: T, value: PlunderConfigType[T]): void;
<T extends keyof PlunderConfigType>(e: 'update:config', name: T, value: PlunderConfigType[T]): void;
}>();

const previousGroups = await ipcInvoke('get-village-groups');
Expand Down
2 changes: 1 addition & 1 deletion modules/components/ConfigPlunderGridOthers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const props = defineProps<{
}>();

const emit = defineEmits<{
<T extends keyof PlunderConfigType>(event: 'update:config', name: T, value: PlunderConfigType[T]): void;
<T extends keyof PlunderConfigType>(e: 'update:config', name: T, value: PlunderConfigType[T]): void;
}>();

const minutesUntilReload = ref<number>(props.config.minutesUntilReload);
Expand Down
2 changes: 1 addition & 1 deletion modules/components/ConfigPlunderGridTemplateC.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const props = defineProps<{
}>();

const emit = defineEmits<{
<T extends keyof PlunderConfigType>(event: 'update:config', name: T, value: PlunderConfigType[T]): void;
<T extends keyof PlunderConfigType>(e: 'update:config', name: T, value: PlunderConfigType[T]): void;
}>();

const useCPattern = ref<UseCPattern>(props.config.useCPattern);
Expand Down
2 changes: 1 addition & 1 deletion modules/components/ConfigPlunderGridWall.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const props = defineProps<{
}>();

const emit = defineEmits<{
<T extends keyof PlunderConfigType>(event: 'update:config', name: T, value: PlunderConfigType[T]): void;
<T extends keyof PlunderConfigType>(e: 'update:config', name: T, value: PlunderConfigType[T]): void;
}>();

const dialog = useDialog();
Expand Down
32 changes: 0 additions & 32 deletions modules/components/ErrorLogElectron.vue

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import { NButton, useMessage } from 'naive-ui';
import { ipcInvoke } from '$renderer/ipc';

defineProps<{
buttonTop: string;
top: string;
}>();

const emit = defineEmits<{
(e: 'export'): void;
}>();

const message = useMessage();
Expand All @@ -15,6 +19,7 @@ async function exportLog() {
const status = await ipcInvoke('error:export');
if (status === 'sucess') {
message.success('Tudo certo!');
emit('export');
} else if (status === 'error') {
message.error('Erro ao exportar o registro de erros.');
};
Expand All @@ -24,17 +29,17 @@ async function exportLog() {
</script>

<template>
<div class="btn-error-export">
<div class="error-log-button-area">
<NButton :loading="loading" :disabled="loading" @click="exportLog">
Exportar
</NButton>
</div>
</template>

<style scoped lang="scss">
.btn-error-export {
.error-log-button-area {
position: absolute;
top: v-bind("buttonTop");
top: v-bind("top");
bottom: 0;
display: flex;
justify-content: center;
Expand Down
32 changes: 0 additions & 32 deletions modules/components/ErrorLogGeneral.vue

This file was deleted.

21 changes: 0 additions & 21 deletions modules/router/error.ts

This file was deleted.

13 changes: 7 additions & 6 deletions modules/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createRouter, createMemoryHistory } from 'vue-router';
import { getRouteNames, getChildrenRoutes } from '$renderer/utils/router';
import { errorRoutes } from '$modules/router/error';
import { configRoutes } from '$modules/router/config';
import DefaultView from '$renderer/views/DefaultView.vue';
import AppUpdateView from '$modules/views/AppUpdateView.vue';
import DemolitionView from '$modules/views/DemolitionView.vue';
import ErrorLogView from '$modules/views/ErrorLogView.vue';
import PlunderHistory from '$modules/views/PlunderHistoryView.vue';
import PlunderTemplateView from '$modules/views/PlunderTemplateView.vue';

Expand All @@ -27,6 +27,11 @@ const singleRoutes: ModuleRouteRecordRaw[] = [
name: 'demolition',
component: DemolitionView
},
{
path: '/error-log',
name: 'error-log',
component: ErrorLogView
},
{
path: '/plunder-history',
name: 'plunder-history',
Expand All @@ -39,11 +44,7 @@ const singleRoutes: ModuleRouteRecordRaw[] = [
}
];

const routes: ModuleRouteRecordRaw[] = [
...singleRoutes,
configRoutes,
errorRoutes
];
const routes: ModuleRouteRecordRaw[] = [...singleRoutes, configRoutes];

export const router = createRouter({
history: createMemoryHistory(),
Expand Down
37 changes: 29 additions & 8 deletions modules/views/ConfigView.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<script setup lang="ts">
import { ref, watch, nextTick, onMounted } from 'vue';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
import { RouterView } from 'vue-router';
import { syncRef, useArrayIncludes } from '@vueuse/core';
import { syncRef, useArrayIncludes, useElementSize, useWindowSize } from '@vueuse/core';
import { NTabs, NTab, type TabsInst } from 'naive-ui';
import { configRouteNames, router } from '$modules/router';

const tabs = ref<TabsInst | null>(null);
const tabName = ref<ConfigModuleRoutes>('config-general');
watch(tabName, (name) => router.push({ name }));

const navBar = ref<HTMLElement | null>(null);
const { height: navBarHeight } = useElementSize(navBar, { width: 0, height: 0 }, { box: 'border-box' });

const { height: windowHeight } = useWindowSize();
const viewHeight = computed(() => `${windowHeight.value - navBarHeight.value}px`);

const currentRouteName = ref<string | null>(null);
syncRef(router.currentRoute, currentRouteName, {
deep: true,
Expand All @@ -31,7 +37,7 @@ onMounted(async () => {
</script>

<template>
<nav class="module-nav-bar">
<nav ref="navBar" class="config-nav-bar">
<NTabs
ref="tabs"
v-model:value="tabName"
Expand All @@ -47,8 +53,8 @@ onMounted(async () => {
</NTabs>
</nav>

<div class="module-tabbed-view-wrapper">
<RouterView #default="{ Component }" class="module-view tb-scrollbar">
<div class="config-view-wrapper tb-scrollbar">
<RouterView #default="{ Component }">
<template v-if="Component">
<Transition name="tb-fade" mode="out-in">
<KeepAlive>
Expand All @@ -66,9 +72,24 @@ onMounted(async () => {
</template>

<style scoped lang="scss">
@use '$modules/assets/main.scss';
.config-nav-bar {
height: 30px;
padding-left: 0.5em;
padding-right: 0.5em;
user-select: none;
}

.module-tabbed-view-wrapper {
@include main.module-tabbed-view-wrapper;
.config-view-wrapper {
position: absolute;
top: 30px;
bottom: 0;
width: 100%;
height: v-bind("viewHeight");
overflow-x: hidden;
overflow-y: auto;
user-select: none;
padding-left: 0.3em;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
</style>
Loading