Skip to content

Commit 752deaa

Browse files
committed
feat: implement image assets reading directly from the file system
1 parent f2d8943 commit 752deaa

File tree

7 files changed

+31
-45
lines changed

7 files changed

+31
-45
lines changed

src-tauri/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ tauri-build = { version = "2.4.0", features = [] }
2121
serde_json = "1.0"
2222
serde = { version = "1.0", features = ["derive"] }
2323
log = "0.4"
24-
tauri = { version = "2.8.4", features = ["macos-private-api"] }
24+
tauri = { version = "2.8.4", features = ["protocol-asset", "macos-private-api"] }
2525
tauri-plugin-log = "2"
2626

2727
# Non-default installed plugins

src-tauri/tauri.conf.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
}
2828
],
2929
"security": {
30-
"csp": null
30+
"csp": null,
31+
"assetProtocol": {
32+
"enable": true,
33+
"scope": {
34+
"allow": ["$APPDATA", "$APPDATA/**/*"]
35+
}
36+
}
3137
}
3238
},
3339
"bundle": {

src/components/general/layout/GlobalBackground.vue

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<script setup lang="ts">
2-
import { computed, inject, shallowReactive } from "vue";
2+
import { computed, inject } from "vue";
33
44
import Image from "@/components/general/base/Image.vue";
5-
import { ApplicationNamespace, GlobalStatesContextKey } from "@/constants/application.ts";
6-
import GlobalStateHelpers from "@/lib/global-state-helpers";
5+
import { GlobalStatesContextKey } from "@/constants/application.ts";
76
import type {
87
ContextGlobalStatesType,
98
GlobalStatesType,
@@ -18,37 +17,9 @@ const image = computed((): GlobalStatesType["layout"]["background"] => {
1817
"key" : background?.key ?? Math.random(),
1918
"url" : background?.url,
2019
"blur" : background?.blur ?? 0,
21-
"color": background?.color ?? "rgb(23, 23, 23)",
20+
"color": background?.color ?? "rgb(17, 17, 17)",
2221
};
2322
});
24-
25-
// TODO Temporary code: implement as a plugin
26-
const previousRoute = shallowReactive<{
27-
"value": GlobalStatesType["pages"]["current"] | undefined;
28-
}>({
29-
"value": undefined,
30-
});
31-
32-
async function updateImageKey(data: GlobalStatesType["pages"]): Promise<void> {
33-
if (!globalStates) {
34-
return;
35-
}
36-
37-
if (previousRoute.value !== data.current) {
38-
GlobalStateHelpers.change("layout", {
39-
...globalStates.layout,
40-
"background": {
41-
...globalStates.layout?.background,
42-
"key": Math.random(),
43-
},
44-
});
45-
}
46-
47-
previousRoute.value = data.current;
48-
}
49-
50-
window[ApplicationNamespace].hooks.onPagesChange.after.push(updateImageKey);
51-
// TODO Temporary code end
5223
</script>
5324

5425
<template>

src/components/general/layout/Sidebar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ function handleButtonAction(action: () => void): void {
120120
:handle-mouse-over="handleMouseOver"
121121
:handle-button-action="handleButtonAction"
122122
/>
123+
<!-- Using 'py-2' instead of 'p-2' seems more logical, -->
124+
<!-- but somehow buttons are clipped on container overflow when I remove horizontal padding -->
123125
<TransitionGroup
124126
@mouseover="handleMouseOver"
125127
name="fade"
@@ -169,7 +171,7 @@ function handleButtonAction(action: () => void): void {
169171
<div
170172
v-else
171173
:id="`__sidebar__entry-divider-${index}`"
172-
class="h-[1px] w-[calc(100%-24px)] bg-[theme(colors.neutral.100/.1)]"
174+
class="h-[1px] w-[calc(100%-8px)] bg-[theme(colors.neutral.100/.1)]"
173175
></div>
174176
</template>
175177
</TransitionGroup>

src/globals.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ button[data-tooltip] {
119119

120120
/* 'global-background' transition */
121121
.global-background-enter-active {
122-
transition: transform 400ms ease;
122+
transition: opacity 150ms ease;
123123
}
124124
.global-background-leave-active {
125-
transition: transform 400ms ease;
126-
transform: translateY(-16px);
125+
transition: opacity 150ms ease;
126+
opacity: 0;
127127
}
128128

129129
.global-background-enter-from {
130-
transform: translateY(16px);
130+
opacity: 1;
131131
}
132132
.global-background-leave-to {}
133133

src/lib/global-state-helpers/scopes/get-config-global-states.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ export async function getConfigGlobalStates(
5353
"layout": {
5454
"custom" : false,
5555
"background": {
56-
"url" : "https://s126-isny.freeconvert.com/task/6914e6c5121a9b1c5c48b781/morizuki-suzumi-blue-archive.960x540.gif",
56+
"url" : undefined,
5757
"key" : undefined,
58-
"blur" : 4,
59-
"color": "rgba(0, 0, 0, 0.7)",
58+
"blur" : undefined,
59+
"color": undefined,
6060
},
6161
"sidebar": {
62-
"blur" : 12,
63-
"color" : "rgb(255, 255, 255)",
62+
"blur" : undefined,
63+
"color" : undefined,
6464
"ripple" : undefined,
6565
"sparkles" : undefined,
66-
"background": "rgba(23, 0, 0, 0.3)",
66+
"background": undefined,
6767
},
6868
},
6969
"pages": {

0 commit comments

Comments
 (0)