81 lines
1.9 KiB
TypeScript
81 lines
1.9 KiB
TypeScript
import { createApp, defineAsyncComponent } from "vue";
|
|
import App from "./App.vue";
|
|
import router from "./router";
|
|
import { Dialog, Notify, Quasar } from "quasar";
|
|
import th from "quasar/lang/th";
|
|
import quasarUserOptions from "./quasar-user-options";
|
|
import { createPinia } from "pinia";
|
|
import "@vuepic/vue-datepicker/dist/main.css";
|
|
|
|
import "quasar/src/css/index.sass";
|
|
import http from "./plugins/http";
|
|
import keycloak from "@/plugins/keycloak";
|
|
|
|
// import OpenLayersMap from "vue3-openlayers";
|
|
|
|
// import './assets/main.css'
|
|
|
|
const app = createApp(App);
|
|
const pinia = createPinia();
|
|
|
|
app.use(router);
|
|
app.use(pinia);
|
|
|
|
app.use(Quasar, {
|
|
plugins: {
|
|
Notify,
|
|
Dialog,
|
|
},
|
|
lang: th,
|
|
});
|
|
// app.use(OpenLayersMap /* options */);
|
|
|
|
app.component(
|
|
"datepicker",
|
|
defineAsyncComponent(() => import("@vuepic/vue-datepicker"))
|
|
);
|
|
|
|
app.component(
|
|
"d-table",
|
|
defineAsyncComponent(() => import("@/components/TableD.vue"))
|
|
);
|
|
|
|
app.config.globalProperties.$http = http;
|
|
|
|
// authen with keycloak client
|
|
function getCookie(name: string) {
|
|
const nameEQ = name + "=";
|
|
const ca = document.cookie.split(";");
|
|
for (let i = 0; i < ca.length; i++) {
|
|
let c = ca[i];
|
|
while (c.charAt(0) == " ") c = c.substring(1, c.length);
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
const kcToken = getCookie("BMAHRIS_KEYCLOAK_IDENTITY");
|
|
const kcRefreshToken = getCookie("BMAHRIS_KEYCLOAK_REFRESH");
|
|
|
|
if (kcToken && kcRefreshToken) {
|
|
keycloak
|
|
.init({
|
|
// onLoad: 'login-required',
|
|
checkLoginIframe: false,
|
|
token: kcToken,
|
|
refreshToken: kcRefreshToken,
|
|
})
|
|
.then((authenticated) => {
|
|
console.log("authenticated", authenticated);
|
|
if (!authenticated) {
|
|
window.location.reload();
|
|
} else {
|
|
console.log("Authenticated");
|
|
}
|
|
})
|
|
.catch((err) => {
|
|
console.error("Keycloak initialization failed:", err);
|
|
});
|
|
}
|
|
|
|
app.mount("#app");
|