Skip to content

Commit 10ae6f9

Browse files
committed
fix: #203 missing icons
1 parent 577772e commit 10ae6f9

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
}
9595
],
9696
"security": {
97-
"csp": "default-src 'self' style-src: 'unsafe-inline'"
97+
"csp": "default-src: 'self' style-src: 'unsafe-inline'"
9898
}
9999
}
100100
}

src/components/modals/Icons.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import TextField from '@mui/material/TextField'
77
import { imageToBase64 } from '~/utils'
88
import Modal from '~/components/Modal'
99

10-
const modules = import.meta.glob('../../../assets/*.svg', { eager: true })
11-
const urls = Object.keys(modules).map((path) => new URL(path, import.meta.url).toString())
12-
const sortedIcons = urls.sort((a, b) => (a.toUpperCase() < b.toUpperCase() ? -1 : 1))
13-
const icons = sortedIcons.map((url) => ({
14-
name: decodeURIComponent(url.split('assets/').pop()!.split('.svg').shift() as string),
15-
url,
16-
}))
10+
const modules = import.meta.glob('/assets/*.svg', { as: 'raw', eager: true })
11+
const icons = Object.entries(modules).map(([key, value]) => {
12+
const name = decodeURIComponent(key.split('assets/').pop()!.split('.svg').shift() as string)
13+
const svg = new Blob([value], { type: 'image/svg+xml' })
14+
const url = URL.createObjectURL(svg)
15+
return { name, url }
16+
})
17+
const sortedIcons = icons.sort((a, b) => (a.name.toUpperCase() < b.name.toUpperCase() ? -1 : 1))
1718

1819
type Icon = {
1920
name: string
@@ -47,7 +48,7 @@ const IconsModal = ({
4748
const { t } = useTranslation()
4849
const [, startTransition] = useTransition()
4950
const [searchTerm, setSearchTerm] = useState('')
50-
const [filteredIcons, setFilteredIcons] = useState(icons)
51+
const [filteredIcons, setFilteredIcons] = useState(sortedIcons)
5152

5253
const onInputChange = (event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => {
5354
const searchTerm = event.target.value

vite.config.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ export default defineConfig({
2626
minify: !process.env.TAURI_DEBUG ? 'esbuild' : false,
2727
// produce sourcemaps for debug builds
2828
sourcemap: !!process.env.TAURI_DEBUG,
29-
rollupOptions: {
30-
output: {
31-
entryFileNames: `assets/[name].js`,
32-
chunkFileNames: `assets/[name].js`,
33-
assetFileNames: `assets/[name].[ext]`,
34-
},
35-
},
3629
},
3730
resolve: {
3831
alias: {

0 commit comments

Comments
 (0)