diff --git a/packages/client/package.json b/packages/client/package.json index e4041fe4fa..08c531aec5 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -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'", diff --git a/packages/client/src/config.ts b/packages/client/src/config.ts index f09d2420b1..5c910018ae 100644 --- a/packages/client/src/config.ts +++ b/packages/client/src/config.ts @@ -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")); diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index 1657b68930..338383dd52 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -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_) { diff --git a/packages/client/vite.config.ts b/packages/client/vite.config.ts index 1a067a3a4e..d674c32d43 100644 --- a/packages/client/vite.config.ts +++ b/packages/client/vite.config.ts @@ -79,7 +79,7 @@ export default defineConfig(({ command, mode }) => { }, build: { - target: ["es2017"], + target: ["esnext"], manifest: "manifest.json", rollupOptions: { input: {