diff --git a/lib/api/changeVersion.js b/lib/api/changeVersion.js index 77124d8..882a1f6 100644 --- a/lib/api/changeVersion.js +++ b/lib/api/changeVersion.js @@ -8,8 +8,6 @@ module.exports = async (argv) => { const isEvolutionInstalled = verifyEvolutionInstallation(); if (!isEvolutionInstalled) return; - - console.log(`🔃 Reverting to Evolution-Api v${v}...`); await revertToVersion(v); console.log(`🔃 Reverted to Evolution-Api v${v} successfully`); diff --git a/lib/postinstall.js b/lib/postinstall.js new file mode 100644 index 0000000..89b866d --- /dev/null +++ b/lib/postinstall.js @@ -0,0 +1,7 @@ +const build = require('./utils/build'); + +async function main() { + await build({ VITE_BASE_URL: '/manager/' }); +} + +main(); \ No newline at end of file diff --git a/package.json b/package.json index f81e02c..e1cdb80 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "evolution-manager", "description": "Evolution Manager is an open-source interface for managing the Evolution API, simplifying the creation and administration of API instances with advanced features and diverse integrations.", - "version": "0.3.12", + "version": "0.4.0", "main": "dist", "engines": { "node": ">=16.0.0" @@ -10,7 +10,8 @@ "dev": "vite", "build": "vite build", "preview": "vite preview", - "lint": "eslint . --fix --ignore-path .gitignore" + "lint": "eslint . --fix --ignore-path .gitignore", + "prepare": "node ./lib/postinstall.js" }, "directories": { "bin": "./bin" diff --git a/src/components/modal/Settings.vue b/src/components/modal/Settings.vue index ad3fa9d..b389e04 100644 --- a/src/components/modal/Settings.vue +++ b/src/components/modal/Settings.vue @@ -141,6 +141,8 @@ import { useAppStore } from "@/store/app"; import AboutModal from "./About.vue"; import ShareConnection from "./ShareConnection.vue"; +const BASE_URL = import.meta.env.BASE_URL; + export default { components: { AboutModal, ShareConnection }, name: "SettingsModal", @@ -149,7 +151,7 @@ export default { valid: false, revelPassword: false, connection: { - host: "", + host: BASE_URL ? window.location.origin : "", globalApiKey: "", }, loading: false, @@ -161,7 +163,6 @@ export default { share() { const connection = Object.assign({}, this.AppStore.connection); this.$refs.share.open(connection); - }, logout() { this.AppStore.logout(); @@ -192,6 +193,8 @@ export default { open() { this.dialog = true; this.connection = Object.assign({}, this.AppStore.connection); + if (!this.connection.host && BASE_URL.startsWith("/manager")) + this.connection.host = window.location.origin; }, }, watch: { diff --git a/src/layouts/default/AppBar.vue b/src/layouts/default/AppBar.vue index 3906150..8d9e2c3 100644 --- a/src/layouts/default/AppBar.vue +++ b/src/layouts/default/AppBar.vue @@ -77,9 +77,14 @@ export default { }, }, async mounted() { - const urlConnection = await this.loadConnectionFromUrl(); - if (!urlConnection) await this.AppStore.loadConnection(); - if (!this.AppStore.validConnection) this.openSettings(); + try { + const urlConnection = await this.loadConnectionFromUrl(); + if (!urlConnection) await this.AppStore.loadConnection(); + } catch (e) { + console.error(e); + } finally { + if (!this.AppStore.validConnection) this.openSettings(); + } }, };