@wot-ui/vitepress-theme 2.0.0-alpha.17 → 2.0.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.js CHANGED
@@ -120,6 +120,7 @@ function createWotVitePressConfig(options) {
120
120
  head: options.head,
121
121
  locales: options.locales,
122
122
  themeConfig: options.themeConfig,
123
+ lang: options.lang,
123
124
  vite: {
124
125
  ...userVite,
125
126
  plugins: [...internalPlugins, ...normalizePlugins(userVite.plugins)],
@@ -1,5 +1,4 @@
1
1
  import { ref, onMounted, inject } from "vue";
2
- import axios from "axios";
3
2
  import { wotThemeOptionsKey } from "../options.js";
4
3
  const data = ref([]);
5
4
  function useAds() {
@@ -13,11 +12,16 @@ function useAds() {
13
12
  const fetchData = async () => {
14
13
  for (const url of urls) {
15
14
  try {
16
- const response = await axios.get(url + "?t=" + Date.now(), {
17
- timeout: 5e3
18
- // 设置5秒超时
15
+ const controller = new AbortController();
16
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
17
+ const response = await fetch(url + "?t=" + Date.now(), {
18
+ signal: controller.signal
19
19
  });
20
- return response.data && response.data.ads ? response.data.ads : [];
20
+ clearTimeout(timeoutId);
21
+ if (!response.ok)
22
+ continue;
23
+ const result = await response.json();
24
+ return result && result.ads ? result.ads : [];
21
25
  } catch (error) {
22
26
  console.warn(`Failed to fetch from ${url}`);
23
27
  }
@@ -1,5 +1,4 @@
1
1
  import { ref, onMounted, inject } from "vue";
2
- import axios from "axios";
3
2
  import { wotThemeOptionsKey } from "../options.js";
4
3
  const data = ref([]);
5
4
  function useBanner() {
@@ -13,11 +12,16 @@ function useBanner() {
13
12
  const fetchData = async () => {
14
13
  for (const url of urls) {
15
14
  try {
16
- const response = await axios.get(url + "?t=" + Date.now(), {
17
- timeout: 5e3
18
- // 设置5秒超时
15
+ const controller = new AbortController();
16
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
17
+ const response = await fetch(url + "?t=" + Date.now(), {
18
+ signal: controller.signal
19
19
  });
20
- return response.data && response.data.data ? response.data.data : [];
20
+ clearTimeout(timeoutId);
21
+ if (!response.ok)
22
+ continue;
23
+ const result = await response.json();
24
+ return result && result.data ? result.data : [];
21
25
  } catch (error) {
22
26
  console.warn(`Failed to fetch from ${url}`);
23
27
  }
@@ -1,5 +1,4 @@
1
1
  import { ref, onMounted, inject } from "vue";
2
- import axios from "axios";
3
2
  import { wotThemeOptionsKey } from "../options.js";
4
3
  const data = ref([]);
5
4
  function useCaseData() {
@@ -10,34 +9,37 @@ function useCaseData() {
10
9
  return;
11
10
  }
12
11
  const urls = casesOptions.urls || [];
12
+ const getFullImageUrl = (image, baseUrl) => {
13
+ if (!image)
14
+ return "";
15
+ if (image.startsWith("http://") || image.startsWith("https://")) {
16
+ return image;
17
+ }
18
+ try {
19
+ const { origin } = new URL(baseUrl);
20
+ return origin + image;
21
+ } catch {
22
+ return baseUrl + image;
23
+ }
24
+ };
13
25
  const fetchData = async () => {
14
26
  for (const url of urls) {
15
27
  try {
16
- const response = await axios.get(url + "?t=" + Date.now(), {
17
- timeout: 5e3
18
- // 设置5秒超时
19
- });
20
- const data2 = response.data && response.data.data ? response.data.data : [];
21
- const getFullImageUrl = (image, baseUrl) => {
22
- if (!image)
23
- return "";
24
- if (image.startsWith("http://") || image.startsWith("https://")) {
25
- return image;
26
- }
27
- try {
28
- const { origin } = new URL(baseUrl);
29
- return origin + image;
30
- } catch {
31
- return baseUrl + image;
32
- }
33
- };
34
- return data2.map((item) => {
35
- return {
36
- name: item.name,
37
- image: getFullImageUrl(item.image, url),
38
- description: item.description
39
- };
28
+ const controller = new AbortController();
29
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
30
+ const response = await fetch(url + "?t=" + Date.now(), {
31
+ signal: controller.signal
40
32
  });
33
+ clearTimeout(timeoutId);
34
+ if (!response.ok)
35
+ continue;
36
+ const result = await response.json();
37
+ const caseData = result && result.data ? result.data : [];
38
+ return caseData.map((item) => ({
39
+ name: item.name,
40
+ image: getFullImageUrl(item.image, url),
41
+ description: item.description
42
+ }));
41
43
  } catch (error) {
42
44
  console.warn(`Failed to fetch from ${url}`);
43
45
  }
@@ -1,5 +1,4 @@
1
1
  import { ref, onMounted, inject } from "vue";
2
- import axios from "axios";
3
2
  import { wotThemeOptionsKey } from "../options.js";
4
3
  const data = ref([]);
5
4
  function useFriendly() {
@@ -13,11 +12,16 @@ function useFriendly() {
13
12
  const fetchData = async () => {
14
13
  for (const url of urls) {
15
14
  try {
16
- const response = await axios.get(url + "?t=" + Date.now(), {
17
- timeout: 5e3
18
- // 设置5秒超时
15
+ const controller = new AbortController();
16
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
17
+ const response = await fetch(url + "?t=" + Date.now(), {
18
+ signal: controller.signal
19
19
  });
20
- return response.data && response.data.links ? response.data.links : [];
20
+ clearTimeout(timeoutId);
21
+ if (!response.ok)
22
+ continue;
23
+ const result = await response.json();
24
+ return result && result.links ? result.links : [];
21
25
  } catch (error) {
22
26
  console.warn(`Failed to fetch from ${url}`);
23
27
  }
@@ -1,5 +1,4 @@
1
1
  import { ref, onMounted, inject } from "vue";
2
- import axios from "axios";
3
2
  import { wotThemeOptionsKey } from "../options.js";
4
3
  const data = ref([]);
5
4
  function useSpecialSponsor() {
@@ -13,11 +12,16 @@ function useSpecialSponsor() {
13
12
  const fetchData = async () => {
14
13
  for (const url of urls) {
15
14
  try {
16
- const response = await axios.get(url + "?t=" + Date.now(), {
17
- timeout: 5e3
18
- // 设置5秒超时
15
+ const controller = new AbortController();
16
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
17
+ const response = await fetch(url + "?t=" + Date.now(), {
18
+ signal: controller.signal
19
19
  });
20
- return response?.data?.data;
20
+ clearTimeout(timeoutId);
21
+ if (!response.ok)
22
+ continue;
23
+ const result = await response.json();
24
+ return result?.data;
21
25
  } catch (error) {
22
26
  console.warn(`Failed to fetch from ${url}`);
23
27
  }
@@ -1,5 +1,4 @@
1
1
  import { ref, onMounted, inject } from "vue";
2
- import axios from "axios";
3
2
  import { wotThemeOptionsKey } from "../options.js";
4
3
  const data = ref();
5
4
  function useSponsor() {
@@ -13,11 +12,15 @@ function useSponsor() {
13
12
  const fetchData = async () => {
14
13
  for (const url of urls) {
15
14
  try {
16
- const response = await axios.get(url + "?t=" + Date.now(), {
17
- timeout: 5e3
18
- // 设置5秒超时
15
+ const controller = new AbortController();
16
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
17
+ const response = await fetch(url + "?t=" + Date.now(), {
18
+ signal: controller.signal
19
19
  });
20
- return response.data;
20
+ clearTimeout(timeoutId);
21
+ if (!response.ok)
22
+ continue;
23
+ return await response.json();
21
24
  } catch (error) {
22
25
  console.warn(`Failed to fetch from ${url}`);
23
26
  }
@@ -1,5 +1,4 @@
1
1
  import { ref, onMounted, inject } from "vue";
2
- import axios from "axios";
3
2
  import { wotThemeOptionsKey } from "../options.js";
4
3
  const data = ref([]);
5
4
  function useTeam() {
@@ -28,10 +27,16 @@ function useTeam() {
28
27
  const fetchData = async () => {
29
28
  for (const url of urls) {
30
29
  try {
31
- const response = await axios.get(url + "?t=" + Date.now(), {
32
- timeout: 5e3
30
+ const controller = new AbortController();
31
+ const timeoutId = setTimeout(() => controller.abort(), 5e3);
32
+ const response = await fetch(url + "?t=" + Date.now(), {
33
+ signal: controller.signal
33
34
  });
34
- const members = response.data && response.data.members ? response.data.members : [];
35
+ clearTimeout(timeoutId);
36
+ if (!response.ok)
37
+ continue;
38
+ const result = await response.json();
39
+ const members = result && result.members ? result.members : [];
35
40
  return normalizeMembers(members);
36
41
  } catch (error) {
37
42
  console.warn(`Failed to fetch team from ${url}`);
package/dist/types.d.ts CHANGED
@@ -215,6 +215,10 @@ export interface WotVitePressConfigOptions {
215
215
  * 站点标题。
216
216
  */
217
217
  title: string;
218
+ /**
219
+ * 站点默认语言。
220
+ */
221
+ lang: string;
218
222
  /**
219
223
  * 站点描述。
220
224
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wot-ui/vitepress-theme",
3
- "version": "2.0.0-alpha.17",
3
+ "version": "2.0.0-alpha.19",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"