Skip to content

Commit

Permalink
网页闲逛偶遇Bug,反复触发让人头疼,花点时间修复它。
Browse files Browse the repository at this point in the history
  • Loading branch information
AyalaKaguya committed Jul 9, 2024
1 parent f0c007d commit ec8fa76
Show file tree
Hide file tree
Showing 8 changed files with 2,511 additions and 1,324 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"dev": "vuepress dev src",
"build": "vuepress build src",
"clean-dev": "vuepress dev src --clean-cache",
"clean-package": "yarn cache clean --force",
"update-package": "yarn dlx vp-update"
"clean-package": "yarn cache clean --force"
},
"repository": {
"type": "git",
Expand All @@ -20,14 +19,15 @@
},
"homepage": "https://github.com/easybangumiorg/.github#readme",
"devDependencies": {
"vuepress": "2.0.0-rc.0",
"vuepress-theme-reco": "2.0.0-rc.6",
"@vuepress/plugin-google-analytics": "^2.0.0-rc.0",
"@vuepress/plugin-register-components": "^2.0.0-rc.0",
"@vuepress/plugin-search": "^2.0.0-rc.0"
"@vuepress/plugin-google-analytics": "^2.0.0-rc.15",
"@vuepress/plugin-register-components": "^2.0.0-rc.15",
"@vuepress/plugin-search": "^2.0.0-rc.18",
"vuepress": "2.0.0-rc.14",
"vuepress-theme-reco": "2.0.0-rc.16"
},
"dependencies": {
"marked": "^4.3.0",
"@types/marked": "^6.0.0",
"marked": "^13.0.2",
"moment": "^2.29.4",
"vuex": "^4.0.2"
}
Expand Down
64 changes: 35 additions & 29 deletions src/.vuepress/components/DownloadButtons.vue
Original file line number Diff line number Diff line change
@@ -1,53 +1,59 @@
<script setup>
import { useStore } from 'vuex'
import { onMounted, ref } from 'vue'
import { onMounted, ref, computed } from 'vue'
const store = useStore()
let stable_data = null
const tag = ref({
stable: "loading",
const data = ref({
tag: "x.x.x",
branch: "main",
author: "unknown",
version_list: []
})
onMounted(async () => {
stable_data = await store.dispatch("getStableReleaseData")
tag.value.stable = stable_data.tag_name
const stable_data = await store.dispatch("getStableReleaseData")
data.value.tag = stable_data.tag_name
data.value.branch = stable_data.target_commitish
data.value.author = stable_data.author.login
data.value.version_list = stable_data.assets
})
const downloadStable = () => {
const url = getDownloadPath(stable_data, "https://github.com/easybangumiorg/EasyBangumi/releases/latest")
const download = (url) => {
window.location.assign(url)
}
const getDownloadPath = (release, fallbackUrl) => {
let apkUrl;
if (release && release.assets) {
release.assets.some(asset => {
if (asset.browser_download_url.endsWith('.apk')) {
apkUrl = asset.browser_download_url
return true
}
return false
})
const parseVersion = (version) => {
version = version.replace("easybangumi", "")
version = version.replace(".apk", "")
version = version.replace(data.value.tag, "")
version = version.replaceAll("-", " ")
version = version.trim()
if (version === "") {
version = "Universal"
}
return apkUrl || fallbackUrl
return version
}
const totalDownload = computed(() => {
return data.value.version_list.reduce((acc, cur) => acc + cur.download_count, 0)
})
</script>

<template>
<div id="DownloadButtons">
<button class="stable" @click="downloadStable">
<span>Stable</span>
<button class="stable" v-for="dlinfo in data.version_list" :id="dlinfo.id"
@click="download(data.browser_download_url)">
<span>{{ data.tag }}</span>
<br>
<span class="downloadTag">{{ tag.stable }}</span>
<span class="downloadTag">{{ parseVersion(dlinfo.name) }}</span>
</button>
<span class="versionNotice">
Requires
<strong>Android 6.0</strong>
or higher.
需要<strong>Android 6.0</strong>或更高版本。
</span>
</div>
</template>
</template>

<style lang="scss">
#DownloadButtons {
Expand All @@ -61,9 +67,9 @@ const getDownloadPath = (release, fallbackUrl) => {
color: #ffffff;
line-height: 1;
margin: 0.1em !important;
padding: 12px 32px;
border-radius: 0.2rem;
margin: 0 0.5em !important;
padding: 1.2rem 32px;
border-radius: 0.5rem;
border: 1px solid #dcdfe6;
width: 10em;
Expand Down
2 changes: 1 addition & 1 deletion src/.vuepress/components/ExtensionsWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default {
</script>

<template>
<div v-if="loading" style="min-height: 200px">loading...</div>
<div v-if="loading" style="min-height: 200px">加载中...</div>
<div v-else>
<ExtensionList :list="extensions" :total-count="extensions.length" />
</div>
Expand Down
57 changes: 0 additions & 57 deletions src/.vuepress/components/ReleaseDate.vue

This file was deleted.

23 changes: 13 additions & 10 deletions src/.vuepress/components/WhatsNew.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@ export default {
...mapState(['stable', 'nightly']),
stableBody() {
const body = this.stable && this.stable.data && this.stable.data.body
let body = this.stable && this.stable.data && this.stable.data.body
if (!body) {
return 'loading...'
return '加载中...'
}
return marked(body).replace(
/(?<=\(|(, ))@(.*?)(?=\)|(, ))/g,
"<a href='https://github.com/$2' target='_blank' rel='noopener'>@$2</a>"
)
body = body.split('\r\n')
for (let i = 0; i < body.length; i++) {
if (i > 0) {
body[i] = `- ${body[i]}`
}
}
return marked.parse(body.join('\r\n'))
}
}
};
Expand All @@ -23,15 +26,16 @@ export default {
<template>
<div class="guide whatsNew">
<p class="title">
What's new
更新日志
</p>
<div v-html="stableBody"></div>
<div class="note">
<p>
View the full release
<a href="https://github.com/easybangumiorg/easybangumi/releases/latest" target="_blank" rel="noopener">
here
GitHub
</a>
上查看
</p>
</div>
</div>
Expand All @@ -53,7 +57,6 @@ export default {
}
.note {
color: rgba(0, 0, 0, .4);
font-size: .9rem;
text-align: right;
}
Expand Down
48 changes: 24 additions & 24 deletions src/.vuepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineUserConfig } from 'vuepress'
import { viteBundler } from '@vuepress/bundler-vite'
import { recoTheme } from 'vuepress-theme-reco'
// import { registerComponentsPlugin } from '@vuepress/plugin-register-components'
// import { googleAnalyticsPlugin } from '@vuepress/plugin-google-analytics'
// import { searchPlugin } from '@vuepress/plugin-search'
// import { getDirname, path } from '@vuepress/utils'

// const __dirname = getDirname(import.meta.url)
import { registerComponentsPlugin } from '@vuepress/plugin-register-components'
import { googleAnalyticsPlugin } from '@vuepress/plugin-google-analytics'
import { searchPlugin } from '@vuepress/plugin-search'
import { getDirname, path } from '@vuepress/utils'
const __dirname = getDirname(import.meta.url)

export default defineUserConfig({
// 头部设置
Expand All @@ -16,14 +16,17 @@ export default defineUserConfig({
['meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0' }],
],

bundler: viteBundler({
viteOptions: {},
vuePluginOptions: {},
}),

// 主题配置
theme: recoTheme({

// 基本配置
style: "@vuepress-reco/style-default",
logo: "/icons/logo.ico",
repo: "easybangumiorg/website",
sourceDir: "src",
// 协同编辑
docsRepo: "https://github.com/easybangumiorg/website",
docsBranch: 'main',
Expand Down Expand Up @@ -96,21 +99,18 @@ export default defineUserConfig({

// 插件
plugins: [
// registerComponentsPlugin({
// componentsDir: path.resolve(__dirname, './components'),
// }),
// googleAnalyticsPlugin({
// id: "G-9CF0ZQPB32"
// }),
// searchPlugin({
// locales: {
// '/en/': {
// placeholder: 'Search',
// },
// '/': {
// placeholder: '搜索',
// },
// },
// }),
registerComponentsPlugin({
componentsDir: path.resolve(__dirname, './components'),
}),
googleAnalyticsPlugin({
id: "G-9CF0ZQPB32"
}),
searchPlugin({
locales: {
'/': {
placeholder: '搜索',
},
},
}),
],
})
2 changes: 1 addition & 1 deletion src/download/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sidebar: false

## 从 Github 上下载

在一般情况下应当选择此渠道下载,更新最快
在一般情况下应当选择此渠道下载,更新最快,如果无法访问也可以直接跳转到[GitHub Release](https://github.com/easybangumiorg/EasyBangumi/releases/latest)

<DownloadButtons/>

Expand Down
Loading

1 comment on commit ec8fa76

@AyalaKaguya
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

鉴定为:玩法环玩的

Please sign in to comment.