shuisheng 1 rok temu
rodzic
commit
adb70f4d44

+ 4 - 0
src/api/liveRoom.ts

@@ -21,6 +21,10 @@ export function fetchUpdateLiveRoomKey() {
   });
 }
 
+export function fetchUpdateMyLiveRoom(data: ILiveRoom) {
+  return request.put('/live_room/update_my_live_room', data);
+}
+
 export function fetchFindLiveRoom(roomId: string) {
   return request.get<ILiveRoom>(`/live_room/find/${roomId}`);
 }

+ 31 - 0
src/constant.ts

@@ -159,6 +159,34 @@ export const DEFAULT_AUTH_INFO = {
     id: 12,
     auth_value: 'LIVE_PULL_SVIP',
   },
+  LIVE_PUSH_CDN: {
+    id: 13,
+    auth_value: 'LIVE_PUSH_CDN',
+  },
+  LIVE_PUSH_FORWARD_BILIBILI: {
+    id: 14,
+    auth_value: 'LIVE_PUSH_FORWARD_BILIBILI',
+  },
+  LIVE_PUSH_FORWARD_HUYA: {
+    id: 15,
+    auth_value: 'LIVE_PUSH_FORWARD_HUYA',
+  },
+  LIVE_PUSH_FORWARD_DOUYU: {
+    id: 16,
+    auth_value: 'LIVE_PUSH_FORWARD_DOUYU',
+  },
+  LIVE_PUSH_FORWARD_DOUYIN: {
+    id: 17,
+    auth_value: 'LIVE_PUSH_FORWARD_DOUYIN',
+  },
+  LIVE_PUSH_FORWARD_KUAISHOU: {
+    id: 18,
+    auth_value: 'LIVE_PUSH_FORWARD_KUAISHOU',
+  },
+  LIVE_PUSH_FORWARD_XIAOHONGSHU: {
+    id: 19,
+    auth_value: 'LIVE_PUSH_FORWARD_XIAOHONGSHU',
+  },
 };
 
 // 全局的cookie的key
@@ -198,6 +226,9 @@ export const liveRoomTypeEnumMap = {
   [LiveRoomTypeEnum.wertc_live]: 'webrtc直播',
   [LiveRoomTypeEnum.wertc_meeting_one]: 'webrtc会议一',
   [LiveRoomTypeEnum.wertc_meeting_two]: 'webrtc会议二',
+  [LiveRoomTypeEnum.forward_bilibili]: '转推b站',
+  [LiveRoomTypeEnum.forward_huya]: '转推虎牙',
+  [LiveRoomTypeEnum.forward_all]: '转推所有',
 };
 
 export const sliderList = [

+ 39 - 3
src/layout/pc/head/index.vue

@@ -619,9 +619,6 @@ function handleStartLive(key: LiveRoomTypeEnum) {
       LiveRoomTypeEnum.msr,
       LiveRoomTypeEnum.tencent_css,
       LiveRoomTypeEnum.tencent_css_pk,
-      LiveRoomTypeEnum.forward_all,
-      LiveRoomTypeEnum.forward_bilibili,
-      LiveRoomTypeEnum.forward_huya,
     ].includes(key)
   ) {
     if (
@@ -633,6 +630,45 @@ function handleStartLive(key: LiveRoomTypeEnum) {
       return;
     }
   }
+  if (key === LiveRoomTypeEnum.forward_huya) {
+    if (
+      !userStore.userInfo?.auths?.find(
+        (v) =>
+          v.auth_value === DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_HUYA.auth_value
+      )
+    ) {
+      window.$message.info('权限不足,请更换其他开播方式');
+      return;
+    }
+  }
+  if (key === LiveRoomTypeEnum.forward_bilibili) {
+    if (
+      !userStore.userInfo?.auths?.find(
+        (v) =>
+          v.auth_value ===
+          DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_BILIBILI.auth_value
+      )
+    ) {
+      window.$message.info('权限不足,请更换其他开播方式');
+      return;
+    }
+  }
+  if (key === LiveRoomTypeEnum.forward_all) {
+    if (
+      !userStore.userInfo?.auths?.find(
+        (v) =>
+          v.auth_value === DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_HUYA.auth_value
+      ) &&
+      !userStore.userInfo?.auths?.find(
+        (v) =>
+          v.auth_value ===
+          DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_BILIBILI.auth_value
+      )
+    ) {
+      window.$message.info('权限不足,请更换其他开播方式');
+      return;
+    }
+  }
   const url = router.resolve({
     name: routerName.push,
     query: { liveType: key },

+ 1 - 1
src/types/ILiveRoom.ts

@@ -33,7 +33,7 @@ export enum LiveRoomTypeEnum {
   tencent_css_pk,
   /** 转推b站 */
   forward_bilibili,
-  /** 转推斗鱼 */
+  /** 转推虎牙 */
   forward_huya,
   /** 转推所有 */
   forward_all,

+ 8 - 0
src/utils/request.ts

@@ -116,6 +116,14 @@ class MyAxios {
   ): MyAxiosPromise<T> {
     return this.instance.post(url, data, config);
   }
+
+  put<T = any>(
+    url: string,
+    data?: {} | undefined,
+    config?: AxiosRequestConfig
+  ): MyAxiosPromise<T> {
+    return this.instance.put(url, data, config);
+  }
 }
 
 export default new MyAxios({

+ 248 - 3
src/views/my/index.vue

@@ -192,6 +192,234 @@
               请联系作者开通~
             </div>
           </div>
+
+          <div>
+            转推b站:
+            <div
+              class="cdn"
+              v-if="
+                userStore.userInfo?.auths?.find(
+                  (v) =>
+                    v.auth_value ===
+                    DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_BILIBILI.auth_value
+                )
+              "
+            >
+              <n-input-group>
+                <n-input
+                  style="width: 500px"
+                  v-model:value="liveRoomInfo!.forward_bilibili_url"
+                  type="text"
+                  placeholder="请输入转推b站url"
+                />
+
+                <n-button
+                  type="primary"
+                  ghost
+                  @click="handleUpdateMyLiveRoom()"
+                >
+                  更新
+                </n-button>
+              </n-input-group>
+            </div>
+            <div
+              v-else
+              class="link"
+              @click="router.push({ name: routerName.author })"
+            >
+              请联系作者开通~
+            </div>
+          </div>
+
+          <div>
+            转推虎牙:
+            <div
+              class="cdn"
+              v-if="
+                userStore.userInfo?.auths?.find(
+                  (v) =>
+                    v.auth_value ===
+                    DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_HUYA.auth_value
+                )
+              "
+            >
+              <n-input-group>
+                <n-input
+                  style="width: 500px"
+                  v-model:value="liveRoomInfo!.forward_huya_url"
+                  type="text"
+                  placeholder="请输入转推虎牙url"
+                />
+
+                <n-button
+                  type="primary"
+                  ghost
+                  @click="handleUpdateMyLiveRoom()"
+                >
+                  更新
+                </n-button>
+              </n-input-group>
+            </div>
+            <div
+              v-else
+              class="link"
+              @click="router.push({ name: routerName.author })"
+            >
+              请联系作者开通~
+            </div>
+          </div>
+
+          <div>
+            转推抖音:
+            <div
+              class="cdn"
+              v-if="
+                userStore.userInfo?.auths?.find(
+                  (v) =>
+                    v.auth_value ===
+                    DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_DOUYIN.auth_value
+                )
+              "
+            >
+              <n-input-group>
+                <n-input
+                  style="width: 500px"
+                  v-model:value="liveRoomInfo!.forward_douyin_url"
+                  type="text"
+                  placeholder="请输入转推抖音url"
+                />
+
+                <n-button
+                  type="primary"
+                  ghost
+                  @click="handleUpdateMyLiveRoom()"
+                >
+                  更新
+                </n-button>
+              </n-input-group>
+            </div>
+            <div
+              v-else
+              class="link"
+              @click="router.push({ name: routerName.author })"
+            >
+              请联系作者开通~
+            </div>
+          </div>
+
+          <div>
+            转推斗鱼:
+            <div
+              class="cdn"
+              v-if="
+                userStore.userInfo?.auths?.find(
+                  (v) =>
+                    v.auth_value ===
+                    DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_DOUYU.auth_value
+                )
+              "
+            >
+              <n-input-group>
+                <n-input
+                  style="width: 500px"
+                  v-model:value="liveRoomInfo!.forward_douyu_url"
+                  type="text"
+                  placeholder="请输入转推斗鱼url"
+                />
+
+                <n-button
+                  type="primary"
+                  ghost
+                  @click="handleUpdateMyLiveRoom()"
+                >
+                  更新
+                </n-button>
+              </n-input-group>
+            </div>
+            <div
+              v-else
+              class="link"
+              @click="router.push({ name: routerName.author })"
+            >
+              请联系作者开通~
+            </div>
+          </div>
+
+          <div>
+            转推小红书:
+            <div
+              class="cdn"
+              v-if="
+                userStore.userInfo?.auths?.find(
+                  (v) =>
+                    v.auth_value ===
+                    DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_XIAOHONGSHU.auth_value
+                )
+              "
+            >
+              <n-input-group>
+                <n-input
+                  style="width: 500px"
+                  v-model:value="liveRoomInfo!.forward_xiaohongshu_url"
+                  type="text"
+                  placeholder="请输入转推小红书url"
+                />
+
+                <n-button
+                  type="primary"
+                  ghost
+                  @click="handleUpdateMyLiveRoom()"
+                >
+                  更新
+                </n-button>
+              </n-input-group>
+            </div>
+            <div
+              v-else
+              class="link"
+              @click="router.push({ name: routerName.author })"
+            >
+              请联系作者开通~
+            </div>
+          </div>
+
+          <div>
+            转推快手:
+            <div
+              class="cdn"
+              v-if="
+                userStore.userInfo?.auths?.find(
+                  (v) =>
+                    v.auth_value ===
+                    DEFAULT_AUTH_INFO.LIVE_PUSH_FORWARD_KUAISHOU.auth_value
+                )
+              "
+            >
+              <n-input-group>
+                <n-input
+                  style="width: 500px"
+                  v-model:value="liveRoomInfo!.forward_kuaishou_url"
+                  type="text"
+                  placeholder="请输入转推快手url"
+                />
+
+                <n-button
+                  type="primary"
+                  ghost
+                  @click="handleUpdateMyLiveRoom()"
+                >
+                  更新
+                </n-button>
+              </n-input-group>
+            </div>
+            <div
+              v-else
+              class="link"
+              @click="router.push({ name: routerName.author })"
+            >
+              请联系作者开通~
+            </div>
+          </div>
         </div>
       </div>
     </div>
@@ -200,19 +428,20 @@
 
 <script lang="ts" setup>
 import { copyToClipBoard, openToTarget } from 'billd-utils';
-import { ref } from 'vue';
+import { ref, watch } from 'vue';
 import { useRouter } from 'vue-router';
 
-import { fetchUpdateLiveRoomKey } from '@/api/liveRoom';
+import { fetchUpdateLiveRoomKey, fetchUpdateMyLiveRoom } from '@/api/liveRoom';
 import { DEFAULT_AUTH_INFO } from '@/constant';
 import { loginTip } from '@/hooks/use-login';
 import { routerName } from '@/router';
 import { useUserStore } from '@/store/user';
-import { LiveRoomTypeEnum } from '@/types/ILiveRoom';
+import { ILiveRoom, LiveRoomTypeEnum } from '@/types/ILiveRoom';
 import { getLiveRoomPageUrl } from '@/utils';
 
 const userStore = useUserStore();
 const router = useRouter();
+const liveRoomInfo = ref<ILiveRoom>();
 
 const updateKeyLoading = ref(false);
 
@@ -221,6 +450,22 @@ function handleCopy(url: string) {
   window.$message.success('复制成功!');
 }
 
+watch(
+  () => userStore.userInfo,
+  (newval) => {
+    if (newval?.live_rooms?.[0]) {
+      liveRoomInfo.value = newval?.live_rooms[0];
+    }
+  }
+);
+
+async function handleUpdateMyLiveRoom() {
+  const res = await fetchUpdateMyLiveRoom(liveRoomInfo.value!);
+  if (res.code === 200) {
+    window.$message.success('修改成功!');
+  }
+}
+
 function openLiveRoom() {
   if (!loginTip()) {
     return;