看广场动态特权是否为会员特权改为服务器控制

This commit is contained in:
jueweijue 2024-05-02 21:57:47 +08:00
parent 39e50ca2ce
commit c8f29ef9c3
6 changed files with 581 additions and 516 deletions

1027
App.jsx

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
import React, { useState, createContext, useContext, useEffect } from "react";
import baseRequest from "../utils/baseRequest";
import { generateSignature } from "../utils/crypto";
const VipVisibilityContext = createContext();
export const VipVisibilityProvider = ({ children }) => {
const [isVipVisible, setIsVipVisible] = useState(true);
useEffect(() => {
const init = async () => {
try {
const apiUrl = process.env.EXPO_PUBLIC_API_URL;
const base = await baseRequest();
const signature = await generateSignature({
...base,
});
const _response = await fetch(
`${apiUrl}/api/moment/is_moment_image_encrypt_enabled?signature=${signature}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
...base,
}),
}
);
const _data = await _response.json();
if (_data.ret === -1) {
return;
}
setIsVipVisible(_data.data === 1 ? true : false);
} catch (error) {
console.error(error);
}
};
init();
}, []);
return (
<VipVisibilityContext.Provider value={{ isVipVisible }}>
{children}
</VipVisibilityContext.Provider>
);
};
export const useVipVisibility = () => useContext(VipVisibilityContext);

View File

@ -16,11 +16,15 @@ import baseRequest from "../../utils/baseRequest";
import { generateSignature } from "../../utils/crypto";
import Toast from "react-native-toast-message";
import { TabView, SceneMap, TabBar } from "react-native-tab-view";
import { useVipVisibility } from "../../context/VipVisibilityProvider";
export default function Posts({ navigation }) {
const tailwind = useTailwind();
const insets = useSafeAreaInsets();
//vip
const { isVipVisible } = useVipVisibility();
//focus
const [blur, setBlur] = useState(true);
useFocusEffect(
@ -60,7 +64,7 @@ export default function Posts({ navigation }) {
}
const role = accountData.data.account.role;
const isVip = accountData.data.account.is_a_member;
if (role !== 0 || isVip === 1) {
if (role !== 0 || isVip === 1 || !isVipVisible) {
setBlur(false);
} else {
setBlur(true);
@ -71,7 +75,7 @@ export default function Posts({ navigation }) {
}
};
getData();
}, [])
}, [isVipVisible])
);
//tab

View File

@ -15,10 +15,14 @@ import { FlashList } from "@shopify/flash-list";
import Post from "../../components/Post";
import { get } from "../../utils/storeInfo";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useVipVisibility } from "../../context/VipVisibilityProvider";
export default function StreamerPosts({ navigation, route }) {
const insets = useSafeAreaInsets();
//vip
const { isVipVisible } = useVipVisibility();
//
const [vipPrice, setVipPrice] = useState();
const getVipPrice = async () => {
@ -126,7 +130,7 @@ export default function StreamerPosts({ navigation, route }) {
const account = await get("account");
const role = account.role;
const isVip = account.is_a_member;
if (role !== 0 || isVip === 1) {
if (role !== 0 || isVip === 1 || !isVipVisible) {
return setBlur(false);
}
return setBlur(true);

View File

@ -30,6 +30,7 @@ import StreamerProfileSkeleton from "./skeleton";
import { generateSignature } from "../../utils/crypto";
import Svg, { Path } from "react-native-svg";
import { useImageViewer } from "../../context/ImageViewProvider";
import { useVipVisibility } from "../../context/VipVisibilityProvider";
const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk";
@ -54,13 +55,16 @@ export default function StreamerProfile({ navigation, route }) {
});
}, []);
//vip
const { isVipVisible } = useVipVisibility();
//blur
const [blur, setBlur] = useState(true);
const checkBlur = async () => {
const account = await get("account");
const role = account.role;
const isVip = account.is_a_member;
if (role !== 0 || isVip === 1) {
if (role !== 0 || isVip === 1 || !isVipVisible) {
return setBlur(false);
}
return setBlur(true);

View File

@ -35,7 +35,6 @@ export async function storeAppInfo() {
}
const b_did = await getDid();
console.log(b_did);
const b_ver = Application.nativeApplicationVersion;
const b_dt = Device.osName === "Android" ? 0 : 1;
const b_ch = "production";