diff --git a/public/font/hack/hack-bold.woff b/assets/font/hack/hack-bold.woff similarity index 100% rename from public/font/hack/hack-bold.woff rename to assets/font/hack/hack-bold.woff diff --git a/public/font/hack/hack-bold.woff2 b/assets/font/hack/hack-bold.woff2 similarity index 100% rename from public/font/hack/hack-bold.woff2 rename to assets/font/hack/hack-bold.woff2 diff --git a/public/font/hack/hack-bolditalic.woff b/assets/font/hack/hack-bolditalic.woff similarity index 100% rename from public/font/hack/hack-bolditalic.woff rename to assets/font/hack/hack-bolditalic.woff diff --git a/public/font/hack/hack-bolditalic.woff2 b/assets/font/hack/hack-bolditalic.woff2 similarity index 100% rename from public/font/hack/hack-bolditalic.woff2 rename to assets/font/hack/hack-bolditalic.woff2 diff --git a/public/font/hack/hack-italic.woff b/assets/font/hack/hack-italic.woff similarity index 100% rename from public/font/hack/hack-italic.woff rename to assets/font/hack/hack-italic.woff diff --git a/public/font/hack/hack-italic.woff2 b/assets/font/hack/hack-italic.woff2 similarity index 100% rename from public/font/hack/hack-italic.woff2 rename to assets/font/hack/hack-italic.woff2 diff --git a/public/font/hack/hack-regular.woff b/assets/font/hack/hack-regular.woff similarity index 100% rename from public/font/hack/hack-regular.woff rename to assets/font/hack/hack-regular.woff diff --git a/public/font/hack/hack-regular.woff2 b/assets/font/hack/hack-regular.woff2 similarity index 100% rename from public/font/hack/hack-regular.woff2 rename to assets/font/hack/hack-regular.woff2 diff --git a/public/font/open-sans/fonts/Bold/OpenSans-Bold.woff b/assets/font/open-sans/fonts/Bold/OpenSans-Bold.woff similarity index 100% rename from public/font/open-sans/fonts/Bold/OpenSans-Bold.woff rename to assets/font/open-sans/fonts/Bold/OpenSans-Bold.woff diff --git a/public/font/open-sans/fonts/Bold/OpenSans-Bold.woff2 b/assets/font/open-sans/fonts/Bold/OpenSans-Bold.woff2 similarity index 100% rename from public/font/open-sans/fonts/Bold/OpenSans-Bold.woff2 rename to assets/font/open-sans/fonts/Bold/OpenSans-Bold.woff2 diff --git a/public/font/open-sans/fonts/BoldItalic/OpenSans-BoldItalic.woff b/assets/font/open-sans/fonts/BoldItalic/OpenSans-BoldItalic.woff similarity index 100% rename from public/font/open-sans/fonts/BoldItalic/OpenSans-BoldItalic.woff rename to assets/font/open-sans/fonts/BoldItalic/OpenSans-BoldItalic.woff diff --git a/public/font/open-sans/fonts/BoldItalic/OpenSans-BoldItalic.woff2 b/assets/font/open-sans/fonts/BoldItalic/OpenSans-BoldItalic.woff2 similarity index 100% rename from public/font/open-sans/fonts/BoldItalic/OpenSans-BoldItalic.woff2 rename to assets/font/open-sans/fonts/BoldItalic/OpenSans-BoldItalic.woff2 diff --git a/public/font/open-sans/fonts/ExtraBold/OpenSans-ExtraBold.woff b/assets/font/open-sans/fonts/ExtraBold/OpenSans-ExtraBold.woff similarity index 100% rename from public/font/open-sans/fonts/ExtraBold/OpenSans-ExtraBold.woff rename to assets/font/open-sans/fonts/ExtraBold/OpenSans-ExtraBold.woff diff --git a/public/font/open-sans/fonts/ExtraBold/OpenSans-ExtraBold.woff2 b/assets/font/open-sans/fonts/ExtraBold/OpenSans-ExtraBold.woff2 similarity index 100% rename from public/font/open-sans/fonts/ExtraBold/OpenSans-ExtraBold.woff2 rename to assets/font/open-sans/fonts/ExtraBold/OpenSans-ExtraBold.woff2 diff --git a/public/font/open-sans/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff b/assets/font/open-sans/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff similarity index 100% rename from public/font/open-sans/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff rename to assets/font/open-sans/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff diff --git a/public/font/open-sans/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff2 b/assets/font/open-sans/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff2 similarity index 100% rename from public/font/open-sans/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff2 rename to assets/font/open-sans/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff2 diff --git a/public/font/open-sans/fonts/Italic/OpenSans-Italic.woff b/assets/font/open-sans/fonts/Italic/OpenSans-Italic.woff similarity index 100% rename from public/font/open-sans/fonts/Italic/OpenSans-Italic.woff rename to assets/font/open-sans/fonts/Italic/OpenSans-Italic.woff diff --git a/public/font/open-sans/fonts/Italic/OpenSans-Italic.woff2 b/assets/font/open-sans/fonts/Italic/OpenSans-Italic.woff2 similarity index 100% rename from public/font/open-sans/fonts/Italic/OpenSans-Italic.woff2 rename to assets/font/open-sans/fonts/Italic/OpenSans-Italic.woff2 diff --git a/public/font/open-sans/fonts/Light/OpenSans-Light.woff b/assets/font/open-sans/fonts/Light/OpenSans-Light.woff similarity index 100% rename from public/font/open-sans/fonts/Light/OpenSans-Light.woff rename to assets/font/open-sans/fonts/Light/OpenSans-Light.woff diff --git a/public/font/open-sans/fonts/Light/OpenSans-Light.woff2 b/assets/font/open-sans/fonts/Light/OpenSans-Light.woff2 similarity index 100% rename from public/font/open-sans/fonts/Light/OpenSans-Light.woff2 rename to assets/font/open-sans/fonts/Light/OpenSans-Light.woff2 diff --git a/public/font/open-sans/fonts/LightItalic/OpenSans-LightItalic.woff b/assets/font/open-sans/fonts/LightItalic/OpenSans-LightItalic.woff similarity index 100% rename from public/font/open-sans/fonts/LightItalic/OpenSans-LightItalic.woff rename to assets/font/open-sans/fonts/LightItalic/OpenSans-LightItalic.woff diff --git a/public/font/open-sans/fonts/LightItalic/OpenSans-LightItalic.woff2 b/assets/font/open-sans/fonts/LightItalic/OpenSans-LightItalic.woff2 similarity index 100% rename from public/font/open-sans/fonts/LightItalic/OpenSans-LightItalic.woff2 rename to assets/font/open-sans/fonts/LightItalic/OpenSans-LightItalic.woff2 diff --git a/public/font/open-sans/fonts/Regular/OpenSans-Regular.woff b/assets/font/open-sans/fonts/Regular/OpenSans-Regular.woff similarity index 100% rename from public/font/open-sans/fonts/Regular/OpenSans-Regular.woff rename to assets/font/open-sans/fonts/Regular/OpenSans-Regular.woff diff --git a/public/font/open-sans/fonts/Regular/OpenSans-Regular.woff2 b/assets/font/open-sans/fonts/Regular/OpenSans-Regular.woff2 similarity index 100% rename from public/font/open-sans/fonts/Regular/OpenSans-Regular.woff2 rename to assets/font/open-sans/fonts/Regular/OpenSans-Regular.woff2 diff --git a/public/font/open-sans/fonts/Semibold/OpenSans-Semibold.woff b/assets/font/open-sans/fonts/Semibold/OpenSans-Semibold.woff similarity index 100% rename from public/font/open-sans/fonts/Semibold/OpenSans-Semibold.woff rename to assets/font/open-sans/fonts/Semibold/OpenSans-Semibold.woff diff --git a/public/font/open-sans/fonts/Semibold/OpenSans-Semibold.woff2 b/assets/font/open-sans/fonts/Semibold/OpenSans-Semibold.woff2 similarity index 100% rename from public/font/open-sans/fonts/Semibold/OpenSans-Semibold.woff2 rename to assets/font/open-sans/fonts/Semibold/OpenSans-Semibold.woff2 diff --git a/public/font/open-sans/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff b/assets/font/open-sans/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff similarity index 100% rename from public/font/open-sans/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff rename to assets/font/open-sans/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff diff --git a/public/font/open-sans/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff2 b/assets/font/open-sans/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff2 similarity index 100% rename from public/font/open-sans/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff2 rename to assets/font/open-sans/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff2 diff --git a/public/font/open-sans/open-sans.scss b/assets/font/open-sans/open-sans.scss similarity index 100% rename from public/font/open-sans/open-sans.scss rename to assets/font/open-sans/open-sans.scss diff --git a/public/font/open-sans/sass/.gitignore b/assets/font/open-sans/sass/.gitignore similarity index 100% rename from public/font/open-sans/sass/.gitignore rename to assets/font/open-sans/sass/.gitignore diff --git a/public/font/open-sans/sass/_Bold.scss b/assets/font/open-sans/sass/_Bold.scss similarity index 100% rename from public/font/open-sans/sass/_Bold.scss rename to assets/font/open-sans/sass/_Bold.scss diff --git a/public/font/open-sans/sass/_BoldItalic.scss b/assets/font/open-sans/sass/_BoldItalic.scss similarity index 100% rename from public/font/open-sans/sass/_BoldItalic.scss rename to assets/font/open-sans/sass/_BoldItalic.scss diff --git a/public/font/open-sans/sass/_ExtraBold.scss b/assets/font/open-sans/sass/_ExtraBold.scss similarity index 100% rename from public/font/open-sans/sass/_ExtraBold.scss rename to assets/font/open-sans/sass/_ExtraBold.scss diff --git a/public/font/open-sans/sass/_ExtraBoldItalic.scss b/assets/font/open-sans/sass/_ExtraBoldItalic.scss similarity index 100% rename from public/font/open-sans/sass/_ExtraBoldItalic.scss rename to assets/font/open-sans/sass/_ExtraBoldItalic.scss diff --git a/public/font/open-sans/sass/_Italic.scss b/assets/font/open-sans/sass/_Italic.scss similarity index 100% rename from public/font/open-sans/sass/_Italic.scss rename to assets/font/open-sans/sass/_Italic.scss diff --git a/public/font/open-sans/sass/_Light.scss b/assets/font/open-sans/sass/_Light.scss similarity index 100% rename from public/font/open-sans/sass/_Light.scss rename to assets/font/open-sans/sass/_Light.scss diff --git a/public/font/open-sans/sass/_LightItalic.scss b/assets/font/open-sans/sass/_LightItalic.scss similarity index 100% rename from public/font/open-sans/sass/_LightItalic.scss rename to assets/font/open-sans/sass/_LightItalic.scss diff --git a/public/font/open-sans/sass/_Regular.scss b/assets/font/open-sans/sass/_Regular.scss similarity index 100% rename from public/font/open-sans/sass/_Regular.scss rename to assets/font/open-sans/sass/_Regular.scss diff --git a/public/font/open-sans/sass/_Semibold.scss b/assets/font/open-sans/sass/_Semibold.scss similarity index 100% rename from public/font/open-sans/sass/_Semibold.scss rename to assets/font/open-sans/sass/_Semibold.scss diff --git a/public/font/open-sans/sass/_SemiboldItalic.scss b/assets/font/open-sans/sass/_SemiboldItalic.scss similarity index 100% rename from public/font/open-sans/sass/_SemiboldItalic.scss rename to assets/font/open-sans/sass/_SemiboldItalic.scss diff --git a/public/font/open-sans/sass/_mixins.scss b/assets/font/open-sans/sass/_mixins.scss similarity index 100% rename from public/font/open-sans/sass/_mixins.scss rename to assets/font/open-sans/sass/_mixins.scss diff --git a/assets/font/open-sans/sass/_variables.scss b/assets/font/open-sans/sass/_variables.scss new file mode 100755 index 0000000..59462d2 --- /dev/null +++ b/assets/font/open-sans/sass/_variables.scss @@ -0,0 +1,2 @@ +$OpenSansPath: "@/assets/font/open-sans/fonts" !default; +$OpenSansVersion: "1.1.0" !default; diff --git a/public/font/open-sans/sass/open-sans.scss b/assets/font/open-sans/sass/open-sans.scss similarity index 100% rename from public/font/open-sans/sass/open-sans.scss rename to assets/font/open-sans/sass/open-sans.scss diff --git a/public/icons/both-mode.png b/assets/icons/both-mode.png similarity index 100% rename from public/icons/both-mode.png rename to assets/icons/both-mode.png diff --git a/public/icons/dark-mode.png b/assets/icons/dark-mode.png similarity index 100% rename from public/icons/dark-mode.png rename to assets/icons/dark-mode.png diff --git a/public/icons/download.svg b/assets/icons/download.svg similarity index 100% rename from public/icons/download.svg rename to assets/icons/download.svg diff --git a/public/icons/format.svg b/assets/icons/format.svg similarity index 100% rename from public/icons/format.svg rename to assets/icons/format.svg diff --git a/public/icons/light-mode.png b/assets/icons/light-mode.png similarity index 100% rename from public/icons/light-mode.png rename to assets/icons/light-mode.png diff --git a/public/icons/update.svg b/assets/icons/update.svg similarity index 100% rename from public/icons/update.svg rename to assets/icons/update.svg diff --git a/electron/preload/index.ts b/electron/preload/index.ts index e2ac6c9..c3db29f 100644 --- a/electron/preload/index.ts +++ b/electron/preload/index.ts @@ -1,5 +1,5 @@ const { contextBridge } = require('electron') -import darkMode from "./theme-mode" +import themeMode from "./theme-mode" import { isMac, isWindows, isLinux } from "../detect-platform" import { ipcRenderer } from "electron" import { @@ -18,8 +18,6 @@ import { import CONFIG from "../config" import getCurrencyData from "./currency" -//contextBridge.exposeInMainWorld("platform", ) -contextBridge.exposeInMainWorld("darkMode", darkMode) contextBridge.exposeInMainWorld("heynote", { platform: { @@ -28,6 +26,8 @@ contextBridge.exposeInMainWorld("heynote", { isLinux, }, + themeMode: themeMode, + quit() { console.log("quitting") //ipcRenderer.invoke("app_quit") diff --git a/electron/preload/theme-mode.ts b/electron/preload/theme-mode.ts index cbae8d1..72bbd3c 100644 --- a/electron/preload/theme-mode.ts +++ b/electron/preload/theme-mode.ts @@ -2,7 +2,7 @@ const { ipcRenderer } = require('electron') const getComputedTheme = () => window.matchMedia('(prefers-color-scheme: dark)').matches ? "dark" : "light" const mediaMatch = window.matchMedia('(prefers-color-scheme: dark)') -let darkModeChangeListener = null +let themeModeChangeListener = null export default { set: (mode) => ipcRenderer.invoke('dark-mode:set', mode), @@ -14,14 +14,14 @@ export default { } }, onChange: (callback) => { - darkModeChangeListener = (event) => { + themeModeChangeListener = (event) => { callback(event.matches ? "dark" : "light") } - mediaMatch.addEventListener('change', darkModeChangeListener) + mediaMatch.addEventListener('change', themeModeChangeListener) return mediaMatch }, removeListener() { - mediaMatch.removeEventListener('change', darkModeChangeListener) + mediaMatch.removeEventListener('change', themeModeChangeListener) }, initial: getComputedTheme(), } diff --git a/package-lock.json b/package-lock.json index 7741b60..6087403 100644 --- a/package-lock.json +++ b/package-lock.json @@ -48,7 +48,7 @@ "rollup-plugin-license": "^3.0.1", "sass": "^1.57.1", "typescript": "^4.9.4", - "vite": "^4.0.5", + "vite": "^4.5.1", "vite-plugin-electron": "^0.11.1", "vite-plugin-electron-renderer": "^0.11.4", "vue": "^3.2.45", diff --git a/package.json b/package.json index feb2a38..d352e1a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "build": "vue-tsc --noEmit && vite build && electron-builder -c electron-builder.json5", "prebuild": "vue-tsc --noEmit && vite build", "preview": "vite preview", - "build_grammar": "lezer-generator src/editor/lang-heynote/heynote.grammar -o src/editor/lang-heynote/parser.js" + "build_grammar": "lezer-generator src/editor/lang-heynote/heynote.grammar -o src/editor/lang-heynote/parser.js", + "webapp:dev": "vite webapp", + "webapp:build": "vite build webapp" }, "devDependencies": { "@codemirror/autocomplete": "^6.11.1", @@ -63,7 +65,7 @@ "rollup-plugin-license": "^3.0.1", "sass": "^1.57.1", "typescript": "^4.9.4", - "vite": "^4.0.5", + "vite": "^4.5.1", "vite-plugin-electron": "^0.11.1", "vite-plugin-electron-renderer": "^0.11.4", "vue": "^3.2.45", diff --git a/public/font/open-sans/sass/_variables.scss b/public/font/open-sans/sass/_variables.scss deleted file mode 100755 index 5144c5b..0000000 --- a/public/font/open-sans/sass/_variables.scss +++ /dev/null @@ -1,2 +0,0 @@ -$OpenSansPath: "font/open-sans/fonts" !default; -$OpenSansVersion: "1.1.0" !default; diff --git a/src/components/App.vue b/src/components/App.vue index 209e2b8..6b0a326 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -19,8 +19,8 @@ selectionSize: 0, language: "plaintext", languageAuto: true, - theme: window.darkMode.initial, - initialTheme: window.darkMode.initial, + theme: window.heynote.themeMode.initial, + initialTheme: window.heynote.themeMode.initial, systemTheme: 'system', development: window.location.href.indexOf("dev=1") !== -1, showLanguageSelector: false, @@ -30,13 +30,20 @@ }, mounted() { - window.darkMode.get().then((mode) => { + window.heynote.themeMode.get().then((mode) => { this.theme = mode.computed this.systemTheme = mode.theme }) - window.darkMode.onChange((theme) => { + const onChangeCallback = (theme) => { this.theme = theme - }) + if (theme === "system") { + document.body.setAttribute("theme", window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") + } else { + document.body.setAttribute("theme", theme) + } + } + onChangeCallback(window.heynote.themeMode.initial) + window.heynote.themeMode.onChange(onChangeCallback) window.heynote.onSettingsChange((settings) => { this.settings = settings }) @@ -46,7 +53,7 @@ }, beforeUnmount() { - window.darkMode.removeListener() + window.heynote.themeMode.removeListener() }, methods: { @@ -66,7 +73,7 @@ } else { newTheme = this.systemTheme === "system" ? "light" : (this.systemTheme === "light" ? "dark" : "system") } - window.darkMode.set(newTheme) + window.heynote.themeMode.set(newTheme) this.systemTheme = newTheme this.$refs.editor.focus() }, diff --git a/src/components/StatusBar.vue b/src/components/StatusBar.vue index 2320f52..04b53c2 100644 --- a/src/components/StatusBar.vue +++ b/src/components/StatusBar.vue @@ -50,6 +50,10 @@ changeLanguageTitle() { return `Change language for current block (${this.cmdKey} + L)` }, + + updatesEnabled() { + return !!window.heynote.autoUpdate + }, }, } @@ -80,7 +84,7 @@ > - +
@@ -148,11 +152,11 @@ +dark-mode opacity: 0.9 &.dark - background-image: url("icons/dark-mode.png") + background-image: url("@/assets/icons/dark-mode.png") &.light - background-image: url("icons/light-mode.png") + background-image: url("@/assets/icons/light-mode.png") &.system - background-image: url("icons/both-mode.png") + background-image: url("@/assets/icons/both-mode.png") .format padding-top: 0 @@ -166,6 +170,6 @@ background-size: 16px background-repeat: no-repeat background-position: center center - background-image: url("icons/format.svg") + background-image: url("@/assets/icons/format.svg") diff --git a/src/components/UpdateStatusItem.vue b/src/components/UpdateStatusItem.vue index a9b1570..5b70edc 100644 --- a/src/components/UpdateStatusItem.vue +++ b/src/components/UpdateStatusItem.vue @@ -176,14 +176,14 @@ background-size: 14px background-repeat: no-repeat background-position: center center - background-image: url("icons/update.svg") + background-image: url("@/assets/icons/update.svg") animation-name: spin animation-duration: 2000ms animation-iteration-count: infinite animation-timing-function: linear animation-play-state: paused &.icon-download - background-image: url("icons/download.svg") + background-image: url("@/assets/icons/download.svg") width: 16px height: 16px background-size: 16px diff --git a/src/css/font.sass b/src/css/font.sass index 81d85cd..d95ef78 100644 --- a/src/css/font.sass +++ b/src/css/font.sass @@ -1,27 +1,27 @@ @font-face font-family: 'Hack' - src: url('font/hack/hack-regular.woff2') format('woff2'), url('font/hack/hack-regular.woff') format('woff') + src: url('@/assets/font/hack/hack-regular.woff2') format('woff2'), url('@/assets/font/hack/hack-regular.woff') format('woff') font-weight: 400 font-style: normal @font-face font-family: 'Hack' - src: url('font/hack/hack-bold.woff2') format('woff2'), url('font/hack/hack-bold.woff') format('woff') + src: url('@/assets/font/hack/hack-bold.woff2') format('woff2'), url('@/assets/font/hack/hack-bold.woff') format('woff') font-weight: 700 font-style: normal @font-face font-family: 'Hack' - src: url('font/hack/hack-italic.woff2') format('woff2'), url('font/hack/hack-italic.woff') format('woff') + src: url('@/assets/font/hack/hack-italic.woff2') format('woff2'), url('@/assets/font/hack/hack-italic.woff') format('woff') font-weight: 400 font-style: italic @font-face font-family: 'Hack' - src: url('font/hack/hack-bolditalic.woff2') format('woff2'), url('font/hack/hack-bolditalic.woff') format('woff') + src: url('@/assets/font/hack/hack-bolditalic.woff2') format('woff2'), url('@/assets/font/hack/hack-bolditalic.woff') format('woff') font-weight: 700 font-style: italic -@import "~/../public/font/open-sans/open-sans" +@import "@/assets/font/open-sans/open-sans" diff --git a/src/css/include.sass b/src/css/include.sass index 152d9ec..e8f61ea 100644 --- a/src/css/include.sass +++ b/src/css/include.sass @@ -1,3 +1,5 @@ =dark-mode() @media (prefers-color-scheme: dark) @content + body[theme=dark] & + @content diff --git a/vite.config.ts b/vite.config.ts index 68e3ca8..fc1a0db 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,6 +6,7 @@ import electron from 'vite-plugin-electron' import renderer from 'vite-plugin-electron-renderer' import license from 'rollup-plugin-license' import pkg from './package.json' +import path from 'path' rmSync('dist-electron', { recursive: true, force: true }) @@ -14,6 +15,12 @@ const isProduction = process.env.NODE_ENV === "production" // https://vitejs.dev/config/ export default defineConfig({ + resolve: { + alias: { + '@': path.resolve(__dirname), + }, + }, + plugins: [ vue(), electron([ diff --git a/webapp/bridge.js b/webapp/bridge.js new file mode 100644 index 0000000..75f01d5 --- /dev/null +++ b/webapp/bridge.js @@ -0,0 +1,80 @@ +const mediaMatch = window.matchMedia('(prefers-color-scheme: dark)') +let themeModeChangeListener = null +let autoUpdateCallbacks = null +let themeCallback = null + +let currencyData = null + +export default { + platform: { + isMac: true, + isWindows: false, + isLinux: false, + }, + + buffer: { + async load() { + const content = localStorage.getItem("buffer") + return content === null ? "\n∞∞∞text-a\n" : content + }, + + async save(content) { + console.log("saving buffer") + localStorage.setItem("buffer", content) + }, + + async saveAndQuit(content) { + + }, + }, + + onWindowClose(callback) { + //ipcRenderer.on(WINDOW_CLOSE_EVENT, callback) + }, + + onOpenSettings(callback) { + //ipcRenderer.on(OPEN_SETTINGS_EVENT, callback) + }, + + onSettingsChange(callback) { + //ipcRenderer.on(SETTINGS_CHANGE_EVENT, (event, settings) => callback(settings)) + }, + + themeMode: { + set: (mode) => { + themeCallback(mode) + document.body.setAttribute("theme", mode === "dark" ? "dark" : "light") + }, + get: async () => { + return { + theme: "light", + computed: "light", + } + }, + onChange: (callback) => { + themeCallback = callback + themeModeChangeListener = (event) => { + callback(event.matches ? "dark" : "light") + } + mediaMatch.addEventListener('change', themeModeChangeListener) + return mediaMatch + }, + removeListener() { + mediaMatch.removeEventListener('change', themeModeChangeListener) + }, + initial: "light", + }, + + settings: { + keymap: "default", + }, + + getCurrencyData: async () => { + if (currencyData !== null) { + return currencyData + } + const response = await fetch("https://currencies.heynote.com/rates.json", {cache: "no-cache"}) + currencyData = JSON.parse(await response.text()) + return currencyData + }, +} diff --git a/webapp/index.html b/webapp/index.html new file mode 100644 index 0000000..9f88204 --- /dev/null +++ b/webapp/index.html @@ -0,0 +1,21 @@ + + + + + + + + Heynote + + +
+ + + + + + + diff --git a/webapp/main.js b/webapp/main.js new file mode 100644 index 0000000..01d18da --- /dev/null +++ b/webapp/main.js @@ -0,0 +1,13 @@ +import '../src/css/application.sass' + +import { createApp } from 'vue' +import App from '../src/components/App.vue' +import { loadCurrencies } from '../src/currency' + +const app = createApp(App) +app.mount('#app') +//console.log("test:", app.hej.test) + +// load math.js currencies +loadCurrencies() +setInterval(loadCurrencies, 1000 * 3600 * 4) diff --git a/webapp/vite.config.js b/webapp/vite.config.js new file mode 100644 index 0000000..eba1ff3 --- /dev/null +++ b/webapp/vite.config.js @@ -0,0 +1,54 @@ +import path from 'path' + +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +//import { directoryPlugin } from "vite-plugin-list-directory-contents"; + + +const middleware = () => { + return { + name: 'middleware', + apply: 'serve', + configureServer(viteDevServer) { + return () => { + viteDevServer.middlewares.use(async (req, res, next) => { + console.log("url:", req.originalUrl) + if (!req.originalUrl.endsWith(".html") && req.originalUrl !== "/") { + req.url = `/src` + req.originalUrl + ".html"; + } else if (req.url === "/index.html") { + //req.url = `/src` + req.url; + } + + next(); + }); + }; + } + } +} + + +// https://vitejs.dev/config/ +export default defineConfig({ + publicDir: "../public", + + plugins: [ + vue(), + //directoryPlugin({ baseDir: __dirname }), + ], + + css: { + preprocessorOptions: { + sass: { + additionalData: ` + @import "../src/css/include.sass" + ` + }, + }, + }, + + resolve: { + alias: { + '@': path.resolve(__dirname, '..'), + }, + }, +})