first commit
This commit is contained in:
25
loginv2/components/ComponentA.js
Normal file
25
loginv2/components/ComponentA.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// components/ComponentA.js
|
||||
|
||||
const ComponentA = {
|
||||
template: `
|
||||
<div>
|
||||
<h2>Component A</h2>
|
||||
<p>Count: {{ count }}</p>
|
||||
<v-btn @click="increment">Increment</v-btn>
|
||||
<v-btn @click="decrement">Decrement</v-btn>
|
||||
</div>
|
||||
`,
|
||||
computed: {
|
||||
count() {
|
||||
return this.$store.state.count;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
increment() {
|
||||
this.$store.dispatch('increment');
|
||||
},
|
||||
decrement() {
|
||||
this.$store.dispatch('decrement');
|
||||
}
|
||||
}
|
||||
};
|
||||
21
loginv2/components/ComponentB.js
Normal file
21
loginv2/components/ComponentB.js
Normal file
@@ -0,0 +1,21 @@
|
||||
// components/ComponentB.js
|
||||
|
||||
const ComponentB = {
|
||||
template: `
|
||||
<div>
|
||||
<h2>Component B</h2>
|
||||
<p>Data: {{ data }}</p>
|
||||
<v-btn @click="fetchData">Fetch Data</v-btn>
|
||||
</div>
|
||||
`,
|
||||
computed: {
|
||||
data() {
|
||||
return this.$store.state.data;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async fetchData() {
|
||||
await this.$store.dispatch('fetchData');
|
||||
}
|
||||
}
|
||||
};
|
||||
92
loginv2/components/coba.vue
Normal file
92
loginv2/components/coba.vue
Normal file
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-container class="mb-6">
|
||||
<v-row align="end" style="min-height: 480px;" no-gutters justify="center">
|
||||
|
||||
<v-col>
|
||||
<div class="d-flex justify-center">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<h2 class="text-h6 font-weight-black">
|
||||
{{ $t("message.login") }} {{ email }}
|
||||
</h2>
|
||||
</v-sheet>
|
||||
</div>
|
||||
<div class="d-flex justify-center mb-6">
|
||||
<v-card
|
||||
class="mx-auto pa-12 pb-8"
|
||||
elevation="0"
|
||||
min-width="400"
|
||||
rounded="lg"
|
||||
>
|
||||
<div class="text-subtitle-1 text-medium-emphasis">
|
||||
{{ $t("message.email") }}
|
||||
</div>
|
||||
<v-text-field
|
||||
density="compact"
|
||||
:placeholder="$t('message.placeholderEmail')"
|
||||
prepend-inner-icon="mdi-email-outline"
|
||||
variant="outlined"
|
||||
v-model="email"
|
||||
></v-text-field>
|
||||
<div
|
||||
class="text-subtitle-1 text-medium-emphasis d-flex align-center justify-space-between"
|
||||
>
|
||||
{{ $t("message.password") }}
|
||||
<a
|
||||
class="text-caption text-decoration-none text-blue"
|
||||
href="#"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
>
|
||||
{{ $t("message.forgotPassword") }}</a
|
||||
>
|
||||
</div>
|
||||
<v-text-field
|
||||
:append-inner-icon="visible ? 'mdi-eye-off' : 'mdi-eye'"
|
||||
:type="visible ? 'text' : 'password'"
|
||||
density="compact"
|
||||
:placeholder="$t('message.placeholderPassword')"
|
||||
prepend-inner-icon="mdi-lock-outline"
|
||||
variant="outlined"
|
||||
@click:append-inner="visible = !visible"
|
||||
></v-text-field>
|
||||
<div class="text-center">
|
||||
<v-btn
|
||||
:loading="loading"
|
||||
@click="login"
|
||||
class="mt-8 text-none"
|
||||
color="blue"
|
||||
size="large"
|
||||
variant="elevated"
|
||||
block
|
||||
>
|
||||
{{ $t("message.login") }}
|
||||
<template v-slot:loader>
|
||||
<v-progress-linear indeterminate></v-progress-linear>
|
||||
</template>
|
||||
</v-btn>
|
||||
</div>
|
||||
</v-card>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "HelloWorld",
|
||||
setup() {
|
||||
const store = useStore();
|
||||
const email = computed(() => store.state.email);
|
||||
return { email };
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
h1 {
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
9
loginv2/images/bg_cover.svg
Normal file
9
loginv2/images/bg_cover.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 4.4 MiB |
4292
loginv2/images/bg_image.svg
Normal file
4292
loginv2/images/bg_image.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 24 MiB |
30
loginv2/images/frame_1.svg
Normal file
30
loginv2/images/frame_1.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 594 KiB |
9
loginv2/images/logo.svg
Normal file
9
loginv2/images/logo.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 66 KiB |
139
loginv2/index.html
Normal file
139
loginv2/index.html
Normal file
@@ -0,0 +1,139 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>WESTONE</title>
|
||||
<!-- Vuetify CSS -->
|
||||
<link href="../css/vuetify.css" rel="stylesheet" />
|
||||
<!-- Local Stylesheet for Fonts -->
|
||||
<link rel="stylesheet" href="../css/styles.css" />
|
||||
<link href="../css/materialdesignicon.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
<!-- Vue.js -->
|
||||
<script src="../libraries/vue3.4.36.global.prod.js"></script>
|
||||
<!-- Vuex -->
|
||||
<script src="../libraries/vuex.js"></script>
|
||||
<!-- Vuetify -->
|
||||
<script src="../libraries/vuetify3.js"></script>
|
||||
<!-- vue-i18n -->
|
||||
<script src="../libraries/vue-i18n.global.js"></script>
|
||||
<!-- Axios -->
|
||||
<script src="../libraries/axios.js"></script>
|
||||
<!-- Store JS -->
|
||||
<script src="store/store.js"></script>
|
||||
<!-- Component JS -->
|
||||
<script src="components/ComponentA.js"></script>
|
||||
<script src="components/ComponentB.js"></script>
|
||||
<!-- <script src="https://unpkg.com/vue3-sfc-loader/dist/vue3-sfc-loader.iife.js"></script> -->
|
||||
<script src="../libraries/vue3-sfc-loader.js"></script>
|
||||
|
||||
<script>
|
||||
const { loadModule } = window["vue3-sfc-loader"];
|
||||
const options = {
|
||||
moduleCache: {
|
||||
vue: Vue,
|
||||
},
|
||||
getFile(url) {
|
||||
return fetch(url).then((response) =>
|
||||
response.ok ? response.text() : Promise.reject(response)
|
||||
);
|
||||
},
|
||||
addStyle(textContent) {
|
||||
const style = document.createElement("style");
|
||||
style.textContent = textContent;
|
||||
const ref = document.head.getElementsByTagName("style")[0] || null;
|
||||
document.head.insertBefore(style, ref);
|
||||
},
|
||||
};
|
||||
// Locale messages
|
||||
const messages = {
|
||||
en: {
|
||||
message: {
|
||||
login: "Login",
|
||||
email: "Email",
|
||||
password: "Password",
|
||||
forgotPassword: "Forgot password?",
|
||||
placeholderEmail: "Enter your email",
|
||||
placeholderPassword: "Enter your password",
|
||||
},
|
||||
},
|
||||
id: {
|
||||
message: {
|
||||
login: "Masuk",
|
||||
email: "Surel",
|
||||
password: "Kata Sandi",
|
||||
forgotPassword: "Lupa kata sandi?",
|
||||
placeholderEmail: "Isikan email anda",
|
||||
placeholderPassword: "Isikan kata sandi anda",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// Get the browser's preferred language
|
||||
const browserLocale = navigator.language || navigator.languages[0];
|
||||
|
||||
// Initialize vue-i18n
|
||||
const i18n = VueI18n.createI18n({
|
||||
locale: browserLocale.startsWith("id") ? "id" : "en", // Set locale based on browser setting
|
||||
fallbackLocale: "en", // Set fallback locale
|
||||
messages, // Set locale messages
|
||||
});
|
||||
|
||||
// Vue App
|
||||
const app = Vue.createApp({
|
||||
components: {
|
||||
"component-a": ComponentA,
|
||||
"component-b": ComponentB,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
bg_src: "./images/bg_cover.svg",
|
||||
items: [
|
||||
{
|
||||
src: "./images/frame_1.svg",
|
||||
},
|
||||
{
|
||||
src: "./images/frame_1.svg",
|
||||
},
|
||||
],
|
||||
loading: false, // Initialize loading state
|
||||
};
|
||||
},
|
||||
template: `
|
||||
<v-row no-gutters>
|
||||
<v-col cols="8">
|
||||
<hello-world></hello-world>
|
||||
|
||||
</v-col>
|
||||
<v-col cols="4">
|
||||
<div class="d-flex justify-center mb-6 mt-4 bg-surface-variant">
|
||||
<v-img
|
||||
class="bg-white"
|
||||
height="86px"
|
||||
src="./images/logo.svg"
|
||||
></v-img>
|
||||
</div>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
`,
|
||||
});
|
||||
|
||||
const vuetify = Vuetify.createVuetify();
|
||||
|
||||
app.use(store);
|
||||
app.use(vuetify);
|
||||
app.use(i18n);
|
||||
loadModule("./components/coba.vue", options).then((component) => {
|
||||
app.component("hello-world", component);
|
||||
app.mount("#app");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
64
loginv2/store/store.js
Normal file
64
loginv2/store/store.js
Normal file
@@ -0,0 +1,64 @@
|
||||
// store/store.js
|
||||
const URL = "/westone-api/v1/system/auth";
|
||||
const store = Vuex.createStore({
|
||||
state() {
|
||||
return {
|
||||
count: 0,
|
||||
data: null,
|
||||
email:null,
|
||||
password:null,
|
||||
dialog_success:false
|
||||
};
|
||||
},
|
||||
mutations: {
|
||||
increment(state) {
|
||||
state.count++;
|
||||
},
|
||||
decrement(state) {
|
||||
state.count--;
|
||||
},
|
||||
setData(state, payload) {
|
||||
state.data = payload;
|
||||
},
|
||||
setEmail(state, data) {
|
||||
state.email = data;
|
||||
},
|
||||
setPassword(state, data) {
|
||||
state.password = data;
|
||||
},
|
||||
setDialogSuccess(state, data) {
|
||||
state.dialog_success = data;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
increment({ commit }) {
|
||||
commit('increment');
|
||||
},
|
||||
decrement({ commit }) {
|
||||
commit('decrement');
|
||||
},
|
||||
async loginState({ state, commit }) {
|
||||
const params = {
|
||||
email: state.email,
|
||||
password: state.pasword
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.post(URL+'/login', params);
|
||||
commit('setData', response.data);
|
||||
} catch (error) {
|
||||
commit('setError', error);
|
||||
}
|
||||
},
|
||||
async LoginParam({ commit }, params) {
|
||||
try {
|
||||
const response = await axios.post(URL+'/login', params);
|
||||
commit('setData', response.data);
|
||||
} catch (error) {
|
||||
commit('setError', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
export default store;
|
||||
|
||||
Reference in New Issue
Block a user