mirror of
https://github.com/kevin-DL/build-gmail-clone-with-vue-3.git
synced 2026-01-23 23:51:25 +00:00
Can switch between inbox and archived mail screens and keep changes in archived videos
This commit is contained in:
18
src/App.vue
18
src/App.vue
@@ -1,17 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<button @click="screenName = 'ArchivedScreen'"
|
<button @click="screenName = 'MailScreenArchived'"
|
||||||
:disabled="screenName == 'ArchivedScreen'">
|
:disabled="screenName == 'MailScreenArchived'">
|
||||||
Archived View
|
Archived View
|
||||||
</button>
|
</button>
|
||||||
<button @click="screenName = 'InboxScreen'"
|
<button @click="screenName = 'MailScreenInbox'"
|
||||||
:disabled="screenName == 'InboxScreen'">
|
:disabled="screenName == 'MailScreenInbox'">
|
||||||
Inbox View
|
Inbox View
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<suspense>
|
<suspense>
|
||||||
<template #default>
|
<template #default>
|
||||||
<component :is="screenName" />
|
<MailScreen :screenName="screenName" />
|
||||||
</template>
|
</template>
|
||||||
<template #fallback>
|
<template #fallback>
|
||||||
<p>Loading...</p>
|
<p>Loading...</p>
|
||||||
@@ -21,17 +21,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import InboxScreen from './components/InboxScreen.vue';
|
import MailScreen from '@/components/MailScreen.vue';
|
||||||
import ArchivedScreen from '@/components/ArchivedScreen.vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
components: {
|
components: {
|
||||||
InboxScreen,
|
MailScreen
|
||||||
ArchivedScreen
|
|
||||||
},
|
},
|
||||||
setup(){
|
setup(){
|
||||||
let screenName = 'InboxScreen';
|
let screenName = 'MailScreenInbox';
|
||||||
return {screenName}
|
return {screenName}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
36
src/components/MailScreen.vue
Normal file
36
src/components/MailScreen.vue
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<component :is="screenName" :emails="emails" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import MailScreenArchived from '@/components/MailScreenArchived.vue';
|
||||||
|
import MailScreenInbox from '@/components/MailScreenInbox.vue';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
async setup(){
|
||||||
|
let response = await fetch('/api/emails');
|
||||||
|
let {emails} = await response.json();
|
||||||
|
|
||||||
|
emails = ref(emails);
|
||||||
|
|
||||||
|
return {emails};
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
MailScreenArchived,
|
||||||
|
MailScreenInbox
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
screenName: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -10,16 +10,12 @@
|
|||||||
import MailTable from '@/components/MailTable.vue';
|
import MailTable from '@/components/MailTable.vue';
|
||||||
import BulkActionBar from '@/components/BulkActionBar.vue';
|
import BulkActionBar from '@/components/BulkActionBar.vue';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async setup(){
|
async setup({emails}){
|
||||||
let response = await fetch('/api/emails');
|
|
||||||
let {emails} = await response.json();
|
|
||||||
|
|
||||||
emails = ref(emails);
|
|
||||||
let archivedEmails = computed(() => {
|
let archivedEmails = computed(() => {
|
||||||
return emails.value.filter(e => e.archived)
|
return emails.filter(e => e.archived)
|
||||||
})
|
})
|
||||||
|
|
||||||
return {archivedEmails}
|
return {archivedEmails}
|
||||||
@@ -10,16 +10,12 @@
|
|||||||
import MailTable from '@/components/MailTable.vue';
|
import MailTable from '@/components/MailTable.vue';
|
||||||
import BulkActionBar from '@/components/BulkActionBar.vue';
|
import BulkActionBar from '@/components/BulkActionBar.vue';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async setup(){
|
async setup({emails}){
|
||||||
let response = await fetch('/api/emails');
|
|
||||||
let {emails} = await response.json();
|
|
||||||
|
|
||||||
emails = ref(emails);
|
|
||||||
let inboxEmails = computed(() => {
|
let inboxEmails = computed(() => {
|
||||||
return emails.value.filter(e => !e.archived)
|
return emails.filter(e => !e.archived)
|
||||||
})
|
})
|
||||||
|
|
||||||
return {inboxEmails}
|
return {inboxEmails}
|
||||||
Reference in New Issue
Block a user