Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from xiaokaixuan:main #20

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
5 changes: 4 additions & 1 deletion cf-worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function handleRequest(event) {
// 发起 fetch
let fr = (await fetch(url, fp));
outCt = fr.headers.get('content-type');
if(outCt.includes('application/text') || outCt.includes('text/html')) {
if(outCt && (outCt.includes('application/text') || outCt.includes('text/html'))) {
try {
// 添加base
let newFr = new HTMLRewriter()
Expand All @@ -89,6 +89,9 @@ async function handleRequest(event) {
} catch(e) {
}
}
for (const [key, value] of fr.headers.entries()) {
outHeaders.set(key, value);
}
outStatus = fr.status;
outStatusText = fr.statusText;
outBody = fr.body;
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="https://www.mypikpak.com/logo.png" />
<link rel="icon" href="https://mypikpak.com/apple-touch-icon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PikPak</title>
</head>
Expand Down
49 changes: 2 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"dependencies": {
"axios": "^0.23.0",
"clipboard": "^2.0.8",
"dplayer": "^1.26.0",
"element-resize-detector": "^1.2.3",
"plyr": "^3.6.9",
"qs": "^6.10.1",
Expand Down
12 changes: 6 additions & 6 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export const proxy = [
'https://cors.z13.workers.dev',
'https://cors.z14.workers.dev',
'https://cors.z15.workers.dev',
'https://cors.z16.workers.dev',
'https://cors.z17.workers.dev',
'https://cors.z18.workers.dev',
'https://api.13pikpak.cf',
'https://api.14pikpak.cf',
'https://api.15pikpak.cf',
'https://api.16pikpak.cf',
'https://api.17pikpak.cf',
'https://api.18pikpak.cf',
]

export const version = '1.0.0'
7 changes: 6 additions & 1 deletion src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Layout from '../views/layout/index.vue'
const routes: Array<RouteRecordRaw> = [
const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'home',
Expand Down Expand Up @@ -40,6 +40,11 @@ const routes: Array<RouteRecordRaw> = [
name: 'setting',
component: () => import('../views/setting.vue')
},
{
path: 'invited',
name: 'invited',
component: () => import('../views/invited.vue')
},
{
path: 'share',
name: 'share',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ instance.interceptors.response.use(response => {
})
} else {
router.push('/login')
return false
return Promise.reject(error)
}

break;
Expand Down
209 changes: 209 additions & 0 deletions src/views/invited.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
<template>
<div class="list-page">
<n-row>
<n-col :span="12">
<n-statistic label="会员分成(天/次)" :value="invitationInfo?.invited_join_days ">
<template #prefix>
<n-icon>
<diamond />
</n-icon>
</template>
<template #suffix>/ {{invitationInfo?.join_vip_nums}}</template>
</n-statistic>
</n-col>
<n-col :span="12">
<n-statistic label="邀请奖励(天/人)" :value="invitationInfo?.add_days">
<template #prefix>
<n-icon>
<accessible />
</n-icon>
</template>
<template #suffix>/ {{invitationInfo?.invited_nums}}</template>
</n-statistic>
</n-col>
<n-col :span="12">
<n-statistic label="邀请链接" >
<template #prefix>
<n-icon>
<copyright></copyright>
</n-icon>
</template>
<template #default>
<n-space inline>
<n-input type="text" size="small" :value="'https://toapp.mypikpak.com/activity/invited?code=' + invitationCode"></n-input>
<n-button size="small" type="primary" @click="copy('https://toapp.mypikpak.com/activity/invited?code=' + invitationCode)">复制</n-button>
</n-space>
<n-input-group >
</n-input-group>
</template>
</n-statistic>
</n-col>
<n-col :span="12">
<n-statistic label="下载推广" >
<template #prefix>
<n-icon>
<arrow-down-circle ></arrow-down-circle>
</n-icon>
</template>
<template #default>
<n-button size="small" type="primary" @click="getChaApkDownloadLink">立即下载</n-button>
</template>
</n-statistic>
</n-col>
</n-row>
<n-scrollbar style="max-height: calc(100vh - 250px)" @scroll="scrollHandle">
<n-data-table :data="invitedList" :columns="columns"></n-data-table>
<div class="loading" v-if="loading">
<n-spin size="small" />加载中
</div>
</n-scrollbar>
</div>
</template>

<script setup lang="ts">
import { Accessible, Diamond, ArrowDownCircle, Copyright } from '@vicons/tabler';
import ClipboardJS from 'clipboard';
import { DataTableColumns, NDataTable, NGradientText, NTime, NScrollbar, NSpin, NRow, NCol, NStatistic, NIcon, NInputGroup, NInput, NButton, NSpace } from 'naive-ui';
import { computed, h, nextTick, onMounted, ref } from 'vue';
import http from '../utils/axios'
const copy = (value:string) => {
nextTick(() => {
const fakeElement = document.createElement('button')
const clipboard = new ClipboardJS(fakeElement, {
text: () => value,
action: () => 'copy',
})
clipboard.on('success', (e) => {
window.$message.success('复制成功')
clipboard.destroy()
})
clipboard.on('error', (e) => {
window.$message.error('复制失败,您可以F12打开控制台手动复制,或手动复制弹窗输入框')
})
fakeElement.click()
})
}
const invitationCode = ref()
// 生成邀请码
const getInviteCode = async () => {
http.get('https://api-drive.mypikpak.com/vip/v1/activity/inviteCode')
.then((res:any) => {
invitationCode.value = res.data?.code
})
}
const invitationInfo = ref()
const isFirstInvite = computed(() => {
return invitationInfo.value.invited_nums <= 0
})
const typeList = ref({
vip_rebate: '会员分成',
invite_reward: '邀请奖励',
relation: '邀请关系',
})
// 获取当用户的邀请详情
const queryUserInvitationInfo = async () => {
http.get('https://api-drive.mypikpak.com/vip/v1/activity/inviteInfo')
.then(res => {
invitationInfo.value = res.data
})
.catch(() => {
invitationInfo.value = {}
})
}
const columns = ref<DataTableColumns>([
{
title: '邀请用户',
key: 'invited_user'
},
{
title: '奖励类型',
key: 'reward_source',
render: (row:any) => {
return h(NGradientText, {
type: row.reward_source == 'vip_rebate' ? 'info' : 'success'
}, {
default: () => typeList.value[row.reward_source as keyof typeof typeList.value]
})
}
},
{
title: '天数',
key: 'reward_days',
},
{
title: '时间',
key: 'time',
align: 'right',
render: (row) => {
return h(NTime, {
time: new Date(String(row.time) || ''),
format: 'yyyy-MM-dd HH:MM:ss',
})
}
}
])
const invitedList = ref([])
const loading = ref(false)
// 分享裂变: 获取成功邀请的好友列表
const getInvitedList = async ( begin?:string, limit = 30) => {
let url = `https://api-drive.mypikpak.com/vip/v1/activity/inviteList`;
if (begin) {
url += `?begin=${begin}&limit=${limit}`;
}
loading.value = true
http.get(url)
.then((res:any) => {
if(!begin) {
invitedList.value = []
}
invitedList.value = invitedList.value.concat(res.data?.data || [])
})
.finally(() => {
loading.value = false
})
}

// 分享裂变: 获取CHA下载包
const getChaApkDownloadLink = () => {
http.get(`https://api-drive.mypikpak.com/package/v1/apk/url/${invitationCode.value}`)
.then((res:any) => {
window.open(res.data.apk_url)
})
}
const scrollHandle = (e:any) => {
if(e.target.offsetHeight + e.target.scrollTop >= e.target.scrollHeight - 30) {
if(invitedList.value.length < invitationInfo.value.invited_nums && !loading.value) {
getInvitedList((invitedList.value[invitedList.value.length - 1] as any).time)
}
}
}
onMounted(() => {
getInviteCode()
queryUserInvitationInfo()
getInvitedList()
})

</script>

<style lang="scss">
.list-page {
padding: 40px;
}
@media(max-width: 968px) {
.list-page {
padding: 10px;
}
.file-info img {
display: none;
}
}
.list-page .loading {
margin-top: 20px;
text-align: center;
color: rgba(37, 38, 43, 0.36);
}
.list-page .loading .n-spin-body {
vertical-align: middle;
margin-right: 10px;
}
</style>
Loading