update directory live
Some checks are pending
Build Electron App / build (macos-latest, build:mac) (push) Waiting to run
Build Electron App / build (ubuntu-latest, build:linux) (push) Waiting to run
Build Electron App / build (windows-latest, build:win) (push) Waiting to run

This commit is contained in:
nicwands
2026-03-03 17:21:14 -05:00
parent e9e0abe380
commit 73349444d6
16 changed files with 88339 additions and 39075 deletions

View File

@@ -97,12 +97,33 @@ app.whenReady().then(async () => {
)
await notesAPI.init()
// Broadcast note changes to all windows
const broadcastNoteChange = (event, data) => {
BrowserWindow.getAllWindows().forEach((win) => {
win.webContents.send(event, data)
})
}
// Handle Notes API
ipcMain.handle('notesAPI:call', (_, method, args) => {
ipcMain.handle('notesAPI:call', async (_, method, args) => {
if (!notesAPI[method]) {
throw new Error('Invalid method')
}
return notesAPI[method](...args)
const result = await notesAPI[method](...args)
// Broadcast changes to all windows
if (method === 'createNote') {
broadcastNoteChange('note-created', result)
} else if (method === 'updateNote') {
broadcastNoteChange('note-updated', result)
} else if (method === 'updateNoteMetadata') {
broadcastNoteChange('note-updated', result)
} else if (method === 'deleteNote') {
broadcastNoteChange('note-deleted', { id: args[0] })
}
return result
})
electronApp.setAppUserModelId('com.electron')

View File

@@ -5,6 +5,15 @@ const api = {
openNoteWindow: (noteId) => {
ipcRenderer.send('open-note-window', noteId)
},
onNoteCreated: (callback) => {
ipcRenderer.on('note-created', (_, data) => callback(data))
},
onNoteUpdated: (callback) => {
ipcRenderer.on('note-updated', (_, data) => callback(data))
},
onNoteDeleted: (callback) => {
ipcRenderer.on('note-deleted', (_, data) => callback(data))
},
}
// Implement notes API

View File

@@ -1,17 +1,17 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Electron</title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
/>
</head>
<head>
<meta charset="UTF-8" />
<title>Electron</title>
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:"
/>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

View File

@@ -4,11 +4,7 @@
<Nav />
<div class="menu-wrap layout-block-inner">
<new-note
class="menu-item"
category="Special Delivery"
@noteOpened="closeMenu"
/>
<new-note class="menu-item" @noteOpened="closeMenu" />
<router-link class="menu-item" to="/category"
>+ New Capitulum</router-link
>

View File

@@ -2,8 +2,30 @@ import { ref } from 'vue'
const categories = ref([])
const searchResults = ref([])
const notesChangeCount = ref(0)
let initialized = false
function setupListeners() {
if (initialized || typeof window === 'undefined') return
initialized = true
window.api.onNoteCreated(() => {
notesChangeCount.value++
})
window.api.onNoteUpdated(() => {
notesChangeCount.value++
})
window.api.onNoteDeleted(() => {
notesChangeCount.value++
})
}
export default () => {
setupListeners()
/* -------------------------
Initialization
--------------------------*/
@@ -71,6 +93,7 @@ export default () => {
return {
categories,
searchResults,
notesChangeCount,
loadCategories,
loadCategoryNotes,

View File

@@ -9,8 +9,8 @@
- The "html" element is excluded, otherwise a bug in Chrome breaks the CSS hyphens property (https://github.com/elad2412/the-new-css-reset/issues/36)
*/
*:where(
:not(html, iframe, canvas, img, svg, video, audio):not(svg *, symbol *)
) {
:not(html, iframe, canvas, img, svg, video, audio):not(svg *, symbol *)
) {
all: unset;
display: revert;
}

View File

@@ -18,7 +18,7 @@
</template>
<script setup>
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import useNotes from '@/composables/useNotes'
import NoteRow from '@/components/NoteRow.vue'
@@ -29,14 +29,23 @@ const route = useRoute()
const id = route.params?.id
const router = useRouter()
const { categories, loadCategoryNotes, updateCategory } = useNotes()
const { categories, loadCategoryNotes, updateCategory, notesChangeCount } =
useNotes()
const notes = ref()
onMounted(async () => {
async function refreshNotes() {
if (id) {
notes.value = await loadCategoryNotes(id)
}
}
onMounted(async () => {
await refreshNotes()
})
watch(notesChangeCount, async () => {
await refreshNotes()
})
const onCategoryEdited = async (editedCategory) => {

View File

@@ -14,8 +14,3 @@ const onCategoryEdited = (name) => {
router.push({ name: 'category', params: { id: name } })
}
</script>
<style lang="scss">
main.create-category {
}
</style>

View File

@@ -17,17 +17,26 @@
<script setup>
import useNotes from '@/composables/useNotes'
import { onMounted, ref } from 'vue'
import { onMounted, ref, watch } from 'vue'
import CategoryRow from '@/components/CategoryRow.vue'
import NoteRow from '@/components/NoteRow.vue'
const { categories, loadCategories, loadCategoryNotes } = useNotes()
const { categories, loadCategories, loadCategoryNotes, notesChangeCount } =
useNotes()
const notes = ref()
onMounted(async () => {
async function refreshNotes() {
await loadCategories()
notes.value = await loadCategoryNotes()
}
onMounted(async () => {
await refreshNotes()
})
watch(notesChangeCount, async () => {
await refreshNotes()
})
</script>