Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
4bd64edb3f | |||
aacd6e37ed | |||
e529eb733b | |||
aa183f19cd | |||
bc97a3fc73 | |||
a97fc92b2f | |||
dfd0d9d998 | |||
145096be9f | |||
a7f0c20b6f | |||
f8999ef0be | |||
3e05196fc5 |
@ -3,7 +3,7 @@
|
|||||||
<name>APP</name>
|
<name>APP</name>
|
||||||
<description>app</description>
|
<description>app</description>
|
||||||
<author email="dev@cordova.apache.org" href="https://cordova.apache.org"></author>
|
<author email="dev@cordova.apache.org" href="https://cordova.apache.org"></author>
|
||||||
<content src="http://10.1.23.61:10001/"/>
|
<content src="http://test.taoya.art/" />
|
||||||
<allow-intent href="http://*/*"/>
|
<allow-intent href="http://*/*"/>
|
||||||
<allow-intent href="https://*/*"/>
|
<allow-intent href="https://*/*"/>
|
||||||
<allow-intent href="tel:*"/>
|
<allow-intent href="tel:*"/>
|
||||||
@ -14,7 +14,12 @@
|
|||||||
<platform name="android">
|
<platform name="android">
|
||||||
<preference name="Fullscreen" value="true"/>
|
<preference name="Fullscreen" value="true"/>
|
||||||
<icon src="logo.png"></icon>
|
<icon src="logo.png"></icon>
|
||||||
<custom-preference name="android-manifest/application/activity/@android:windowSoftInputMode" value="adjustResize" />
|
|
||||||
</platform>
|
</platform>
|
||||||
<plugin name="phonegap-plugin-barcodescanner" />
|
<plugin name="phonegap-plugin-barcodescanner" />
|
||||||
|
|
||||||
|
<preference name="GradlePluginKotlinEnabled" value="true" />
|
||||||
|
<preference name="GradlePluginKotlinCodeStyle" value="official" />
|
||||||
|
<preference name="GradlePluginKotlinVersion" value="1.6.10" />
|
||||||
|
<preference name="AndroidXEnabled" value="true" />
|
||||||
</widget>
|
</widget>
|
||||||
|
1673
package-lock.json
generated
1673
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@ -19,14 +19,17 @@
|
|||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"cordova-android": "^10.1.2",
|
"cordova-android": "^10.1.2",
|
||||||
|
"cordova-plugin-app-version": "^0.1.14",
|
||||||
"cordova-plugin-battery-status": "^2.0.3",
|
"cordova-plugin-battery-status": "^2.0.3",
|
||||||
"cordova-plugin-camera": "^6.0.0",
|
"cordova-plugin-camera": "^6.0.0",
|
||||||
"cordova-plugin-device": "^2.1.0",
|
"cordova-plugin-device": "^2.1.0",
|
||||||
"cordova-plugin-dialogs": "^2.0.2",
|
"cordova-plugin-dialogs": "^2.0.2",
|
||||||
"cordova-plugin-file": "^6.0.2",
|
"cordova-plugin-file": "^6.0.2",
|
||||||
|
"cordova-plugin-file-opener2": "^4.0.0",
|
||||||
"cordova-plugin-file-transfer-jsg": "^2.0.0",
|
"cordova-plugin-file-transfer-jsg": "^2.0.0",
|
||||||
"cordova-plugin-geolocation": "^4.1.0",
|
"cordova-plugin-geolocation": "^4.1.0",
|
||||||
"cordova-plugin-inappbrowser": "^5.0.0",
|
"cordova-plugin-inappbrowser": "^5.0.0",
|
||||||
|
"cordova-plugin-jbprint-jsg": "^1.0.3",
|
||||||
"cordova-plugin-media": "^5.0.4",
|
"cordova-plugin-media": "^5.0.4",
|
||||||
"cordova-plugin-media-capture": "^3.0.3",
|
"cordova-plugin-media-capture": "^3.0.3",
|
||||||
"cordova-plugin-network-information": "^3.0.0",
|
"cordova-plugin-network-information": "^3.0.0",
|
||||||
@ -34,6 +37,7 @@
|
|||||||
"cordova-plugin-screen-orientation": "^3.0.2",
|
"cordova-plugin-screen-orientation": "^3.0.2",
|
||||||
"cordova-plugin-splashscreen": "^6.0.1",
|
"cordova-plugin-splashscreen": "^6.0.1",
|
||||||
"cordova-plugin-statusbar": "^3.0.0",
|
"cordova-plugin-statusbar": "^3.0.0",
|
||||||
|
"cordova-plugin-test-tl": "^1.1.11",
|
||||||
"cordova-plugin-vibration": "^3.1.1",
|
"cordova-plugin-vibration": "^3.1.1",
|
||||||
"es6-promise-plugin": "^4.2.2",
|
"es6-promise-plugin": "^4.2.2",
|
||||||
"phonegap-plugin-barcodescanner-fix": "^8.1.1",
|
"phonegap-plugin-barcodescanner-fix": "^8.1.1",
|
||||||
@ -69,7 +73,12 @@
|
|||||||
"cordova-plugin-printer-jsg": {
|
"cordova-plugin-printer-jsg": {
|
||||||
"ANDROID_SUPPORT_V4_VERSION": "28.+"
|
"ANDROID_SUPPORT_V4_VERSION": "28.+"
|
||||||
},
|
},
|
||||||
"cordova-plugin-file-transfer-jsg": {}
|
"cordova-plugin-file-transfer-jsg": {},
|
||||||
|
"cordova-plugin-app-version": {},
|
||||||
|
"cordova-plugin-file-opener2": {},
|
||||||
|
"cordova-plugin-test-tl": {},
|
||||||
|
"cordova-plugin-file-transfer": {},
|
||||||
|
"cordova-plugin-jbprint-jsg": {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
3557
pnpm-lock.yaml
Normal file
3557
pnpm-lock.yaml
Normal file
File diff suppressed because it is too large
Load Diff
175
www/index.html
175
www/index.html
@ -0,0 +1,175 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="initial-scale=1, width=device-width, viewport-fit=cover"
|
||||||
|
/>
|
||||||
|
<title>Hello World</title>
|
||||||
|
<script src="cordova.js"></script>
|
||||||
|
<!-- 导入样式 -->
|
||||||
|
<link rel="stylesheet" href="//unpkg.com/element-plus/dist/index.css" />
|
||||||
|
<!-- 导入 Vue 3 -->
|
||||||
|
<script src="//unpkg.com/vue@next"></script>
|
||||||
|
<!-- 导入组件库 -->
|
||||||
|
<script src="//unpkg.com/element-plus"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app">
|
||||||
|
<h1>Cordova plugins</h1>
|
||||||
|
<el-button @click="getDeviceInfo">获取设备信息</el-button>
|
||||||
|
<el-button @click="openUrl">打开百度</el-button>
|
||||||
|
<el-button @click="deviceVibration">设备震动</el-button>
|
||||||
|
<el-button @click="scanCode">扫码</el-button>
|
||||||
|
<el-button @click="takPhoto">拍照</el-button>
|
||||||
|
<el-button @click="docPrint">文件打印</el-button>
|
||||||
|
<el-button @click="versionCheck">版本升级</el-button>
|
||||||
|
<el-button @click="installAPK" type="danger">安装apk</el-button>
|
||||||
|
<el-button @click="customPlugin">自定义插件</el-button>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
|
||||||
|
<script>
|
||||||
|
var vConsole = new window.VConsole();
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
const app = Vue.createApp({
|
||||||
|
mounted() {
|
||||||
|
setTimeout(() => {
|
||||||
|
window.addEventListener("batterystatus", this.onBatteryStatus, false);
|
||||||
|
}, 600);
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
customPlugin() {
|
||||||
|
console.log(cordovaTest);
|
||||||
|
cordovaTest.coolMethod(
|
||||||
|
"param",
|
||||||
|
(res) => {
|
||||||
|
console.log(res);
|
||||||
|
this.$message.success(res);
|
||||||
|
},
|
||||||
|
(e) => {
|
||||||
|
this.$message.error(e);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
installAPK() {
|
||||||
|
let url = "http://3000.taoya.art/app.apk";
|
||||||
|
var filename = url.split("/").pop();
|
||||||
|
var targetPath = cordova.file.externalRootDirectory + filename;
|
||||||
|
console.log(cordova.file.externalRootDirectory);
|
||||||
|
//1. 下载
|
||||||
|
let _this = this;
|
||||||
|
_this.progress = 0;
|
||||||
|
_this.fileTransfer = new FileTransfer();
|
||||||
|
_this.fileTransfer.onprogress = function (e) {
|
||||||
|
if (e.lengthComputable) {
|
||||||
|
const progress = e.loaded / e.total;
|
||||||
|
_this.progress = (progress * 100).toFixed(2);
|
||||||
|
console.log(progress);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
console.log("download file");
|
||||||
|
_this.fileTransfer.download(
|
||||||
|
encodeURI(url), //服务器地址
|
||||||
|
targetPath, //本地存储地址
|
||||||
|
function (entry) {
|
||||||
|
//下载完成回调
|
||||||
|
let url = entry.toURL();
|
||||||
|
console.log(url);
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
console.log(error);
|
||||||
|
_this.$message.error(error);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
trustHosts: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
|
||||||
|
//2. 安装
|
||||||
|
cordova.plugins.fileOpener2.open(
|
||||||
|
"",
|
||||||
|
"application/vnd.android.package-archive",
|
||||||
|
{
|
||||||
|
error: function (e) {
|
||||||
|
console.log("open fail");
|
||||||
|
},
|
||||||
|
success: function () {
|
||||||
|
console.log("open successfully");
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
async versionCheck() {
|
||||||
|
let versionCode =
|
||||||
|
await window.cordova.getAppVersion.getVersionNumber();
|
||||||
|
this.$message.success(`当前版本: ${versionCode}`);
|
||||||
|
},
|
||||||
|
docPrint() {
|
||||||
|
// use
|
||||||
|
// cordova.plugins.printer.print();
|
||||||
|
cordova.plugins.printer.print("<b>Hello Cordova!</b>");
|
||||||
|
},
|
||||||
|
takPhoto() {
|
||||||
|
let that = this;
|
||||||
|
window.navigator.camera.getPicture(
|
||||||
|
(imageURI) => {
|
||||||
|
console.log(imageURI);
|
||||||
|
that.$message.success(`文件路径: ${imageURI}`);
|
||||||
|
},
|
||||||
|
(message) => {
|
||||||
|
this.$message.warning("取消拍照");
|
||||||
|
},
|
||||||
|
{
|
||||||
|
quality: 50,
|
||||||
|
destinationType: Camera.DestinationType.FILE_URI,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
scanCode() {
|
||||||
|
cordova.plugins.barcodeScanner.scan(
|
||||||
|
function (result) {
|
||||||
|
console.log("扫码结果", result);
|
||||||
|
try {
|
||||||
|
if (result.text) {
|
||||||
|
alert(result.text);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
that.$message.error("扫描失败");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onBatteryStatus(status) {
|
||||||
|
this.$message.warning(
|
||||||
|
"电池电量: " + status.level + " 是否充电中: " + status.isPlugged
|
||||||
|
);
|
||||||
|
},
|
||||||
|
deviceVibration() {
|
||||||
|
navigator.vibrate(600);
|
||||||
|
// var pattern = [1000, 1000, 1000, 1000];
|
||||||
|
// navigator.vibrate(pattern);
|
||||||
|
},
|
||||||
|
openUrl() {
|
||||||
|
var ref = cordova.InAppBrowser.open(
|
||||||
|
"https://www.baidu.com",
|
||||||
|
"_blank",
|
||||||
|
"location=yes"
|
||||||
|
);
|
||||||
|
},
|
||||||
|
getDeviceInfo() {
|
||||||
|
this.$message.success("请打开控制台查看");
|
||||||
|
console.log(window.device);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
app.use(ElementPlus);
|
||||||
|
app.mount("#app");
|
||||||
|
</script>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user