Skip to content

Commit

Permalink
增加可视化辅助,用于对图片进行二值化等操作
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyJiangWJ committed Dec 26, 2020
1 parent 6057ace commit 39a23b9
Show file tree
Hide file tree
Showing 6 changed files with 989 additions and 0 deletions.
75 changes: 75 additions & 0 deletions test/visual_test/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<!--
* @Author: TonyJiangWJ
* @Date: 2020-11-29 13:17:06
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2020-12-25 21:35:53
* @Description:
-->
<!DOCTYPE html>
<html lang=en>

<head>
<meta charset=utf-8>
<meta http-equiv=X-UA-Compatible content="IE=edge">
<meta name=viewport content="width=device-width,initial-scale=1">
<title>可视化测试工具</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.10/lib/index.css" />
<!-- <script src="https://cdn.jsdelivr.net/npm/vue@2.6/dist/vue.min.js"></script> -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router@3.4.9/dist/vue-router.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vant@2.10/lib/vant.min.js"></script>
</head>

<body>
<noscript><strong>We're sorry but this doesn't work properly without JavaScript enabled. Please enable
it to continue.</strong></noscript>
<div id=app class="root-container" v-cloak style="min-height:755px;background: #ffffff;">
<!-- <image-data-visual-test /> -->
<router-view></router-view>
</div>
</body>
<script type="text/javascript">
/**
* 加载本地js文件
*/
function appendScripts(filePath) {
let element = document.createElement('script')
// element.src = 'file://' + filePath + '/vue_configs/js/vue.min.js'
// document.head.appendChild(element)
let scripts = ['/vue_configs/js/webview_bridge.js', '/vue_configs/js/components/common.js', '/test/visual_test/js/components/visual_test.js', '/test/visual_test/js/index.js', '/test/visual_test/js/app.js']
let index = 0
scripts.forEach(script => {
setTimeout(function () {
element = document.createElement('script')
element.src = filePath + script
document.head.appendChild(element)
}, 100 + (index++) * 10)
})
console.log('append scripts done')
let csses = ['/vue_configs/css/style.css']
csses.forEach(css => {
element = document.createElement('link')
element.href = filePath + css
element.rel = "stylesheet"
document.head.appendChild(element)
})
console.log('append css done')
}
function nativeInvoke(message) {
//document.getElementById('content').innerText = message
}

// 挂载本地js脚本
window.onload = () => {
let location = window.location.href
appendScripts(location.substring(0, location.indexOf('/test/visual_test/index.html')))
}
/**
* 禁用长按菜单,复制等
**/
window.addEventListener('contextmenu', function (e) {
e.preventDefault()
})
</script>

</html>
51 changes: 51 additions & 0 deletions test/visual_test/js/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* @Author: TonyJiangWJ
* @Date: 2020-11-29 13:24:38
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2020-12-25 21:31:29
* @Description:
*/

Vue.use(vant);
let app = new Vue({
router,
el: '#app',
data () {
return {
resourcePath: 'unknown',
message: '',
activeTab: '1',
showMenuDialog: false,
clientHeight: 0
}
},
methods: {
invokeAutojsToast: function () {
this.message = '点击触发toast'
console.log('点击触发 toast')
$app.invoke('toastLog', { message: 'Hello, this is from H5.' })
this.message = '点击触发toast'
},
invokeAutojsCallback: function () {
$app.invoke('callback', { message: 'invoke callback' }, (data) => {
this.message = data.message
})
},
getDialogContainer: function () {
return document.querySelector('html')
},
back: function () {
this.$router.back()
}
},
mounted() {
// vant.Toast('vue加载完成');
let self = this
setTimeout(function () {
self.clientHeight = document.querySelector('html').clientHeight
console.log('client-height:' + self.clientHeight)
}, 200)
$app.registerFunction('clickBack', this.back)
// document.getElementById('app').style.minHeight = this.clientHeight + 'px'
}
})
7 changes: 7 additions & 0 deletions test/visual_test/js/components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* @Author: TonyJiangWJ
* @Date: 2020-12-25 10:12:37
* @Last Modified by: TonyJiangWJ
* @Last Modified time: 2020-12-25 21:12:38
* @Description:
*/
Loading

0 comments on commit 39a23b9

Please sign in to comment.