Skip to content

Commit

Permalink
change api url
Browse files Browse the repository at this point in the history
  • Loading branch information
ShirasawaSama committed Apr 18, 2020
1 parent ce0d32a commit a6b7fbc
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 44 deletions.
19 changes: 10 additions & 9 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload to cos
uses: TencentCloud/cos-action@v1
- name: Deploy static to Tencent CloudBase
id: deployStatic
uses: TencentCloudBase/cloudbase-action@v1
with:
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
cos_bucket: ${{ secrets.COS_BUCKET }}
cos_region: ${{ secrets.COS_REGION }}
local_path: dist
remote_path: /
clean: true
secretId: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
secretKey: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
envId: ${{ secrets.ENV_ID }}
staticSrcPath: dist

- name: Get the deploy result
run: echo "Deploy to cloudbase result ${{ steps.deployStatic.outputs.deployResult }}"
Binary file modified assets/screenshots/accounts-cn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/accounts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/home-cn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/home.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/plugins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/versions-cn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/screenshots/versions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 10 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const data: { os: { name?: string }, cpu: { architecture?: string } } = new (window as any).UAParser().getResult()

const os = (data.os.name || '').toLowerCase()
const isX64 = (data.cpu.architecture || '').indexOf('64') !== -1

const cn = {
home: require('../assets/screenshots/home-cn.png'),
Expand All @@ -17,19 +18,19 @@ const en = {
const changeText = () => {
let text: string
let ext: string
if (os.startsWith('android') || os.startsWith('blackberry') || os.startsWith('ios') || os.startsWith('windows phone')) {
if (os === 'android' || os === 'blackberry' || os === 'ios' || os === 'windows phone') {
text = $i('notSupport')
$('#download-now').prop('disabled', true)
} else if (os.startsWith('windows')) {
text = `Windows ${$i('32')}`
} else if (os === 'windows') {
text = `Windows ${$i(isX64 ? '64' : '32')}`
ext = 'exe'
} else if (os.startsWith('mac os')) {
} else if (os === 'mac os') {
text = `MACOS ${$i('64')}`
ext = 'dmg'
} else if (os.startsWith('debian') || os.startsWith('ubuntu') || os.startsWith('deepin')) {
} else if (os === 'debian' || os === 'ubuntu' || os === 'deepin') {
text = `Debian Linux ${$i('64')}`
ext = 'deb'
} else if (os.startsWith('redhat') || os.startsWith('suse') || os.startsWith('centos')) {
} else if (os === 'redhat' || os === 'suse' || os === 'centos') {
text = `RedHat Linux ${$i('64')}`
ext = 'rpm'
} else {
Expand All @@ -40,7 +41,9 @@ const changeText = () => {
if (ext) {
$('#release-type').text(text + ` (${ext})`)
btn.onclick = () => void window.open(
`https://xmcl.azurewebsites.net/api/pl-get-release?ext=${ext}&gfw=${(window as any).currentLang === 'zh-cn'}`,
(window as any).currentLang === 'zh-cn'
? 'https://dl.pl.apisium.cn/pl/PureLauncher.' + ext
: 'https://github.com/Apisium/PureLauncher/releases/latest/download/PureLauncher.' + ext,
'_blank'
)
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ const f1 = (window as any).setLanguague = (str: string, exec: boolean) => {
const isCN = str === 'zh-cn'
$('[data-ext]').each((_, it) => {
const e = $(it)
const ext = e.data('ext')
e.prop(
'href',
`https://xmcl.azurewebsites.net/api/pl-get-release?ext=${e.data('ext')}&gfw=${isCN}`
isCN
? 'https://dl.pl.apisium.cn/pl/PureLauncher.' + ext
: 'https://github.com/Apisium/PureLauncher/releases/latest/download/PureLauncher.' + ext
)
})
if (!exec) fn1(str)
Expand Down
57 changes: 30 additions & 27 deletions src/versions.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import copy from 'copy-to-clipboard'

interface Version {
id: string
time: number
fabric?: string
forge?: string
optifine?: [string, string]
type?: 'snapshot' | 'old'
i: string // id
t: number // time
a?: string // fabric
f?: string // forge
o?: [string, string] // optifine
k?: 1 | 2 // kind
}

interface Data {
Expand Down Expand Up @@ -38,32 +38,35 @@ const genList = () => {
const old = $i('oldVersion')
const releaseTime = $i('releaseTime')

const versionsStr = data.versions.map((it, i) => {
if (!showOldVersion && it.type) return
let versionsStr = ''
const len = data.versions.length
for (let i = 0; i < len; i++) {
const it = data.versions[i]
if (!showOldVersion && it.k) continue
let type: string
let typeName: string
switch (it.type) {
case 'snapshot':
switch (it.k) {
case 1:
type = 'snapshot'
typeName = snapshot
break
case 'old':
case 2:
type = 'snapshot'
typeName = old
break
default:
type = 'release'
typeName = release
}
const date = new Date(it.time)
return `<li onclick="install(event, ${i}, 0)">
${it.id} <span class="badge ${type}">${typeName}</span>
${it.fabric ? `<span class="badge fabric" onclick="install(event, ${i}, 1)">Fabric</span>` : ''}
${it.forge ? `<span class="badge forge" onclick="install(event, ${i}, 2)">Forge</span>` : ''}
${it.optifine ? `<span class="badge optifine" onclick="install(event, ${i}, 3)">Optifine</span>` : ''}
const date = new Date(it.t * 1000)
versionsStr += `<li onclick="install(event, ${i}, 0)">
${it.i} <span class="badge ${type}">${typeName}</span>
${it.a ? `<span class="badge fabric" onclick="install(event, ${i}, 1)">Fabric</span>` : ''}
${it.f ? `<span class="badge forge" onclick="install(event, ${i}, 2)">Forge</span>` : ''}
${it.o ? `<span class="badge optifine" onclick="install(event, ${i}, 3)">Optifine</span>` : ''}
<p>${releaseTime}: ${date.getFullYear()}-${ft(date.getMonth() + 1)}-${ft(date.getDay())} ${ft(date.getHours())}:${ft(date.getHours())}</p>
</li>`
}).filter(Boolean).join('')
}
$('#book-body').html(`<ul>
<li id="list-header">${$i('versionsTopText')} <span class="badge fabric">Fabric</span> <span class="badge forge">Forge</span> <span class="badge optifine">Optifine</span></li>
${versionsStr}
Expand All @@ -72,22 +75,22 @@ const genList = () => {

(window as any).install = (e: MouseEvent, id: number, type: 0 | 1 | 2 | 3) => {
const v = data.versions[id]
let json: any = { type: 'Version', mcVersion: v.id }
let json: any = { type: 'Version', mcVersion: v.i }
switch (type) {
case 1:
json.id = v.fabric + '-Fabric'
json.$fabric = [v.fabric, data.latest.fabricLoader]
json.id = v.a + '-Fabric'
json.$fabric = [v.a, data.latest.fabricLoader]
break
case 2:
json.id = v.id + '-Forge' + '-' + v.forge
json.$forge = v.forge
json.id = v.i + '-Forge' + '-' + v.f
json.$forge = v.f
break
case 3:
json.id = v.id + '-Optifine' + '-' + v.optifine[0] + '-' + v.optifine[0]
json.$optifine = v.optifine
json.id = v.i + '-Optifine' + '-' + v.o[0] + '-' + v.o[0]
json.$optifine = v.o
break
default:
json.id = v.id
json.id = v.i
json.$vanilla = true
}
json = JSON.stringify(json)
Expand All @@ -97,7 +100,7 @@ const genList = () => {
else e.cancelBubble = true
}

fetch('https://xmcl.blob.core.windows.net/pure-launcher/vanillaData.json')
fetch('https://s.pl.apisium.cn/minecraft.json')
.then(it => it.json())
.then((it: Data) => {
data = it
Expand Down

0 comments on commit a6b7fbc

Please sign in to comment.