From ba013cc7ef2fa3b0db5e4a3f81583acc95769858 Mon Sep 17 00:00:00 2001 From: Pysio Date: Wed, 15 Jan 2025 18:24:02 +0800 Subject: [PATCH 1/4] feat: add deepsource --- .deepsource.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .deepsource.toml diff --git a/.deepsource.toml b/.deepsource.toml new file mode 100644 index 00000000..d0e693b8 --- /dev/null +++ b/.deepsource.toml @@ -0,0 +1,14 @@ +version = 1 + +[[analyzers]] +name = "javascript" + + [analyzers.meta] + plugins = ["vue"] + environment = [ + "nodejs", + "vitest" + ] + +[[transformers]] +name = "standardjs" \ No newline at end of file From c4a8d2b08520bc9890e9fa48d0c766a876eb8220 Mon Sep 17 00:00:00 2001 From: Pysio Date: Wed, 15 Jan 2025 18:28:06 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DIP=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=8E=A5=E5=8F=A3=E7=9A=84=E9=97=AE=E9=A2=98=20close?= =?UTF-8?q?=20#322?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/.vuepress/components/ipcheck.vue | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/.vuepress/components/ipcheck.vue b/src/.vuepress/components/ipcheck.vue index 2d724b0e..8ea28e48 100644 --- a/src/.vuepress/components/ipcheck.vue +++ b/src/.vuepress/components/ipcheck.vue @@ -202,12 +202,33 @@ export default { } // 获取第二个 IP 地址 - const ipResponse2 = await fetch('https://myip.ipip.net/'); + const ipResponse2 = await fetch('https://2024.ipchaxun.com/'); if (!ipResponse2.ok) { throw new Error(`HTTP error! status: ${ipResponse2.status}`); } - const ipText = await ipResponse2.text(); - userIP2 = ipText.match(/当前 IP:(\d+\.\d+\.\d+\.\d+)/)[1]; + const ipJson2 = await ipResponse2.json(); + + if (ipJson2.ret === 'ok') { + userIP2 = ipJson2.ip; + // 创建一个兼容的数据结构 + const compatibleData = { + ip: ipJson2.ip, + country: ipJson2.data[0], + region: ipJson2.data[1], + city: ipJson2.data[2], + org: ipJson2.data[4], + data: { + ip: ipJson2.ip, + country: ipJson2.data[0], + region: ipJson2.data[1], + city: ipJson2.data[2], + org: ipJson2.data[4] + } + }; + this.ipData2 = compatibleData; + } else { + throw new Error('Failed to get IP data from ipchaxun'); + } // 比较两个 IP 地址 if (userIP !== userIP2) { From b8140a255390fe8b17cb5f14cb7e0d1af1cd27c0 Mon Sep 17 00:00:00 2001 From: Pysio Date: Wed, 15 Jan 2025 18:31:38 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=8B=E9=93=BE?= =?UTF-8?q?Icon=20close=20#324?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/README.md b/src/README.md index ac0b2430..fe13adb7 100644 --- a/src/README.md +++ b/src/README.md @@ -28,7 +28,7 @@ projects: # desc: 文章详细描述 # link: https://你的文章链接 - - icon: friend + - icon: fa-solid fa-link name: 友链 desc: 朋友们的网站些 link: /other/friends From 609437126df194a4cc13bbfdb5cbe92e5571d052 Mon Sep 17 00:00:00 2001 From: Pysio Date: Wed, 15 Jan 2025 18:35:08 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E9=98=B2=E6=AD=A2Wordle=E5=8D=95?= =?UTF-8?q?=E8=AF=8D=E6=97=A0=E6=95=88=20close=20#319?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/.vuepress/components/Wordle.vue | 43 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/.vuepress/components/Wordle.vue b/src/.vuepress/components/Wordle.vue index a0ba5f7b..12d8d5f1 100644 --- a/src/.vuepress/components/Wordle.vue +++ b/src/.vuepress/components/Wordle.vue @@ -54,24 +54,35 @@ export default { }, methods: { async fetchNewWord() { - try { - const response = await fetch(API_URL); - const [word] = await response.json(); - this.answer = word.toLowerCase(); - } catch (error) { - console.error('Failed to fetch word:', error); - this.answer = 'nowan'; // 降级方案 + let isValid = false; + let word = ''; + let attempts = 0; + const maxAttempts = 5; // 最大重试次数 + + while (!isValid && attempts < maxAttempts) { + try { + const response = await fetch(API_URL); + [word] = await response.json(); + word = word.toLowerCase(); + + // 验证单词是否有效 + const validationResponse = await fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`); + if (validationResponse.ok) { + isValid = true; + this.answer = word; + break; + } + } catch (error) { + console.error('Failed to fetch or validate word:', error); + } + attempts++; + } + + if (!isValid) { + this.answer = 'nowan'; // 如果多次尝试后仍未获取到有效单词,使用降级方案 + console.warn('Failed to get a valid word after multiple attempts'); } }, - // 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}`);