zhgdyunapp/examples/sosSimpleTest.vue
2025-09-11 18:14:57 +08:00

152 lines
3.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="sos-simple-test">
<view class="test-header">
<text class="test-title">SOS SDK 简单测试</text>
</view>
<view class="test-content">
<button
class="test-btn"
@click="testSOSConstructor"
:disabled="isTesting"
>
{{ isTesting ? '测试中...' : '测试SOS构造函数' }}
</button>
<view class="test-result">
<text class="result-text">{{ resultText }}</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'SOSSimpleTest',
data() {
return {
isTesting: false,
resultText: '点击按钮开始测试SOS构造函数'
}
},
onLoad() {
this.testSOSConstructor()
},
methods: {
/**
* 测试SOS构造函数
*/
async testSOSConstructor() {
this.isTesting = true
this.resultText = '正在测试SOS构造函数...'
try {
// 加载SOS包装器
const sosModule = require('@/utils/sos-wrapper.js')
this.resultText = 'SOS包装器加载成功'
// 检查SDK构造函数
if (sosModule.SDK) {
this.resultText = 'SOS.SDK构造函数可用正在创建实例...'
// 尝试创建SDK实例
const sdk = new sosModule.SDK({
// 基本配置
test: true
})
this.resultText = 'SOS.SDK实例创建成功'
// 检查实例方法
if (typeof sdk.init === 'function') {
this.resultText = 'SOS.SDK实例创建成功init方法可用'
} else {
this.resultText = 'SOS.SDK实例创建成功但init方法不可用'
}
} else {
this.resultText = 'SOS.SDK构造函数不可用'
}
// 检查原始SOS对象
if (sosModule.SOS) {
this.resultText += '\n原始SOS对象可用'
} else {
this.resultText += '\n原始SOS对象不可用'
}
// 检查原始SDK构造函数
if (sosModule.OriginalSDK) {
this.resultText += '\n原始SOS.SDK构造函数可用'
} else {
this.resultText += '\n原始SOS.SDK构造函数不可用'
}
} catch (error) {
this.resultText = `测试失败: ${error.message}`
console.error('SOS构造函数测试失败:', error)
} finally {
this.isTesting = false
}
}
}
}
</script>
<style scoped>
.sos-simple-test {
padding: 40rpx;
background-color: #f5f5f5;
min-height: 100vh;
}
.test-header {
text-align: center;
margin-bottom: 60rpx;
}
.test-title {
font-size: 40rpx;
font-weight: bold;
color: #333;
}
.test-content {
display: flex;
flex-direction: column;
gap: 30rpx;
}
.test-btn {
background: #2196f3;
color: white;
border: none;
border-radius: 30rpx;
padding: 30rpx;
font-size: 32rpx;
font-weight: bold;
}
.test-btn:disabled {
background: #ccc;
color: #999;
}
.test-result {
background: white;
border-radius: 20rpx;
padding: 30rpx;
margin-top: 30rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}
.result-text {
font-size: 28rpx;
color: #333;
line-height: 1.5;
white-space: pre-line;
}
</style>