Skip to content

Commit

Permalink
fix theme loading
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD authored and NotThorny committed May 20, 2023
1 parent 544d0a1 commit 662fad6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ fn main() -> Result<(), ArgsError> {
println!("You running as a non-elevated user. Some stuff will almost definitely not work.");
println!("===============================================================================");

reopen_as_admin();
//reopen_as_admin();
}

// Setup datadir/cultivation just in case something went funky and it wasn't made
Expand Down
6 changes: 3 additions & 3 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"tauri": {
"allowlist": {
"fs": {
"scope": ["$DATA", "$DATA/cultivation", "$DATA/cultivation/*"]
"scope": ["$DATA", "$DATA/cultivation", "$DATA/cultivation/**"]
},
"protocol": {
"all": true,
"asset": true,
"assetScope": ["$DATA", "$DATA/cultivation", "$DATA/cultivation/*"]
"assetScope": ["$DATA", "$DATA/cultivation", "$DATA/cultivation/**"]
},
"all": true
},
Expand Down Expand Up @@ -53,7 +53,7 @@
}
},
"security": {
"csp": "default-src 'self' https://asset.localhost; img-src 'self'; img-src https://* asset: https://asset.localhost"
"csp": "default-src 'self'; img-src 'self'; img-src https://* asset: https://asset.localhost; media-src https://* asset: https://asset.localhost"
},
"updater": {
"active": false,
Expand Down
32 changes: 19 additions & 13 deletions src/utils/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,32 @@ export async function loadTheme(theme: ThemeList, document: Document) {
const cssIncludes = theme.includes.css
const jsIncludes = theme.includes.js

console.log(theme.includes)

// Load CSS files
cssIncludes.forEach((css) => {
if (!css) return
if (cssIncludes) {
cssIncludes?.forEach((css) => {
if (!css) return

const link = document.createElement('link')
const link = document.createElement('link')

link.rel = 'stylesheet'
link.href = convertFileSrc(theme.path + '/' + css)
head.appendChild(link)
})
link.rel = 'stylesheet'
link.href = convertFileSrc(theme.path + '/' + css)
head.appendChild(link)
})
}

// Load JS files
jsIncludes.forEach((js) => {
if (!js) return
if (jsIncludes) {
jsIncludes.forEach((js) => {
if (!js) return

const script = document.createElement('script')
const script = document.createElement('script')

script.src = convertFileSrc(theme.path + '/' + js)
head.appendChild(script)
})
script.src = convertFileSrc(theme.path + '/' + js)
head.appendChild(script)
})
}

// Set custom background
if (theme.customBackgroundURL) {
Expand Down

0 comments on commit 662fad6

Please sign in to comment.