main.ts
1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// App WebView(尤其旧版 Android)可能没有 TextEncoder,先做兼容再加载其它模块
const g = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : (typeof self !== "undefined" ? self : {});
if (typeof (g as any).TextEncoder === "undefined") {
(g as any).TextEncoder = class TextEncoder {
encode(s = "") {
const u8: number[] = [];
for (let i = 0; i < s.length; i++) {
let c = s.charCodeAt(i);
if (c < 0x80) u8.push(c);
else if (c < 0x800) {
u8.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));
} else if (c < 0xd800 || c >= 0xe000) {
u8.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
} else {
i++;
const c2 = s.charCodeAt(i);
const u = ((c & 0x3ff) << 10) + (c2 & 0x3ff) + 0x10000;
u8.push(0xf0 | (u >> 18), 0x80 | ((u >> 12) & 0x3f), 0x80 | ((u >> 6) & 0x3f), 0x80 | (u & 0x3f));
}
}
return new Uint8Array(u8);
}
};
}
if (typeof (g as any).TextDecoder === "undefined") {
(g as any).TextDecoder = class TextDecoder {
decode() {
return "";
}
};
}
import { createSSRApp } from "vue";
import App from "./App.vue";
import i18n from "./utils/i18n";
export function createApp() {
const app = createSSRApp(App);
app.use(i18n);
return {
app,
};
}