添加不同环境的url

This commit is contained in:
kron
2025-08-09 12:16:36 +08:00
parent ca6cb989c7
commit e164d4736e
4 changed files with 29 additions and 4 deletions

View File

@@ -6,10 +6,10 @@ try {
switch (envVersion) {
case "develop": // 开发版
BASE_URL = "https://api.shelingxingqiu.com/api/shoot";
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
break;
case "trial": // 体验版
BASE_URL = "https://api.shelingxingqiu.com/api/shoot";
BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot";
break;
case "release": // 正式版
BASE_URL = "https://api.shelingxingqiu.com/api/shoot";

View File

@@ -15,7 +15,7 @@ const props = defineProps({
default: () => {},
},
});
const nextLvlPoints = ref("");
const nextLvlPoints = ref(0);
const containerWidth = computed(() =>
props.showRank ? "72%" : "calc(100% - 15px)"
);
@@ -52,6 +52,7 @@ watch(
},
{
immediate: true,
deep: true,
}
);
</script>

View File

@@ -9,6 +9,7 @@ const defaultUser = {
};
const getLvlName = (score, rankList = []) => {
if (!rankList) return;
let lvlName = "";
rankList.some((r, index) => {
lvlName = rankList[index].name;
@@ -24,6 +25,7 @@ const getLvlName = (score, rankList = []) => {
};
const getLvlImage = (rankLvl, rankList = []) => {
if (!rankList) return;
let lvlImage = "";
rankList.some((r, index) => {
if (r.rank_id === rankLvl) {

View File

@@ -7,7 +7,29 @@ let reconnectTimer = null;
* 建立 WebSocket 连接
*/
function createWebSocket(token, onMessage) {
const url = `wss://api.shelingxingqiu.com/socket?authorization=${token}`;
let url = "wss://api.shelingxingqiu.com/socket";
try {
const accountInfo = uni.getAccountInfoSync();
const envVersion = accountInfo.miniProgram.envVersion;
switch (envVersion) {
case "develop": // 开发版
url = "wss://apitest.shelingxingqiu.com/socket";
break;
case "trial": // 体验版
url = "wss://apitest.shelingxingqiu.com/socket";
break;
case "release": // 正式版
url = "wss://api.shelingxingqiu.com/socket";
break;
default:
// 保持默认值
break;
}
} catch (e) {
console.error("获取环境信息失败,使用默认正式环境", e);
}
url += `?authorization=${token}`;
socket = uni.connectSocket({
url,
success: () => {