Skip to content

Commit cc16a2e

Browse files
committed
refactor: clean up unused utility functions and simplify SelectorPage layout
1 parent 566760c commit cc16a2e

File tree

4 files changed

+6
-38
lines changed

4 files changed

+6
-38
lines changed

src/components/SvgIcon.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,12 @@ watchEffect(() => {
4646
></svg>
4747
</template>
4848
<style>
49-
:root {
50-
--svg-h: 1em;
51-
}
5249
.SvgIcon {
5350
display: block;
5451
overflow: hidden;
52+
height: var(--svg-h, 1em);
53+
}
54+
.SvgIcon:not([fill]) {
5555
fill: currentColor;
56-
height: var(--svg-h);
5756
}
58-
/* --svg-h:initial */
5957
</style>

src/style/index.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ html {
77
height: var(--win-h);
88
}
99

10-
body {
11-
width: var(--gkd-w);
12-
&.body-auto-w {
13-
--gkd-w: 100vw;
14-
}
15-
}
16-
1710
.page-size,
1811
[page-size] {
1912
width: var(--gkd-w);

src/utils/others.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { LocationQuery } from 'vue-router';
22
import { message } from './discrete';
3-
import root from './root';
43
import { Teleport } from 'vue';
54
import BodyScrollbar from '@/components/BodyScrollbar.vue';
65

@@ -66,24 +65,6 @@ export const copy = (() => {
6665
};
6766
})();
6867

69-
const useAutoCls = (el: Element, cls: string) => {
70-
el.classList.add(cls);
71-
onMounted(() => {
72-
el.classList.add(cls);
73-
});
74-
onUnmounted(() => {
75-
el.classList.remove(cls);
76-
});
77-
};
78-
79-
export const useAutoHeight = () => {
80-
useAutoCls(root, 'app-auto-h');
81-
};
82-
83-
export const useAutoWidth = () => {
84-
useAutoCls(document.body, 'body-auto-w');
85-
};
86-
8768
export const timeAgo = (date: number) => {
8869
const seconds = Math.floor((Date.now() - date) / 1000);
8970
const interval = Math.floor(seconds / 31536000);

src/views/SelectorPage.vue

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
<script setup lang="ts">
22
import SelectorText from '@/components/SelectorText.vue';
3-
import { useAutoHeight, useAutoWidth } from '@/utils/others';
43
import {
54
AstNode,
6-
Selector,
75
GkdException,
6+
Selector,
87
SyntaxException,
98
} from '@gkd-kit/selector';
109
import * as base64url from 'universal-base64url';
1110
12-
useAutoHeight();
13-
useAutoWidth();
14-
1511
const route = useRoute();
1612
const router = useRouter();
1713
@@ -68,7 +64,7 @@ const error = computed(() => {
6864
});
6965
</script>
7066
<template>
71-
<div page-size flex items-center gap-16px pt-12px px-12px>
67+
<div flex items-center gap-16px pt-12px px-12px>
7268
<NTooltip placement="right">
7369
<template #trigger>
7470
<NButton text>
@@ -83,7 +79,7 @@ const error = computed(() => {
8379
</template>
8480
回到首页
8581
</NTooltip>
86-
<div flex gap-16px>
82+
<div flex gap-16px items-center>
8783
<div text-18px>测试选择器</div>
8884
<div>语法高亮/错误解析</div>
8985
</div>

0 commit comments

Comments
 (0)