fix: 小地图缩放比例 & 存储

This commit is contained in:
unanmed 2024-04-21 14:48:44 +08:00
parent 0fa07e0605
commit 020551bd90
2 changed files with 24 additions and 17 deletions

View File

@ -98,6 +98,15 @@ export class GameStorage<T extends object = any> {
static get(key: string) { static get(key: string) {
return this.list.find(v => v.key === key); return this.list.find(v => v.key === key);
} }
/**
* Symbol.for类似
*/
static for(key: string) {
const s = this.get(key);
if (s) return s;
else return new GameStorage(key);
}
} }
window.addEventListener('beforeunload', () => { window.addEventListener('beforeunload', () => {

View File

@ -89,12 +89,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'; import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import Scroll from '../components/scroll.vue'; import Scroll from '../components/scroll.vue';
import { import { getArea, getMapData, MinimapDrawer } from '../plugin/ui/fly';
getArea,
getMapDrawData,
getMapData,
MinimapDrawer
} from '../plugin/ui/fly';
import { cancelGlobalDrag, isMobile, useDrag, useWheel } from '../plugin/use'; import { cancelGlobalDrag, isMobile, useDrag, useWheel } from '../plugin/use';
import { import {
LeftOutlined, LeftOutlined,
@ -103,12 +98,13 @@ import {
DoubleRightOutlined DoubleRightOutlined
} from '@ant-design/icons-vue'; } from '@ant-design/icons-vue';
import { debounce } from 'lodash-es'; import { debounce } from 'lodash-es';
import { downloadCanvasImage, tip } from '../plugin/utils'; import { tip } from '../plugin/utils';
import { GameUi } from '@/core/main/custom/ui'; import { GameUi } from '@/core/main/custom/ui';
import { gameKey } from '@/core/main/init/hotkey'; import { gameKey } from '@/core/main/init/hotkey';
import { createChangable } from '@/plugin/ui/common'; import { createChangable } from '@/plugin/ui/common';
import { mainUi } from '@/core/main/init/ui'; import { mainUi } from '@/core/main/init/ui';
import { mainSetting } from '@/core/main/setting'; import { mainSetting } from '@/core/main/setting';
import { GameStorage } from '@/core/main/storage';
const props = defineProps<{ const props = defineProps<{
num: number; num: number;
@ -124,11 +120,13 @@ const nowArea = ref(
const nowFloor = ref(core.status.floorId); const nowFloor = ref(core.status.floorId);
const noBorder = ref(true); const noBorder = ref(true);
const tradition = ref(false); const tradition = ref(false);
let scale = const settingScale = mainSetting.getValue('ui.mapScale', 100) / 100;
((isMobile ? 1.5 : 3) * mainSetting.getValue('ui.mapScale', 100)) / 100; let scale = (isMobile ? 1.5 : 3) * settingScale;
noBorder.value = core.getLocalStorage('noBorder', true); const storage = GameStorage.for(GameStorage.fromAuthor('AncTe', 'flyConfig'));
tradition.value = core.getLocalStorage('flyTradition', false);
noBorder.value = storage.getValue('noBorder', true);
tradition.value = storage.getValue('flyTradition', false);
const floor = computed(() => { const floor = computed(() => {
return core.status.maps[nowFloor.value]; return core.status.maps[nowFloor.value];
@ -139,10 +137,10 @@ watch(nowFloor, n => {
draw(); draw();
}); });
watch(nowArea, n => { watch(nowArea, n => {
scale = 3; scale = 3 * settingScale;
lastScale = 3; lastScale = 3 * settingScale;
drawer.nowArea = n; drawer.nowArea = n;
drawer.scale = 3; drawer.scale = 3 * settingScale;
drawer.ox = 0; drawer.ox = 0;
drawer.oy = 0; drawer.oy = 0;
if (area[n] && !area[n].includes(nowFloor.value)) if (area[n] && !area[n].includes(nowFloor.value))
@ -150,13 +148,13 @@ watch(nowArea, n => {
area[n].find(v => v === core.status.floorId) ?? area[n][0]; area[n].find(v => v === core.status.floorId) ?? area[n][0];
}); });
watch(noBorder, n => { watch(noBorder, n => {
core.setLocalStorage('noBorder', n); storage.setValue('noBorder', n);
drawer.noBorder = true; drawer.noBorder = n;
drawer.drawedThumbnail = {}; drawer.drawedThumbnail = {};
drawer.drawMap(); drawer.drawMap();
}); });
watch(tradition, n => { watch(tradition, n => {
core.setLocalStorage('flyTradition', n); storage.setValue('flyTradition', n);
}); });
let map: HTMLCanvasElement; let map: HTMLCanvasElement;