This commit is contained in:
SMGDev
2025-10-30 10:50:21 +00:00
4 changed files with 48 additions and 3 deletions

View File

@@ -1,8 +1,9 @@
<!doctype html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8"/>
<link rel="icon" type="image/svg+xml" href="/favicon.png"/>
<link rel="manifest" href="/manifest.json">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Type Words - 词文记 | 单词跟打 · 文章跟打</title>
<!-- 搜索引擎描述 -->
@@ -77,5 +78,16 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/service-worker.js').then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}).catch(error => {
console.log('ServiceWorker registration failed: ', error);
});
});
}
</script>
</body>
</html>

16
manifest.json Normal file
View File

@@ -0,0 +1,16 @@
{
"name": "Type Words - 词文记 | 单词跟打 · 文章跟打",
"short_name": "",
"start_url": ".",
"description": "在线英语打字练习平台,支持单词跟打与文章跟打,帮助提升打字速度与英语学习效率。",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#ffffff",
"icons": [
{
"src": "/favicon.png",
"sizes": "800x800",
"type": "image/png"
}
]
}

12
service-worker.js Normal file
View File

@@ -0,0 +1,12 @@
// 'install' 事件在 Service Worker 首次被安装时触发。
self.addEventListener('install', event => {
self.skipWaiting();
});
// 'activate' 事件在 Service Worker 变为激活状态时触发。
self.addEventListener('activate', event => {
return self.clients.claim();
});
self.addEventListener('fetch', event => {
});

View File

@@ -1,10 +1,10 @@
<script setup lang="ts">
import { inject, onMounted, onUnmounted, watch } from "vue"
import { Article, ArticleWord, PracticeArticleWordType, Sentence, Word } from "@/types/types.ts";
import {Article, ArticleWord, PracticeArticleWordType, Sentence, ShortcutKey, Word} from "@/types/types.ts";
import { useBaseStore } from "@/stores/base.ts";
import { useSettingStore } from "@/stores/setting.ts";
import { usePlayBeep, usePlayCorrect, usePlayKeyboardAudio } from "@/hooks/sound.ts";
import { emitter, EventKey } from "@/utils/eventBus.ts";
import {emitter, EventKey, useEvents} from "@/utils/eventBus.ts";
import { _dateFormat, _nextTick, msToHourMinute, msToMinute, total } from "@/utils";
import '@imengyu/vue3-context-menu/lib/vue3-context-menu.css'
import ContextMenu from '@imengyu/vue3-context-menu'
@@ -522,6 +522,11 @@ onUnmounted(() => {
emitter.off(EventKey.onTyping, onTyping)
})
useEvents([
[ShortcutKey.KnowWord, onTyping],
[ShortcutKey.UnknownWord, onTyping],
])
defineExpose({showSentence, play, del, hideSentence, nextSentence, init})
function isCurrent(i: number, j: number, w: number) {