remove .env file(electron not picking it up)
This commit is contained in:
parent
716730fdd2
commit
7dbf4e6aa6
10 changed files with 29 additions and 13 deletions
4
.env
4
.env
|
|
@ -1,4 +0,0 @@
|
||||||
|
|
||||||
BUSINESS_URL="http://localhost:3000"
|
|
||||||
|
|
||||||
PLATFORM_URL="ws://127.0.0.1:8760"
|
|
||||||
|
|
@ -85,8 +85,14 @@ export default defineComponent({
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onSessionAuthFail = (_event: IpcRendererEvent, _payload: null) => {
|
||||||
|
clearProfile();
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
console.log("APP:mounted.");
|
console.log("APP:mounted.");
|
||||||
|
|
||||||
|
window.ipcRenderer.on("session-auth-fail", onSessionAuthFail)
|
||||||
window.ipcRenderer.on("update-state", updateState)
|
window.ipcRenderer.on("update-state", updateState)
|
||||||
window.ipcRenderer.on("update_available", () => {
|
window.ipcRenderer.on("update_available", () => {
|
||||||
console.log('testing auto update');
|
console.log('testing auto update');
|
||||||
|
|
@ -117,6 +123,7 @@ export default defineComponent({
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
window.ipcRenderer.removeAllListeners("update-state");
|
window.ipcRenderer.removeAllListeners("update-state");
|
||||||
|
window.ipcRenderer.removeAllListeners("session-auth-fail");
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ protocol.registerSchemesAsPrivileged([
|
||||||
const isDev = require('electron-is-dev');
|
const isDev = require('electron-is-dev');
|
||||||
|
|
||||||
// NOTE Program Begins Here
|
// NOTE Program Begins Here
|
||||||
(async () => {
|
(() => {
|
||||||
|
|
||||||
console.log('Starting Crimata electron app.');
|
console.log('Starting Crimata electron app.');
|
||||||
await initApp(isDev);
|
initApp(isDev);
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ const onLogin = async (
|
||||||
resolve(parsed.profile);
|
resolve(parsed.profile);
|
||||||
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log('[API]', e.response);
|
console.log('[API]', e);
|
||||||
reject(new Error('Failed to authenticate'));
|
reject(new Error('Failed to authenticate'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,10 @@ let state: SessionState;
|
||||||
// Calls appropriate endpoint for a server message.
|
// Calls appropriate endpoint for a server message.
|
||||||
const onMessage = (data: string): void => {
|
const onMessage = (data: string): void => {
|
||||||
let message = JSON.parse(data);
|
let message = JSON.parse(data);
|
||||||
console.log('received new message', message);
|
if (message === "CLOSE_AUTH_FAIL") {
|
||||||
|
ipcEmit("session-auth-fail", null)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Standard message.
|
// Standard message.
|
||||||
if (message.content) {
|
if (message.content) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import WebSocket from 'ws';
|
||||||
|
|
||||||
let socket: WebSocket;
|
let socket: WebSocket;
|
||||||
|
|
||||||
const socketUrl = process.env.PLATFORM_URL;
|
const socketUrl = "ws://127.0.0.1:8760"
|
||||||
|
|
||||||
// Run every time we want to connect to backend.
|
// Run every time we want to connect to backend.
|
||||||
export default function useWebSockets(
|
export default function useWebSockets(
|
||||||
|
|
@ -53,7 +53,7 @@ export default function useWebSockets(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClose = (_event: WebSocket.CloseEvent) => {
|
const onClose = (event: WebSocket.CloseEvent) => {
|
||||||
console.log("WS:Socket closed normally.")
|
console.log("WS:Socket closed normally.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,7 +69,6 @@ export default function useWebSockets(
|
||||||
token: string;
|
token: string;
|
||||||
crimataId: string;
|
crimataId: string;
|
||||||
}) => {
|
}) => {
|
||||||
if (socketUrl)
|
|
||||||
socket = new WebSocket(socketUrl)
|
socket = new WebSocket(socketUrl)
|
||||||
|
|
||||||
// Add listeners.
|
// Add listeners.
|
||||||
|
|
|
||||||
|
|
@ -40,13 +40,14 @@ import { authRequest } from '@/modules/message';
|
||||||
import { useProfile } from '@/modules/auth';
|
import { useProfile } from '@/modules/auth';
|
||||||
import { invokeLogin } from "@/ipcRend/account";
|
import { invokeLogin } from "@/ipcRend/account";
|
||||||
import { Profile } from "@/types";
|
import { Profile } from "@/types";
|
||||||
|
import { postInitSession } from "@/ipcRend/session";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "Login",
|
name: "Login",
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
const { setProfile } = useProfile();
|
const { profile, setProfile } = useProfile();
|
||||||
|
|
||||||
const usr = ref("");
|
const usr = ref("");
|
||||||
const pwd = ref("");
|
const pwd = ref("");
|
||||||
|
|
@ -63,6 +64,13 @@ export default defineComponent({
|
||||||
setProfile(profile);
|
setProfile(profile);
|
||||||
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
console.log('Error login in.')
|
||||||
|
} finally{
|
||||||
|
|
||||||
|
if (profile.value.crimataId) {
|
||||||
|
// start session
|
||||||
|
postInitSession(profile.value.crimataId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,3 +19,5 @@ export const postInitSession = (cid: string): void => (
|
||||||
export const postMessage = (payload: ClientMessage): void => (
|
export const postMessage = (payload: ClientMessage): void => (
|
||||||
post('client-message', payload)
|
post('client-message', payload)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import App from "./App.vue";
|
||||||
|
|
||||||
import mitt from "mitt";
|
import mitt from "mitt";
|
||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
|
require('dotenv').config()
|
||||||
|
|
||||||
|
|
||||||
// Handle events.
|
// Handle events.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import axios, { AxiosRequestConfig } from 'axios';
|
||||||
|
|
||||||
const preFix = '/api';
|
const preFix = '/api';
|
||||||
|
|
||||||
const baseURL = process.env.BUSSINESS_URL + preFix;
|
const baseURL = "http://127.0.0.1:3000" + preFix;
|
||||||
|
|
||||||
|
|
||||||
interface Request {
|
interface Request {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue