|
|
@@ -107,11 +107,7 @@
|
|
|
function getQtInfo(): Promise<Uint8Array[]> {
|
|
|
if (qtWebChannel) {
|
|
|
return qtWebChannel.getSystemInfo().then((res: any) => {
|
|
|
- const arr = [];
|
|
|
- for (var i = 0, j = res.length; i < j; ++i) {
|
|
|
- arr.push(res.charCodeAt(i));
|
|
|
- }
|
|
|
- return new Uint8Array(arr);
|
|
|
+ return base64ToUint8Array(res);
|
|
|
});
|
|
|
} else {
|
|
|
console.warn('qtWebChannel is null');
|
|
|
@@ -121,6 +117,21 @@
|
|
|
return { getQtInfo };
|
|
|
}
|
|
|
|
|
|
+ function base64ToUint8Array(base64String: string) {
|
|
|
+ let padding = '='.repeat((4 - base64String.length % 4) % 4);
|
|
|
+ let base64 = (base64String + padding)
|
|
|
+ .replace(/\-/g, '+')
|
|
|
+ .replace(/_/g, '/');
|
|
|
+
|
|
|
+ let rawData = window.atob(base64);
|
|
|
+ let outputArray = new Uint8Array(rawData.length);
|
|
|
+
|
|
|
+ for (var i = 0; i < rawData.length; ++i) {
|
|
|
+ outputArray[i] = rawData.charCodeAt(i);
|
|
|
+ }
|
|
|
+ return outputArray;
|
|
|
+ }
|
|
|
+
|
|
|
// function qtAction(value: any) {
|
|
|
// if (qtWebChannel) {
|
|
|
// qtWebChannel.getSystemInfo().then((res: any) => {
|