locale
This commit is contained in:
parent
6e4daf8f1f
commit
2464223073
|
@ -4,7 +4,7 @@
|
|||
"scripts": {
|
||||
"watch": "pnpm vite build --watch --mode development",
|
||||
"build": "pnpm vite build",
|
||||
"mobilebuild": "pnpm vite build --mode mobile && pnpm run mobilecopy && npx cap sync",
|
||||
"mobilebuild": "pnpm vite build --mode mobile && pnpm -w run gulp && pnpm run mobilecopy && npx cap sync",
|
||||
"mobilecopy": "pnpm node ../../scripts/mobilebuild.js",
|
||||
"lint": "pnpm rome check \"src/**/*.{ts,vue}\"",
|
||||
"format": "pnpm prettier --write '**/*.vue'",
|
||||
|
|
|
@ -15,7 +15,7 @@ export const url = $i?.instanceUrl;
|
|||
// #v-else
|
||||
export const url = address.origin;
|
||||
// #v-endif
|
||||
export const apiUrl = url + "/api";
|
||||
export const apiUrl = `${url}/api`;
|
||||
export const lang = localStorage.getItem("lang");
|
||||
export const langs = _LANGS_;
|
||||
export const locale = JSON.parse(localStorage.getItem("locale"));
|
||||
|
|
|
@ -5,8 +5,27 @@
|
|||
// https://vitejs.dev/config/build-options.html#build-modulepreload
|
||||
import "vite/modulepreload-polyfill";
|
||||
|
||||
import { Device, DeviceInfo } from "@capacitor/device";
|
||||
export let storedDeviceInfo: DeviceInfo;
|
||||
|
||||
// #v-ifdef VITE_CAPACITOR
|
||||
console.log("Compiled for Capacitor");
|
||||
const res = await Device.getInfo();
|
||||
{
|
||||
console.log(res);
|
||||
storedDeviceInfo = res;
|
||||
if (!localStorage.getItem("lang")) {
|
||||
localStorage.setItem("lang", "en-US");
|
||||
}
|
||||
const lang: string = localStorage.getItem("lang") || "";
|
||||
const lang_res = await fetch(`/assets/locales/${lang}.${version}.json`);
|
||||
if (lang_res.status === 200) {
|
||||
localStorage.setItem("lang", lang);
|
||||
localStorage.setItem("locale", await lang_res.text());
|
||||
localStorage.setItem("localeVersion", version);
|
||||
}
|
||||
}
|
||||
|
||||
// #v-else
|
||||
console.log("Compiled for Web");
|
||||
// #v-endif
|
||||
|
@ -56,25 +75,13 @@ import { reloadChannel } from "@/scripts/unison-reload";
|
|||
import { reactionPicker } from "@/scripts/reaction-picker";
|
||||
import { getUrlWithoutLoginId } from "@/scripts/login-id";
|
||||
import { getAccountFromId } from "@/scripts/get-account-from-id";
|
||||
import { Device, DeviceInfo } from "@capacitor/device";
|
||||
import { App } from "@capacitor/app";
|
||||
import lightThemeDefault from "@/themes/l-rosepinedawn.json5";
|
||||
import OneSignal from "onesignal-cordova-plugin";
|
||||
export let storedDeviceInfo: DeviceInfo;
|
||||
// #v-ifdef VITE_CAPACITOR
|
||||
const onesignal_app_id = "efe09597-0778-4156-97b7-0bf8f52c21a7";
|
||||
// #v-endif
|
||||
(async () => {
|
||||
// #v-ifdef VITE_CAPACITOR
|
||||
const res = await Device.getInfo();
|
||||
console.log(res);
|
||||
storedDeviceInfo = res;
|
||||
if (!localStorage.getItem("lang")) {
|
||||
localStorage.setItem("lang", (await Device.getLanguageCode()).value ||
|
||||
"en-US");
|
||||
window.location.reload();
|
||||
}
|
||||
// #v-endif
|
||||
console.info(`Calckey v${version}`);
|
||||
|
||||
if (_DEV_) {
|
||||
|
|
|
@ -79,7 +79,7 @@ export default defineConfig(({ command, mode }) => {
|
|||
},
|
||||
|
||||
build: {
|
||||
target: ["es2017"],
|
||||
target: ["esnext"],
|
||||
manifest: "manifest.json",
|
||||
rollupOptions: {
|
||||
input: {
|
||||
|
|
Loading…
Reference in New Issue