Skip to content

Commit

Permalink
fix: 修复Wordle
Browse files Browse the repository at this point in the history
  • Loading branch information
pysio2007 committed Dec 13, 2024
1 parent ae82c86 commit a44e60f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![note build](https://github.com/pysio2007/Vue-blog/actions/workflows/bulid-server.yml/badge.svg)](https://github.com/pysio2007/Vue-blog/actions/workflows/bulid-server.yml)
[![Build Docker Image](https://github.com/pysio2007/Vue-blog/actions/workflows/bulid-docker.yml/badge.svg)](https://github.com/pysio2007/Vue-blog/actions/workflows/bulid-docker.yml)
[![可靠性评级](https://sonarqube.pysio.online/api/project_badges/measure?project=pysio2007_Vue-blog_4ce9d341-7a3c-4327-8552-71bbe67bb1ca&metric=reliability_rating&token=sqb_136ab7accc7d12a217881f398f214de786ad6b55)](https://sonarqube.pysio.online/dashboard?id=pysio2007_Vue-blog_4ce9d341-7a3c-4327-8552-71bbe67bb1ca)
[![Coverage Status](https://coveralls.io/repos/github/pysio2007/Vue-blog/badge.svg?branch=main)](https://coveralls.io/github/pysio2007/Vue-blog?branch=main)
<!-- [![Coverage Status](https://coveralls.io/repos/github/pysio2007/Vue-blog/badge.svg?branch=main)](https://coveralls.io/github/pysio2007/Vue-blog?branch=main) -->
[![wakatime](https://wakatime.com/badge/user/a8344004-6b9a-4a56-8b71-e626b395781c/project/d910a3a5-e3e2-425e-be0f-175d36fa6d19.svg)](https://wakatime.com/badge/user/a8344004-6b9a-4a56-8b71-e626b395781c/project/d910a3a5-e3e2-425e-be0f-175d36fa6d19)
## 关于本仓库

Expand Down
6 changes: 5 additions & 1 deletion babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-typescript'],
presets: [
'@babel/preset-env',
'@babel/preset-typescript',
],
sourceMaps: 'inline',
};
12 changes: 10 additions & 2 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ const config = {
coverageProvider: "v8",
testEnvironment: "node",
transform: {
"^.+\\.tsx?$": "babel-jest",
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', {
sourceMaps: false,
plugins: ['@babel/plugin-transform-modules-commonjs']
}]
},
moduleFileExtensions: ["js", "jsx", "ts", "tsx", "json", "node"],
testMatch: [
Expand All @@ -14,8 +17,13 @@ const config = {
],
collectCoverageFrom: [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts", // 排除类型声明文件
"!src/**/*.d.ts",
"!src/.vuepress/**/*",
"!**/node_modules/**"
],
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1"
}
};

export default config;
20 changes: 10 additions & 10 deletions src/.vuepress/components/Wordle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default {
},
async created() {
await this.fetchNewWord();
await this.loadValidWords();
// await this.loadValidWords();
},
methods: {
async fetchNewWord() {
Expand All @@ -63,15 +63,15 @@ export default {
this.answer = 'nowan'; // 降级方案
}
},
async loadValidWords() {
try {
const response = await fetch('/word-list.txt'); // 需要提供有效词列表
const text = await response.text();
this.validWords = new Set(text.split('\n').map(w => w.trim().toLowerCase()));
} catch (error) {
console.error('Failed to load valid words:', error);
}
},
// async loadValidWords() {
// try {
// const response = await fetch('/word-list.txt'); // 需要提供有效词列表
// const text = await response.text();
// this.validWords = new Set(text.split('\n').map(w => w.trim().toLowerCase()));
// } catch (error) {
// console.error('Failed to load valid words:', error);
// }
// },
async isValidWord(word) {
try {
const response = await fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`);
Expand Down

0 comments on commit a44e60f

Please sign in to comment.