started work on displaying local images in pure js

This commit is contained in:
Adrian Osterwind 2024-11-14 11:32:32 +01:00
parent ad8cd4339b
commit 9983220f89
2 changed files with 9 additions and 11 deletions

View file

@ -40,7 +40,7 @@ pub fn run() {
.setup(|app| {
// allowed the given directory
let scope = app.fs_scope();
scope.allow_directory("/home/toxotes", true);
scope.allow_directory(tauri::path::BaseDirectory::Home.variable(), true);
app.set_theme(Some(tauri::Theme::Dark));
Ok(())

View file

@ -1,13 +1,11 @@
const { invoke } = window.__TAURI__.core;
const {readFile } = window.__TAURI__.fs;
const { convertFileSrc, invoke } = window.__TAURI__.core;
const { homeDir, join } = window.__TAURI__.path;
const { readFile } = window.__TAURI__.fs;
let greetInputEl;
let greetMsgEl;
const appDataDirPath = await homeDir();
const filePath = await join(appDataDirPath, 'Pictures/wallpaper.png');
async function greet() {
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
greetMsgEl.textContent = await invoke("greet", { name: "harald" });
}
const assetUrl = convertFileSrc(filePath);
let text = "";
window.addEventListener("DOMCharacterDataModified", () => {
@ -18,8 +16,8 @@ window.addEventListener("DOMCharacterDataModified", () => {
invoke("parse_markdown", { document: text }).then(
(ret)=>{
var tag_id = document.getElementById('rendered_markdown');
tag_id.innerHTML = "<pre>".concat("", ret).concat("", "</pre>");
// tag_id.innerHTML = ret;
// tag_id.innerHTML = "<pre>".concat("", ret).concat("", "</pre>");
tag_id.innerText = assetUrl.concat("", ' \n <img src="'.concat("", assetUrl).concat("", '" alt="Girl in a jacket" width="500" height="600">'))
}
);