|
@@ -1,9 +1,12 @@
|
|
|
// 获取assets静态资源
|
|
|
-const getAssetsFile = (url: string) => {
|
|
|
- return new URL(`../assets/images/${url}`, import.meta.url).href;
|
|
|
- };
|
|
|
-
|
|
|
- export default {getAssetsFile:getAssetsFile}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+const getAssetsFile = (name: string) => {
|
|
|
+ if (typeof name === 'undefined') return 'error.png'
|
|
|
+ const path = `/src/assets/images/${name}`
|
|
|
+ const modules = import.meta.globEager('/src/assets/images/*')
|
|
|
+ return modules[path]?.default
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
+export default { getAssetsFile: getAssetsFile }
|
|
|
+
|
|
|
+
|