Skip to content

Commit e90176f

Browse files
committed
refactor: use UTooltip replace tippy
1 parent 9420bba commit e90176f

File tree

12 files changed

+92
-155
lines changed

12 files changed

+92
-155
lines changed

apps/client/components/Home/CalendarGraph.vue

+11-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<th></th>
1717
<th
1818
v-for="{ colSpan, month } in thead"
19-
class="text-left font-normal"
19+
class="pb-1 text-left font-normal"
2020
:colspan="colSpan"
2121
:key="month"
2222
>
@@ -33,15 +33,17 @@
3333
</td>
3434
<td
3535
v-for="(cell, j) in row"
36-
class="m-0"
3736
:key="j"
3837
>
39-
<div
40-
class="cell block"
41-
:class="[cell?.bg]"
42-
:data-tippy-content="cell?.tips"
43-
@mouseenter="(e) => $calendarTippy(e, calendarTable)"
44-
/>
38+
<UTooltip
39+
:text="cell?.tips"
40+
:ui="{ wrapper: '', strategy: 'override' }"
41+
>
42+
<div
43+
class="cell block"
44+
:class="[cell?.bg]"
45+
></div>
46+
</UTooltip>
4547
</td>
4648
</tr>
4749
</tbody>
@@ -166,7 +168,7 @@ watchEffect(() => {
166168

167169
<style scoped>
168170
.cell {
169-
@apply mt-[2px] h-[12px] w-[12px] rounded-sm border-gray-200 bg-gray-200 hover:scale-125 hover:border hover:border-blue-400 dark:bg-gray-700 dark:hover:border-gray-50;
171+
@apply h-[12px] w-[12px] rounded-sm border-gray-200 bg-gray-200 hover:scale-125 hover:border hover:border-blue-400 dark:bg-gray-700 dark:hover:border-gray-50;
170172
}
171173
172174
.low {

apps/client/components/courses/CourseCard.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
'bg-purple-600': isActiveCourse,
3131
},
3232
]"
33-
:data-tippy-content="dataTip"
34-
@mouseenter="$lazyTippy"
3533
>
36-
{{ count }}
34+
<UTooltip :text="dataTip">
35+
{{ count }}
36+
</UTooltip>
3737
</div>
3838
</div>
3939
</template>

apps/client/components/main/Contents/Contents.vue

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
v-for="(item, index) in contentsList"
1111
:key="item.id"
1212
:class="getItemClassNames(index)"
13-
:data-tippy-content="`${item.english}<br>${item.chinese}`"
1413
@click="jumpTo(index, item)"
15-
@mouseenter="$lazyTippy"
1614
>
17-
<div class="flex whitespace-pre-wrap border-b py-1 dark:border-slate-600">
18-
<div class="w-12 text-center">{{ index + 1 }}</div>
19-
<div class="flex-1 truncate text-left">
20-
{{ item.chinese }}
21-
{{ item.isMastered ? "✅" : "" }}
15+
<UTooltip :text="`${item.english} ${item.chinese}`">
16+
<div class="flex whitespace-pre-wrap border-b py-1 dark:border-slate-600">
17+
<div class="w-12 text-center">{{ index + 1 }}</div>
18+
<div class="flex-1 truncate text-left">
19+
{{ item.chinese }}
20+
{{ item.isMastered ? "✅" : "" }}
21+
</div>
2222
</div>
23-
</div>
23+
</UTooltip>
2424
</div>
2525
</div>
2626
</div>

apps/client/components/main/PrevAndNextBtn.vue

+19-13
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,35 @@
44
<button
55
v-show="courseStore.visibleStatementIndex !== 0"
66
class="arrow-btn"
7-
:data-tippy-content="PREV_BTN_TIP"
87
@click="goToPreviousQuestion"
9-
@mouseenter="$lazyTippy"
108
>
11-
<UIcon
12-
name="i-ph-caret-left"
13-
class="h-12 w-12"
14-
></UIcon>
9+
<UTooltip
10+
text="上一题"
11+
:shortcuts="parseShortcut(shortcutKeys.previous)"
12+
>
13+
<UIcon
14+
name="i-ph-caret-left"
15+
class="h-12 w-12"
16+
></UIcon>
17+
</UTooltip>
1518
</button>
1619
</div>
1720

1821
<div class="h-12 w-12">
1922
<button
2023
v-show="courseStore.visibleStatementIndex + 1 !== courseStore.visibleStatementsCount"
2124
class="arrow-btn"
22-
:data-tippy-content="NEXT_BTN_TIP"
2325
@click="goToNextQuestion"
24-
@mouseenter="$lazyTippy"
2526
>
26-
<UIcon
27-
name="i-ph-caret-right"
28-
class="h-12 w-12"
29-
></UIcon>
27+
<UTooltip
28+
text="下一题"
29+
:shortcuts="parseShortcut(shortcutKeys.skip)"
30+
>
31+
<UIcon
32+
name="i-ph-caret-right"
33+
class="h-12 w-12"
34+
></UIcon>
35+
</UTooltip>
3036
</button>
3137
</div>
3238
</div>
@@ -35,7 +41,7 @@
3541
import { onMounted, onUnmounted } from "vue";
3642
3743
import { useGameMode } from "~/composables/main/game";
38-
import { useShortcutKeyMode } from "~/composables/user/shortcutKey";
44+
import { parseShortcut, useShortcutKeyMode } from "~/composables/user/shortcutKey";
3945
import { useCourseStore } from "~/store/course";
4046
import { cancelShortcut, registerShortcut } from "~/utils/keyboardShortcuts";
4147

apps/client/components/main/StudyVideoLink.vue

+6-7
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
target="_blank"
55
class="flex cursor-pointer items-center fill-current text-xl hover:text-fuchsia-500"
66
:href="video"
7-
:data-tippy-content="NOTE_TIP"
8-
@mouseenter="$lazyTippy"
97
>
10-
<UIcon
11-
name="i-simple-icons-bilibili"
12-
class="h-5 w-5"
13-
/>
8+
<UTooltip text="边看边练">
9+
<UIcon
10+
name="i-simple-icons-bilibili"
11+
class="h-5 w-5"
12+
/>
13+
</UTooltip>
1414
</NuxtLink>
1515
</template>
1616

1717
<script setup lang="ts">
18-
const NOTE_TIP = "边看边练";
1918
defineProps<{
2019
video?: string;
2120
}>();

apps/client/components/main/Tool.vue

+32-32
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
<!-- 左侧 -->
66
<div class="flex items-center">
77
<NuxtLink
8-
class="clickable-item"
9-
data-tippy-content="课程列表"
8+
class="clickable-item flex items-center justify-center"
109
:href="`/course-pack/${courseStore.currentCourse?.coursePackId}`"
11-
@mouseenter="$lazyTippy"
1210
>
13-
<IconsExpand class="h-7 w-7" />
11+
<UTooltip text="课程列表">
12+
<IconsExpand class="h-7 w-7" />
13+
</UTooltip>
1414
</NuxtLink>
1515
<div
1616
class="clickable-item ml-4"
17-
data-tippy-content="课程题目列表"
1817
@click="toggleContents"
19-
@mouseenter="$lazyTippy"
2018
>
21-
{{ currentCourseInfo }}
19+
<UTooltip text="课程题目列表">
20+
{{ currentCourseInfo }}
21+
</UTooltip>
2222
</div>
2323
<MainStudyVideoLink :video="courseStore.currentCourse?.video" />
2424
</div>
@@ -27,34 +27,34 @@
2727
<div class="flex items-center gap-4">
2828
<div
2929
v-if="isAuthenticated()"
30-
:data-tippy-content="`暂停游戏 (${shortcutKeys.pause})`"
3130
@click="pauseGame"
32-
@mouseenter="$lazyTippy"
3331
>
34-
<UIcon
35-
name="i-ph-pause"
36-
class="clickable-item h-6 w-6"
37-
/>
32+
<UTooltip
33+
text="暂停游戏"
34+
:shortcuts="parseShortcut(shortcutKeys.pause)"
35+
>
36+
<UIcon
37+
name="i-ph-pause"
38+
class="clickable-item h-6 w-6"
39+
/>
40+
</UTooltip>
3841
</div>
39-
<div
40-
data-tippy-content="重置当前课程进度"
41-
@click="handleDoAgain"
42-
@mouseenter="$lazyTippy"
43-
>
44-
<UIcon
45-
name="i-ph-arrow-counter-clockwise"
46-
class="clickable-item h-6 w-6"
47-
/>
42+
43+
<div @click="handleDoAgain">
44+
<UTooltip text="重置当前课程进度">
45+
<UIcon
46+
name="i-ph-arrow-counter-clockwise"
47+
class="clickable-item h-6 w-6"
48+
/>
49+
</UTooltip>
4850
</div>
49-
<div
50-
data-tippy-content="排行榜"
51-
@click="rankingStore.showRankModal"
52-
@mouseenter="$lazyTippy"
53-
>
54-
<UIcon
55-
name="i-ph-ranking"
56-
class="clickable-item h-6 w-6"
57-
/>
51+
<div @click="rankingStore.showRankModal">
52+
<UTooltip text="排行榜">
53+
<UIcon
54+
name="i-ph-ranking"
55+
class="clickable-item h-6 w-6"
56+
/>
57+
</UTooltip>
5858
</div>
5959
</div>
6060

@@ -79,7 +79,7 @@ import { useGameMode } from "~/composables/main/game";
7979
import { clearQuestionInput } from "~/composables/main/question";
8080
import { useGamePause } from "~/composables/main/useGamePause";
8181
import { useRanking } from "~/composables/rank/rankingList";
82-
import { useShortcutKeyMode } from "~/composables/user/shortcutKey";
82+
import { parseShortcut, useShortcutKeyMode } from "~/composables/user/shortcutKey";
8383
import { isAuthenticated } from "~/services/auth";
8484
import { useCourseStore } from "~/store/course";
8585
import { useContent } from "./Contents/useContents";

apps/client/composables/user/shortcutKey.ts

+6
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ export function convertMacKey(key: string) {
5050
);
5151
}
5252

53+
export function parseShortcut(shortcut: string): string[] {
54+
return shortcut
55+
.split("+")
56+
.map((key) => key.trim().charAt(0).toUpperCase() + key.slice(1).toLowerCase());
57+
}
58+
5359
// 自定义快捷键
5460
const showModal = ref<boolean>(false);
5561
const currentKeyType = ref<SHORTCUT_KEY_TYPES | "">("");

apps/client/nuxt.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default defineNuxtConfig({
4141
"@hypernym/nuxt-anime",
4242
"@nuxt/image",
4343
],
44-
plugins: ["~/plugins/logto.ts", "~/plugins/lazyTippy.ts", "~/plugins/http.ts"],
44+
plugins: ["~/plugins/logto.ts", "~/plugins/http.ts"],
4545
runtimeConfig: {
4646
public: {
4747
apiBase: process.env.API_BASE || "",

apps/client/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"ofetch": "^1.3.4",
5656
"pinia": "^2.1.7",
5757
"satori": "^0.10.13",
58-
"tippy.js": "^6.3.7",
5958
"vee-validate": "^4.12.5",
6059
"vue-sonner": "^1.1.4",
6160
"yup": "^1.3.3"

apps/client/pages/mastered-elements.vue

+6-5
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
</div>
2828
</div>
2929
<div
30-
data-tippy-content="删除"
3130
@click="removeItem(item)"
3231
class="cursor-pointer transition-transform duration-300 hover:scale-110"
3332
>
34-
<UIcon
35-
name="i-ph-trash-bold"
36-
class="h-5 w-5"
37-
/>
33+
<UTooltip text="删除">
34+
<UIcon
35+
name="i-ph-trash-bold"
36+
class="h-5 w-5"
37+
/>
38+
</UTooltip>
3839
</div>
3940
</div>
4041
</div>

apps/client/plugins/lazyTippy.ts

-66
This file was deleted.

0 commit comments

Comments
 (0)