将安装包链接改为从apollo获取;增加cookies时效
This commit is contained in:
parent
39c4fba3df
commit
51e054cd29
|
@ -10,6 +10,8 @@ import IosInstallStepModal from "@/components/IosInstallStepModal/page";
|
|||
|
||||
export default function Download({ params }) {
|
||||
const [deviceType, setDeviceType] = useState("");
|
||||
const [installInfo, setInstallInfo] = useState({});
|
||||
|
||||
useEffect(() => {
|
||||
const userAgent = navigator.userAgent;
|
||||
//区分设备类型
|
||||
|
@ -20,6 +22,37 @@ export default function Download({ params }) {
|
|||
} else {
|
||||
setDeviceType("pc");
|
||||
}
|
||||
|
||||
const handleIosInstallButtonVisibility = async () => {
|
||||
try {
|
||||
const base = baseRequest();
|
||||
const body = {
|
||||
...base,
|
||||
};
|
||||
const signature = generateSignature(body);
|
||||
const _response = await fetch(
|
||||
`/api/app/install_info?signature=${signature}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
}
|
||||
);
|
||||
const _data = await _response.json();
|
||||
if (_data.ret === -1) {
|
||||
Toast.show({
|
||||
content: _data.msg,
|
||||
});
|
||||
return;
|
||||
}
|
||||
setInstallInfo(_data.data);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
handleIosInstallButtonVisibility();
|
||||
}, []);
|
||||
|
||||
//点下载在剪贴板写入主播邀请信息
|
||||
|
@ -172,16 +205,18 @@ export default function Download({ params }) {
|
|||
)}
|
||||
</div>
|
||||
<div className="flex flex-col items-center">
|
||||
{deviceType !== "pc" && (
|
||||
{(deviceType === "Android" ||
|
||||
(deviceType === "ios" &&
|
||||
installInfo?.is_ios_install_button_visible === 1)) && (
|
||||
<div
|
||||
className="btn bg-gradient-to-r from-[#FF668B] to-[#FF66F0] rounded-full text-white text-lg font-medium w-64 h-14"
|
||||
className={`btn bg-gradient-to-r from-[#FF668B] to-[#FF66F0] rounded-full text-white text-lg font-medium w-64 h-14`}
|
||||
onClick={() => {
|
||||
copyInviter();
|
||||
if (deviceType === "ios") setIsIosInstallStepModalVisible(true);
|
||||
const url =
|
||||
deviceType === "ios"
|
||||
? "itms-services://?action=download-manifest&url=https://filecdntx01.tiefen.fun/appdownload/ironfans.plist"
|
||||
: "https://filecdntx01.tiefen.fun/appdownload/ironfans1.5.2.apk";
|
||||
? `itms-services://?action=download-manifest&url=${installInfo?.ios_url}`
|
||||
: installInfo?.android_url;
|
||||
window.location.href = url;
|
||||
if (deviceType === "ios") {
|
||||
setIsIosInstallStepModalVisible(true);
|
||||
|
|
15
app/page.jsx
15
app/page.jsx
|
@ -10,8 +10,8 @@ import { generateSignature } from "@/utils/crypto";
|
|||
|
||||
export default function Home() {
|
||||
const [deviceType, setDeviceType] = useState("");
|
||||
const [isIosInstallButtonVisible, setIsIosInstallButtonVisible] =
|
||||
useState(true);
|
||||
const [installInfo, setInstallInfo] = useState({});
|
||||
|
||||
useEffect(() => {
|
||||
const userAgent = navigator.userAgent;
|
||||
//区分设备类型
|
||||
|
@ -31,7 +31,7 @@ export default function Home() {
|
|||
};
|
||||
const signature = generateSignature(body);
|
||||
const _response = await fetch(
|
||||
`/api/app/is_ios_install_button_visible?signature=${signature}`,
|
||||
`/api/app/install_info?signature=${signature}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
|
@ -47,7 +47,7 @@ export default function Home() {
|
|||
});
|
||||
return;
|
||||
}
|
||||
if (_data.data === 0) setIsIosInstallButtonVisible(false);
|
||||
setInstallInfo(_data.data);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
@ -203,7 +203,8 @@ export default function Home() {
|
|||
</div>
|
||||
)}
|
||||
{(deviceType === "Android" ||
|
||||
(deviceType === "ios" && isIosInstallButtonVisible)) && (
|
||||
(deviceType === "ios" &&
|
||||
installInfo?.is_ios_install_button_visible === 1)) && (
|
||||
<div
|
||||
className={`btn ${
|
||||
deviceType === "ios"
|
||||
|
@ -214,8 +215,8 @@ export default function Home() {
|
|||
if (deviceType === "ios") setIsIosInstallStepModalVisible(true);
|
||||
const url =
|
||||
deviceType === "ios"
|
||||
? "itms-services://?action=download-manifest&url=https://filecdntx01.tiefen.fun/appdownload/ironfans.plist"
|
||||
: "https://filecdntx01.tiefen.fun/appdownload/ironfans1.5.2.apk";
|
||||
? `itms-services://?action=download-manifest&url=${installInfo?.ios_url}`
|
||||
: installInfo?.android_url;
|
||||
window.location.href = url;
|
||||
if (deviceType === "ios") {
|
||||
setIsIosInstallStepModalVisible(true);
|
||||
|
|
|
@ -37,8 +37,8 @@ export async function checkAuth() {
|
|||
}
|
||||
|
||||
export function signIn(data) {
|
||||
setCookie("token", data.data.token);
|
||||
setCookie("account", data.data.account);
|
||||
setCookie("token", data.data.token, { maxAge: 60 * 60 * 24 * 365 * 10 });
|
||||
setCookie("account", data.data.account, { maxAge: 60 * 60 * 24 * 365 * 10 });
|
||||
}
|
||||
|
||||
export function signOut() {
|
||||
|
|
Loading…
Reference in New Issue