2024-04-13 08:32:42 +08:00
|
|
|
<script setup lang="ts">
|
2024-04-13 09:53:41 +08:00
|
|
|
import Sidebar from "./components/Sidebar.vue";
|
|
|
|
import Header from "./components/Header.vue";
|
|
|
|
import {
|
|
|
|
darkTheme,
|
|
|
|
NConfigProvider,
|
|
|
|
NMessageProvider,
|
|
|
|
NDialogProvider,
|
|
|
|
} from "naive-ui";
|
2024-04-26 23:07:26 +08:00
|
|
|
import { Store } from "@tauri-apps/plugin-store";
|
|
|
|
import { getCurrent } from "@tauri-apps/api/window";
|
|
|
|
import { KeyMappingConfig } from "./keyMappingConfig";
|
|
|
|
import { onMounted } from "vue";
|
|
|
|
import { useGlobalStore } from "./store/global";
|
|
|
|
|
|
|
|
const store = useGlobalStore();
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
// loading keyMappingConfigList from local store
|
|
|
|
const localStore = new Store("store.bin");
|
|
|
|
let keyMappingConfigList: KeyMappingConfig[] | null = await localStore.get(
|
|
|
|
"keyMappingConfigList"
|
|
|
|
);
|
|
|
|
if (keyMappingConfigList === null || keyMappingConfigList.length === 0) {
|
|
|
|
keyMappingConfigList = [
|
|
|
|
{
|
|
|
|
relativeSize: await calMaskSize(),
|
|
|
|
title: "空白方案",
|
|
|
|
list: [],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
store.keyMappingConfigList = keyMappingConfigList;
|
|
|
|
});
|
|
|
|
|
|
|
|
async function calMaskSize() {
|
|
|
|
const appWindow = getCurrent();
|
|
|
|
const ml = 70;
|
|
|
|
const mt = 30;
|
|
|
|
let size = (await appWindow.outerSize()).toLogical(
|
|
|
|
await appWindow.scaleFactor()
|
|
|
|
);
|
|
|
|
return {
|
|
|
|
w: Math.round(size.width) - ml,
|
|
|
|
h: Math.round(size.height) - mt,
|
|
|
|
};
|
|
|
|
}
|
2024-04-13 08:32:42 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-04-13 09:53:41 +08:00
|
|
|
<NConfigProvider :theme="darkTheme" class="container">
|
|
|
|
<NMessageProvider>
|
|
|
|
<Header />
|
|
|
|
<NDialogProvider>
|
2024-04-16 22:18:42 +08:00
|
|
|
<RouterView v-slot="{ Component }">
|
|
|
|
<KeepAlive>
|
|
|
|
<component :is="Component" />
|
|
|
|
</KeepAlive>
|
|
|
|
</RouterView>
|
2024-04-13 09:53:41 +08:00
|
|
|
</NDialogProvider>
|
|
|
|
<Sidebar />
|
|
|
|
</NMessageProvider>
|
|
|
|
</NConfigProvider>
|
2024-04-13 08:32:42 +08:00
|
|
|
</template>
|
|
|
|
|
2024-04-13 09:53:41 +08:00
|
|
|
<style>
|
|
|
|
.container {
|
|
|
|
background-color: transparent;
|
|
|
|
height: 100%;
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 70px 1fr;
|
|
|
|
grid-template-rows: 30px 1fr;
|
|
|
|
grid-template-areas:
|
|
|
|
"sidebar header"
|
|
|
|
"sidebar content";
|
2024-04-13 08:32:42 +08:00
|
|
|
}
|
2024-04-16 22:18:42 +08:00
|
|
|
|
2024-04-26 23:07:26 +08:00
|
|
|
.n-scrollbar-container {
|
2024-04-17 10:17:39 +08:00
|
|
|
background-color: var(--bg-color);
|
|
|
|
}
|
|
|
|
|
2024-04-16 22:18:42 +08:00
|
|
|
.n-scrollbar-content {
|
|
|
|
height: 100%;
|
|
|
|
}
|
2024-04-13 08:32:42 +08:00
|
|
|
</style>
|
2024-04-26 23:07:26 +08:00
|
|
|
import { getCurrent } from "@tauri-apps/api/webview"; import { Store } from
|
|
|
|
"@tauri-apps/plugin-store"; import { KeyMappingConfig } from
|
|
|
|
"./keyMappingConfig";
|