chore: 恢复旧布局基线(迁移改动丢失后重建,apps/packages 布局暂存)
This commit is contained in:
1 parent
a9510235bb
commit
456fa6954b
203 files changed
+18787
-48
No files matched your search
@@ -0,0 +1,31 @@
|
||||
/** Vite-bundled driver icons — works in Tauri/web without depending on /public path. */
|
||||
const modules = import.meta.glob("../assets/databases/*.{svg,png}", {
|
||||
eager: true,
|
||||
query: "?url",
|
||||
import: "default",
|
||||
}) as Record<string, string>;
|
||||
|
||||
function fileKey(path: string): string {
|
||||
const base = path.split("/").pop() ?? path;
|
||||
return base.replace(/\.(svg|png)$/i, "").toLowerCase();
|
||||
}
|
||||
|
||||
/** id → bundled asset URL */
|
||||
export const DRIVER_ICON_URLS: Record<string, string> = {};
|
||||
for (const [path, url] of Object.entries(modules)) {
|
||||
DRIVER_ICON_URLS[fileKey(path)] = url;
|
||||
}
|
||||
|
||||
/** Resolve catalog icon path or id to a loadable URL. */
|
||||
export function resolveDriverIconUrl(id: string, icon?: string): string | undefined {
|
||||
const byId = DRIVER_ICON_URLS[id.toLowerCase()];
|
||||
if (byId) return byId;
|
||||
if (!icon) return undefined;
|
||||
const m = icon.match(/\/([^/]+)\.(svg|png)$/i);
|
||||
if (m) {
|
||||
const byFile = DRIVER_ICON_URLS[m[1].toLowerCase()];
|
||||
if (byFile) return byFile;
|
||||
}
|
||||
// last resort: absolute/public path (web dev)
|
||||
return icon;
|
||||
}
|
||||
Reference in new issue
Block a user