feat: testscan页面
This commit is contained in:
parent
8bf3ad06d6
commit
0c9c38890e
|
@ -1,5 +1,5 @@
|
|||
from django.urls import path, include
|
||||
from apps.develop.views import BackupDatabase, BackupMedia, ReloadClientGit, ReloadServerGit, ReloadServerOnly, TestViewSet, CorrectViewSet
|
||||
from apps.develop.views import BackupDatabase, BackupMedia, ReloadClientGit, ReloadServerGit, ReloadServerOnly, TestViewSet, CorrectViewSet, testScanHtml
|
||||
from rest_framework.routers import DefaultRouter
|
||||
|
||||
API_BASE_URL = 'api/develop/'
|
||||
|
@ -15,4 +15,5 @@ urlpatterns = [
|
|||
path(API_BASE_URL + 'backup_database/', BackupDatabase.as_view()),
|
||||
path(API_BASE_URL + 'backup_media/', BackupMedia.as_view()),
|
||||
path(API_BASE_URL, include(router.urls)),
|
||||
path(HTML_BASE_URL + "testscan/", testScanHtml)
|
||||
]
|
||||
|
|
|
@ -35,6 +35,7 @@ from apps.utils.snowflake import idWorker
|
|||
from django.core.cache import cache
|
||||
import json
|
||||
from apps.utils.decorators import auto_log, idempotent
|
||||
from django.http import HttpResponse
|
||||
# Create your views here.
|
||||
|
||||
|
||||
|
@ -643,3 +644,35 @@ class TestViewSet(CustomGenericViewSet):
|
|||
from apps.wpm.tasks import cal_exp_duration_sec
|
||||
cal_exp_duration_sec('3397169058570170368')
|
||||
return Response()
|
||||
|
||||
|
||||
html_str = """
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>WebView 扫码</title>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="openScanner()">扫码</button>
|
||||
<p>扫描结果: <span id="result"></span></p>
|
||||
|
||||
<script>
|
||||
function openScanner() {
|
||||
if (window.Android) {
|
||||
window.Android.openScanner();
|
||||
} else {
|
||||
alert("当前环境不支持扫码");
|
||||
}
|
||||
}
|
||||
|
||||
function onScanResult(data) {
|
||||
document.getElementById("result").innerText = data;
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
def testScanHtml(request):
|
||||
return HttpResponse(html_str)
|
Loading…
Reference in New Issue