From f6096a18016be63c719d2ce5a27d64363862b0fd Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Tue, 22 Jun 2021 00:18:35 +0200 Subject: Initial commit --- app/imap.js | 34 +++++++++++ app/index.html | 13 +++++ app/main.js | 39 +++++++++++++ app/src/App.vue | 3 + app/src/components/Folders.vue | 21 +++++++ app/src/components/Panel.vue | 34 +++++++++++ app/src/index.js | 13 +++++ app/src/mixins/dynamicModelObjectEmit.js | 16 ++++++ app/src/pages/Home.vue | 99 ++++++++++++++++++++++++++++++++ app/src/router.js | 12 ++++ app/src/store.js | 30 ++++++++++ 11 files changed, 314 insertions(+) create mode 100644 app/imap.js create mode 100644 app/index.html create mode 100644 app/main.js create mode 100644 app/src/App.vue create mode 100644 app/src/components/Folders.vue create mode 100644 app/src/components/Panel.vue create mode 100644 app/src/index.js create mode 100644 app/src/mixins/dynamicModelObjectEmit.js create mode 100644 app/src/pages/Home.vue create mode 100644 app/src/router.js create mode 100644 app/src/store.js (limited to 'app') diff --git a/app/imap.js b/app/imap.js new file mode 100644 index 0000000..1ac76a4 --- /dev/null +++ b/app/imap.js @@ -0,0 +1,34 @@ +const { ipcMain } = require('electron'); +const { ImapFlow } = require('imapflow'); + +ipcMain.on('imap:listTree:from', listTreeFrom); +ipcMain.on('imap:listTree:to', listTreeTo); + +async function connect (options) { + const client = new ImapFlow({ + host: options.server, + port: options.port, + auth: { + user: options.username, + pass: options.password, + }, + }); + + await client.connect(); + + return client; +} + +async function listTreeFrom (event, options) { + const client = await connect(options); + + event.reply('imap:listTree:from:reply', await client.listTree()); + await client.logout(); +} + +async function listTreeTo (event, options) { + const client = await connect(options); + + event.reply('imap:listTree:to:reply', await client.listTree()); + await client.logout(); +} diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000..8b7ddc9 --- /dev/null +++ b/app/index.html @@ -0,0 +1,13 @@ + + + + + + Hello World! + + + +
+ + + diff --git a/app/main.js b/app/main.js new file mode 100644 index 0000000..c2b8e30 --- /dev/null +++ b/app/main.js @@ -0,0 +1,39 @@ +const { app, BrowserWindow } = require('electron'); +// const path = require('path'); +const isProduction = process.env.NODE_ENV === 'production'; + +require('./imap'); + +function createWindow () { + const mainWindow = new BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + // preload: path.join(__dirname, 'preload.js') + nodeIntegration: true, + contextIsolation: false, + }, + }); + + mainWindow.loadFile('index.html'); + + if (!isProduction) { + mainWindow.webContents.openDevTools(); + } +} + +app.whenReady().then(() => { + createWindow(); + + app.on('activate', function () { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow(); + } + }); +}); + +app.on('window-all-closed', function () { + if (process.platform !== 'darwin') { + app.quit(); + } +}); diff --git a/app/src/App.vue b/app/src/App.vue new file mode 100644 index 0000000..98240ae --- /dev/null +++ b/app/src/App.vue @@ -0,0 +1,3 @@ + diff --git a/app/src/components/Folders.vue b/app/src/components/Folders.vue new file mode 100644 index 0000000..b801c1a --- /dev/null +++ b/app/src/components/Folders.vue @@ -0,0 +1,21 @@ + + + diff --git a/app/src/components/Panel.vue b/app/src/components/Panel.vue new file mode 100644 index 0000000..3ae4000 --- /dev/null +++ b/app/src/components/Panel.vue @@ -0,0 +1,34 @@ + + + + + diff --git a/app/src/index.js b/app/src/index.js new file mode 100644 index 0000000..46dc556 --- /dev/null +++ b/app/src/index.js @@ -0,0 +1,13 @@ +import { createApp } from 'vue'; +import router from './router'; +import store from './store'; +import App from './App'; + +const app = createApp(App); + +app.config.globalProperties.$electron = require('electron'); + +app.use(router); +app.use(store); + +app.mount('#app'); diff --git a/app/src/mixins/dynamicModelObjectEmit.js b/app/src/mixins/dynamicModelObjectEmit.js new file mode 100644 index 0000000..93701c8 --- /dev/null +++ b/app/src/mixins/dynamicModelObjectEmit.js @@ -0,0 +1,16 @@ +export default { + props: { + modelValue: { + type: Object, + required: true, + }, + }, + + emits: ['update:modelValue'], + + methods: { + emit (key, value) { + this.$emit('update:modelValue', { ...this.modelValue, [key]: value }); + }, + }, +}; diff --git a/app/src/pages/Home.vue b/app/src/pages/Home.vue new file mode 100644 index 0000000..2fe4030 --- /dev/null +++ b/app/src/pages/Home.vue @@ -0,0 +1,99 @@ + + + + + diff --git a/app/src/router.js b/app/src/router.js new file mode 100644 index 0000000..7676449 --- /dev/null +++ b/app/src/router.js @@ -0,0 +1,12 @@ +import { createRouter, createWebHashHistory } from 'vue-router'; +import Home from './pages/Home'; + +export default createRouter({ + history: createWebHashHistory(), + routes: [ + { + path: '/', + component: Home, + }, + ], +}); diff --git a/app/src/store.js b/app/src/store.js new file mode 100644 index 0000000..db5a9fa --- /dev/null +++ b/app/src/store.js @@ -0,0 +1,30 @@ +import { createStore } from 'vuex'; + +export default createStore({ + state () { + return { + from: { + server: 'localhost', + port: '3143', + username: 'd@cool.de', + password: 'lolo11', + }, + to: { + server: '', + port: '', + username: '', + password: '', + }, + }; + }, + + mutations: { + setFrom (state, payload) { + state.from = Object.assign(state.from, payload); + }, + + setTo (state, payload) { + state.to = Object.assign(state.to, payload); + }, + }, +}); -- cgit v1.2.3