started work on displaying local images in pure js
This commit is contained in:
parent
ad8cd4339b
commit
9983220f89
2 changed files with 9 additions and 11 deletions
|
|
@ -40,7 +40,7 @@ pub fn run() {
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
// allowed the given directory
|
// allowed the given directory
|
||||||
let scope = app.fs_scope();
|
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));
|
app.set_theme(Some(tauri::Theme::Dark));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
18
src/main.js
18
src/main.js
|
|
@ -1,13 +1,11 @@
|
||||||
const { invoke } = window.__TAURI__.core;
|
const { convertFileSrc, invoke } = window.__TAURI__.core;
|
||||||
const {readFile } = window.__TAURI__.fs;
|
const { homeDir, join } = window.__TAURI__.path;
|
||||||
|
const { readFile } = window.__TAURI__.fs;
|
||||||
|
|
||||||
let greetInputEl;
|
const appDataDirPath = await homeDir();
|
||||||
let greetMsgEl;
|
const filePath = await join(appDataDirPath, 'Pictures/wallpaper.png');
|
||||||
|
|
||||||
async function greet() {
|
const assetUrl = convertFileSrc(filePath);
|
||||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
|
||||||
greetMsgEl.textContent = await invoke("greet", { name: "harald" });
|
|
||||||
}
|
|
||||||
|
|
||||||
let text = "";
|
let text = "";
|
||||||
window.addEventListener("DOMCharacterDataModified", () => {
|
window.addEventListener("DOMCharacterDataModified", () => {
|
||||||
|
|
@ -18,8 +16,8 @@ window.addEventListener("DOMCharacterDataModified", () => {
|
||||||
invoke("parse_markdown", { document: text }).then(
|
invoke("parse_markdown", { document: text }).then(
|
||||||
(ret)=>{
|
(ret)=>{
|
||||||
var tag_id = document.getElementById('rendered_markdown');
|
var tag_id = document.getElementById('rendered_markdown');
|
||||||
tag_id.innerHTML = "<pre>".concat("", ret).concat("", "</pre>");
|
// tag_id.innerHTML = "<pre>".concat("", ret).concat("", "</pre>");
|
||||||
// tag_id.innerHTML = ret;
|
tag_id.innerText = assetUrl.concat("", ' \n <img src="'.concat("", assetUrl).concat("", '" alt="Girl in a jacket" width="500" height="600">'))
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue