74 lines
1.7 KiB
Vue
74 lines
1.7 KiB
Vue
|
|
<template>
|
|||
|
|
<view class="drama-container">
|
|||
|
|
<!-- 嵌入网页 -->
|
|||
|
|
<web-view :src="dramaUrl"></web-view>
|
|||
|
|
</view>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
<script>
|
|||
|
|
import { API_BASE, API_ENDPOINTS } from '@/config/api.js';
|
|||
|
|
|
|||
|
|
export default {
|
|||
|
|
data() {
|
|||
|
|
return {
|
|||
|
|
// 默认使用用户指定的短剧链接
|
|||
|
|
dramaUrl: 'https://djcps.meinvclk.top/'
|
|||
|
|
};
|
|||
|
|
},
|
|||
|
|
onLoad() {
|
|||
|
|
// 暂时注释掉动态加载,强制使用默认URL
|
|||
|
|
// this.loadDramaUrl();
|
|||
|
|
},
|
|||
|
|
methods: {
|
|||
|
|
async loadDramaUrl() {
|
|||
|
|
try {
|
|||
|
|
// 先从本地存储读取缓存
|
|||
|
|
const cachedConfig = uni.getStorageSync('appConfig');
|
|||
|
|
if (cachedConfig && cachedConfig.app && cachedConfig.app.dramaUrl) {
|
|||
|
|
this.dramaUrl = cachedConfig.app.dramaUrl;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 从后端获取最新配置(公开接口,不需要认证)
|
|||
|
|
const res = await uni.request({
|
|||
|
|
url: `${API_BASE}${API_ENDPOINTS.config.getAppConfig}`,
|
|||
|
|
method: 'GET',
|
|||
|
|
header: {
|
|||
|
|
'Content-Type': 'application/json'
|
|||
|
|
// 不添加认证头,因为这是公开接口
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
// 兼容不同平台的返回格式:可能是 [error, res] 或直接是 res
|
|||
|
|
const response = Array.isArray(res) ? res[1] : res;
|
|||
|
|
if (response && response.data && response.data.success && response.data.data) {
|
|||
|
|
const config = response.data.data;
|
|||
|
|
uni.setStorageSync('appConfig', config);
|
|||
|
|
|
|||
|
|
if (config.app && config.app.dramaUrl) {
|
|||
|
|
this.dramaUrl = config.app.dramaUrl;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
} catch (error) {
|
|||
|
|
console.error('加载短剧URL失败:', error);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<style lang="scss" scoped>
|
|||
|
|
.drama-container {
|
|||
|
|
width: 100%;
|
|||
|
|
height: 100vh;
|
|||
|
|
display: flex;
|
|||
|
|
flex-direction: column;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
web-view {
|
|||
|
|
flex: 1;
|
|||
|
|
width: 100%;
|
|||
|
|
height: 100vh;
|
|||
|
|
}
|
|||
|
|
</style>
|