Skip to content

Commit

Permalink
优化 FetchInfo.vue 和改用 Lsposed Module 仓库获取版本信息 (#49)
Browse files Browse the repository at this point in the history
* 优化FetchInfo.vue和改用Lsposed Module仓库获取版本

改用 Lsposed Module 仓库获取版本信息
 - 防止一些网络问题。
 - 防止出现 GitHub API 速率问题。
 - 切换到 Lsposed Module仓库以修复描述的 Markdown 未被渲染问题。

优化 FetchInfo.vue
 - 添加错误处理
 - 将大部分操作移至 FetchInfo.vue 不至于让还没有获取到更新或者获取出错的位置很丑

* 为 FetchInfo.vue 添加 i18n 支持
  • Loading branch information
FurryRbl committed Feb 21, 2024
1 parent 1b32ab1 commit 40911d3
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 103 deletions.
83 changes: 45 additions & 38 deletions .vitepress/components/FetchInfo.vue
Original file line number Diff line number Diff line change
@@ -1,42 +1,49 @@
<template></template>

<template>
<div id="update_log">
<p v-if="loading">{{ i18n.loading_tips }}</p>
<div v-if="releases">
<p>{{ i18n.version + release.name }}</p>
<p>{{ i18n.update_date + release.publishedAt }}</p>
<p v-html="release.descriptionHTML"></p>
</div>
<div v-if="error">
<p>{{ i18n.error_log }}</p>
<br />
<pre>{{ error }}</pre>
</div>
</div>
</template>

<script>
export default {
mounted() {
const githubApiUrl1 = 'https://api.github.com/repos/saraSakuHj/HyperCeiler/releases/latest';
const githubApiUrl2 = 'https://api.github.com/repos/saraSakuHj/Cemiuiler/releases/latest';
fetch(githubApiUrl1)
.then(response => response.json())
.then(data => {
handleResponse(data);
})
.catch(error => {
console.error('Error fetching data from', githubApiUrl1, 'Error:', error);
// If the first request fails, try the second one
setTimeout(() => {
fetch(githubApiUrl2)
.then(response => response.json())
.then(data => {
handleResponse(data);
})
.catch(error => {
console.error('Error fetching data from', githubApiUrl2, 'Error:', error);
});
}, 500);
});
function handleResponse(data) {
if (document.getElementById("info")) {
const body = data.body.replace(/\r\n/g, '<br/>');
document.getElementById('info').innerHTML = body;
}
document.getElementById('version').innerHTML = data.name;
document.getElementById('date').innerHTML = data.published_at;
document.getElementById('hidden').innerHTML = '';
}
}
}
props: {
i18n: Object,
},
data() {
return {
error: false,
loading: true,
releases: false,
release: {}, // 一个玄学问题,解决ts(2568)低级警告(强迫症去世)
};
},
async mounted() {
try {
const response = await fetch("https://modules.lsposed.org/module/com.sevtinge.hyperceiler.json");
const data = await response.json();
this.loading = false;
this.releases = true;
this.release = data.releases[0];
} catch (error) {
this.loading = false;
this.error = error.message;
}
},
};
</script>


<style scoped>
pre {
white-space: pre-wrap;
}
</style>
50 changes: 25 additions & 25 deletions Download.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
# 下载

- [GitHub Releases 下载](https://github.com/ReChronoRain/HyperCeiler/releases)
- [GitHub Releases 下载](https://github.com/ReChronoRain/HyperCeiler/releases)

- [直链下载](https://api.sevtinge.cc/update.php)
- [直链下载](https://api.sevtinge.cc/update.php)

- [Alist 网盘下载](https://alist.heinu.cc/cemiuiler)
- [Alist 网盘下载](https://alist.heinu.cc/cemiuiler)

> 以上下载方式均可以下载最新版 Alist网盘/Github Releases 可以下载历史版本
> 以上下载方式均可以下载最新版 Alist 网盘/Github Releases 可以下载历史版本
## 安全提醒

::: danger 警告
**非官方发布的安装包可能存在恶意代码,请务必在官方进行下载!**
:::

**HyperCeiler官方更新的位置**
**HyperCeiler 官方更新的位置**

**Telegram:**

- [HyperCeiler | Release & Notice ](https://t.me/cemiuiler_release)
- [HyperCeiler | Release & Notice](https://t.me/cemiuiler_release)

- [Sevtinge's bug workshop](https://t.me/sevtinge_mod)
- [Sevtinge's bug workshop](https://t.me/sevtinge_mod)

**BiliBili:**

- [绀漓丨Sevtinge](https://space.bilibili.com/526912874)
- [绀漓丨 Sevtinge](https://space.bilibili.com/526912874)

>PS:
> PS:
![bilibili](/images/bilibili.png)
![bilibili](/images/bilibili.png)

**X (Twitter):**

- [绀漓丨Sevtinge](https://x.com/CN_Sevtinge)
- [绀漓丨 Sevtinge](https://x.com/CN_Sevtinge)

**GitHub:**
**GitHub:**

- [HyperCeiler](https://github.com/ReChronoRain/HyperCeiler)
- [HyperCeiler](https://github.com/ReChronoRain/HyperCeiler)

**lsposed仓库:**
**lsposed 仓库:**

- [HyperCeiler](https://modules.lsposed.org/module/com.sevtinge.hyperceiler)
- [HyperCeiler](https://modules.lsposed.org/module/com.sevtinge.hyperceiler)

## 意见反馈&交流群
## 意见反馈&交流群

[点击查看](/Support.html)

## 更新日志

<span id="hidden">更新日志由 GitHub 提供,如果持续无法加载,请更换网络环境</span>

版本号: <span id="version">加载中...</span>

更新日期: <span id="date">加载中...</span> (UTC)

<p id="info">加载中...</p>
<FetchInfo :i18n="i18n"/>

<script setup>
import FetchInfo from '/.vitepress/components/FetchInfo.vue'
import FetchInfo from '/.vitepress/components/FetchInfo.vue';

const i18n = {
loading_tips: "正在获取更新日志,请稍后... 更新日志由 Lsposed 提供!如果持续无法加载,请尝试更换网络环境",
version: "版本号:",
update_date: "更新日期:",
error_log: "无法获取更新日志!",
}
</script>
<FetchInfo/>
37 changes: 19 additions & 18 deletions en/Download.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Download

- [GitHub Releases](https://github.com/ReChronoRain/HyperCeiler/releases)
- [GitHub Releases](https://github.com/ReChronoRain/HyperCeiler/releases)

Feedback & Communication: [Click here](/en/Support.html)

**PS: Only support Android 11 or above, Android 10 or below can not be used.**

## Safety reminder

::: danger WARNING
**Non official installation packages may contain malicious code, please be sure to download them from the official website.**
:::
Expand All @@ -15,41 +16,41 @@ Feedback & Communication: [Click here](/en/Support.html)

**Telegram:**

- [HyperCeiler | Release & Notice](https://t.me/cemiuiler_release)
- [HyperCeiler | Release & Notice](https://t.me/cemiuiler_release)

- [Sevtinge's bug workshop](https://t.me/sevtinge_mod)
- [Sevtinge's bug workshop](https://t.me/sevtinge_mod)

**BiliBili:**

- [绀漓丨Sevtinge](https://space.bilibili.com/526912874)
- [绀漓丨 Sevtinge](https://space.bilibili.com/526912874)

>PS:
> PS:
![bilibili](/images/bilibili.png)

**X (Twitter):**

- [绀漓丨Sevtinge](https://x.com/CN_Sevtinge)
- [绀漓丨 Sevtinge](https://x.com/CN_Sevtinge)

**GitHub:**

- [HyperCeiler](https://github.com/ReChronoRain/HyperCeiler)
- [HyperCeiler](https://github.com/ReChronoRain/HyperCeiler)

**LSposited Warehouse:**

- [HyperCeiler](https://modules.lsposed.org/module/com.sevtinge.hyperceiler)

## Version Information

(Chinese Only)

<span id="hidden">The changelog is provided by GitHub, if it continues to fail to load, please change your network environment.</span>
- [HyperCeiler](https://modules.lsposed.org/module/com.sevtinge.hyperceiler)

Version: <span id="version">Loading...</span>
## Version Information (Chinese Only)

Update Date: <span id="date">Loading...</span>(UTC)
<FetchInfo :i18n="i18n"/>

<script setup>
import FetchInfo from '/.vitepress/components/FetchInfo.vue'
import FetchInfo from '/.vitepress/components/FetchInfo.vue';

const i18n = {
loading_tips: "Fetching update log, please wait... Update log provided by Lsposed! If unable to load continuously, try changing the network environment.",
version: "Version: ",
update_date: "Update Date: ",
error_log: "Unable to retrieve update log!",
}
</script>
<FetchInfo/>
44 changes: 22 additions & 22 deletions zh_TW/Download.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# 下載

- [GitHub Releases 下載](https://github.com/ReChronoRain/HyperCeiler/releases)
- [藍奏雲下載點](http://api.sevtinge.cc/update.php)
- [GitHub Releases 下載](https://github.com/ReChronoRain/HyperCeiler/releases)

- [藍奏雲下載點](http://api.sevtinge.cc/update.php)

意見回饋 & 交流群:[點擊查看](/zh_TW/Support.html)

Expand All @@ -14,45 +14,45 @@
**非官方發佈的安裝包可能存在惡意程式碼,請務必在官方進行下載!**
:::

**HyperCeiler官方更新的位置**
**HyperCeiler 官方更新的位置**

**Telegram:**

- [HyperCeiler | Release & Notice]( https://t.me/cemiuiler_release)
- [HyperCeiler | Release & Notice](https://t.me/cemiuiler_release)

- [Sevtinge's bug workshop]( https://t.me/sevtinge_mod)
- [Sevtinge's bug workshop](https://t.me/sevtinge_mod)

**BiliBili:**

- [绀漓丨Sevtinge](https://space.bilibili.com/526912874)
- [绀漓丨 Sevtinge](https://space.bilibili.com/526912874)

>PS:
> PS:
![bilibili](/images/bilibili.png)

**X (Twitter):**

- [绀漓丨Sevtinge](https://x.com/CN_Sevtinge)
- [绀漓丨 Sevtinge](https://x.com/CN_Sevtinge)

**GitHub:**

- [HyperCeiler](https://github.com/ReChronoRain/HyperCeiler)

**LSPosed倉庫:**

- [HyperCeiler](https://modules.lsposed.org/module/com.sevtinge.hyperceiler)

## 更新日誌
- [HyperCeiler](https://github.com/ReChronoRain/HyperCeiler)

<span id="hidden">更新日誌由 GitHub 提供,如果持續無法載入,請檢查您的網路環境。</span>
**LSPosed 倉庫:**

版本號碼: <span id="version">載入中...</span>
- [HyperCeiler](https://modules.lsposed.org/module/com.sevtinge.hyperceiler)

更新日期: <span id="date">載入中...</span> (UTC+8:00)
## 更新日志

<p id="info">載入中...</p>
<FetchInfo :i18n="i18n"/>

<script setup>
import FetchInfo from '/.vitepress/components/FetchInfo.vue'
import FetchInfo from '/.vitepress/components/FetchInfo.vue';

const i18n = {
loading_tips: "正在獲取更新日誌,請稍後... 更新日誌由 Lsposed 提供!如果持續無法加載,請嘗試更換網絡環境",
version: "版本號:",
update_date: "更新日期:",
error_log: "無法獲取更新日誌!",
}
</script>
<FetchInfo/>

0 comments on commit 40911d3

Please sign in to comment.