first commit
This commit is contained in:
48
pakaivue/components/AnotherComponent.vue
Normal file
48
pakaivue/components/AnotherComponent.vue
Normal file
@@ -0,0 +1,48 @@
|
||||
<!-- components/AnotherComponent.vue -->
|
||||
<template>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<h2>{{ $t('anotherComponent.title') }}</h2>
|
||||
<v-text-field v-model="param2" :label="$t('anotherComponent.param2Label')"></v-text-field>
|
||||
<p>{{ $t('anotherComponent.param2') }}: {{ param2 }}</p>
|
||||
<v-btn @click="sendData">{{ $t('anotherComponent.sendDataButton') }}</v-btn>
|
||||
<div v-if="data">{{ $t('anotherComponent.response') }}: {{ data }}</div>
|
||||
<div v-if="error">{{ $t('anotherComponent.error') }}: {{ error.message }}</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
param2: {
|
||||
get() {
|
||||
return this.$store.state.param2;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit('setParam2', value);
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return this.$store.state.data;
|
||||
},
|
||||
error() {
|
||||
return this.$store.state.error;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
sendData() {
|
||||
this.$store.dispatch('sendData');
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
h2 {
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
|
||||
34
pakaivue/components/ComponentA.vue
Normal file
34
pakaivue/components/ComponentA.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<!-- components/ComponentA.vue -->
|
||||
<template>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<h2>{{ $t('message.login') }}</h2>
|
||||
<v-text-field v-model="param1" :label="$t('message.email')"></v-text-field>
|
||||
<p>{{ $t('message.param1') }}: {{ param1 }}</p>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
param1: {
|
||||
get() {
|
||||
return this.$store.state.param1;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit('setParam1', value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
h2 {
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
48
pakaivue/components/ComponentB.vue
Normal file
48
pakaivue/components/ComponentB.vue
Normal file
@@ -0,0 +1,48 @@
|
||||
<!-- components/ComponentB.vue -->
|
||||
<template>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<h2>{{ $t('message.login') }}</h2>
|
||||
<v-text-field v-model="param2" :label="$t('message.password')"></v-text-field>
|
||||
<p>{{ $t('message.param2') }}: {{ param2 }}</p>
|
||||
<v-btn @click="sendData">{{ $t('message.login') }}</v-btn>
|
||||
<div v-if="data">{{ $t('message.response') }}: {{ data }}</div>
|
||||
<div v-if="error">{{ $t('message.error') }}: {{ error.message }}</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
param2: {
|
||||
get() {
|
||||
return this.$store.state.param2;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit('setParam2', value);
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return this.$store.state.data;
|
||||
},
|
||||
error() {
|
||||
return this.$store.state.error;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
sendData() {
|
||||
this.$store.dispatch('sendData');
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
h2 {
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
|
||||
34
pakaivue/components/MyComponent.vue
Normal file
34
pakaivue/components/MyComponent.vue
Normal file
@@ -0,0 +1,34 @@
|
||||
<!-- components/MyComponent.vue -->
|
||||
<template>
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<h2>{{ $t('myComponent.title') }}</h2>
|
||||
<v-text-field v-model="param1" :label="$t('myComponent.param1Label')"></v-text-field>
|
||||
<p>{{ $t('myComponent.param1') }}: {{ param1 }}</p>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
param1: {
|
||||
get() {
|
||||
return this.$store.state.param1;
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit('setParam1', value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
h2 {
|
||||
color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
102
pakaivue/index.html
Normal file
102
pakaivue/index.html
Normal file
@@ -0,0 +1,102 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vue App with SFC Loader</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>
|
||||
<!-- vue-sfc-loader -->
|
||||
<script src="../libraries/vue3-sfc-loader.js"></script>
|
||||
<!-- Store JS -->
|
||||
<script type="module">
|
||||
import store from './store/index.js';
|
||||
|
||||
const { loadModule } = window['vue-sfc-loader'];
|
||||
|
||||
const messages = {
|
||||
en: {
|
||||
message: {
|
||||
login: 'Login',
|
||||
email: 'Email',
|
||||
password: 'Password',
|
||||
forgotPassword: 'Forgot password?',
|
||||
placeholderEmail: 'Enter your email',
|
||||
placeholderPassword: 'Enter your password',
|
||||
param1: 'Parameter 1',
|
||||
param2: 'Parameter 2',
|
||||
response: 'Response',
|
||||
error: 'Error'
|
||||
}
|
||||
},
|
||||
id: {
|
||||
message: {
|
||||
login: 'Masuk',
|
||||
email: 'Surel',
|
||||
password: 'Kata Sandi',
|
||||
forgotPassword: 'Lupa kata sandi?',
|
||||
placeholderEmail: 'Isikan email anda',
|
||||
placeholderPassword: 'Isikan kata sandi anda',
|
||||
param1: 'Parameter 1',
|
||||
param2: 'Parameter 2',
|
||||
response: 'Respons',
|
||||
error: 'Kesalahan'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const browserLocale = navigator.language || navigator.languages[0];
|
||||
|
||||
const i18n = VueI18n.createI18n({
|
||||
locale: browserLocale.startsWith('id') ? 'id' : 'en',
|
||||
fallbackLocale: 'en',
|
||||
messages,
|
||||
});
|
||||
|
||||
const options = {
|
||||
moduleCache: {
|
||||
vue: Vue,
|
||||
},
|
||||
getFile(url) {
|
||||
return fetch(url).then(response => response.ok ? response.text() : Promise.reject(response));
|
||||
},
|
||||
addStyle(textContent) {
|
||||
const style = Object.assign(document.createElement('style'), { textContent });
|
||||
const ref = document.head.getElementsByTagName('style')[0] || null;
|
||||
document.head.insertBefore(style, ref);
|
||||
}
|
||||
};
|
||||
|
||||
const app = Vue.createApp({
|
||||
components: {
|
||||
'component-a': Vue.defineAsyncComponent(() => loadModule('./components/ComponentA.vue', options)),
|
||||
'component-b': Vue.defineAsyncComponent(() => loadModule('./components/ComponentB.vue', options))
|
||||
}
|
||||
});
|
||||
|
||||
const vuetify = Vuetify.createVuetify();
|
||||
|
||||
app.use(store);
|
||||
app.use(vuetify);
|
||||
app.use(i18n);
|
||||
app.mount('#app');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
45
pakaivue/store/index.js
Normal file
45
pakaivue/store/index.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// store/index.js
|
||||
import { createStore } from '../../libraries/vuex.js';
|
||||
import axios from '../../libraries/axios.js';
|
||||
|
||||
const store = createStore({
|
||||
state() {
|
||||
return {
|
||||
data: null,
|
||||
error: null,
|
||||
param1: 'value1',
|
||||
param2: 'value2'
|
||||
};
|
||||
},
|
||||
mutations: {
|
||||
setData(state, payload) {
|
||||
state.data = payload;
|
||||
},
|
||||
setError(state, error) {
|
||||
state.error = error;
|
||||
},
|
||||
setParam1(state, value) {
|
||||
state.param1 = value;
|
||||
},
|
||||
setParam2(state, value) {
|
||||
state.param2 = value;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async sendData({ state, commit }) {
|
||||
const params = {
|
||||
param1: state.param1,
|
||||
param2: state.param2
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.post('https://example.com/api/endpoint', params);
|
||||
commit('setData', response.data);
|
||||
} catch (error) {
|
||||
commit('setError', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default store;
|
||||
Reference in New Issue
Block a user