Jelajahi Sumber

fix: add build/plugin-isme to git for Docker build

徐滕 1 Minggu lalu
induk
melakukan
487c3f914c

+ 0 - 1
.gitignore

@@ -2,7 +2,6 @@
 # Build Tools
 
 .gradle
-/forge-admin-ui/build/
 !gradle/wrapper/gradle-wrapper.jar
 
 target/

+ 27 - 0
forge-admin-ui/build/index.js

@@ -0,0 +1,27 @@
+import path from 'node:path'
+import { globSync } from 'glob'
+import dynamicIcons from '../src/assets/icons/dynamic-icons.js'
+
+/**
+ * @usage 生成icons, 用于 unocss safelist,以支持页面动态渲染自定义图标
+ */
+export function getIcons() {
+  const feFiles = globSync('src/assets/icons/ai-icon/*.svg', { nodir: true, strict: true })
+  const feIcons = feFiles.map((filePath) => {
+    const fileName = path.basename(filePath) // 获取文件名,包括后缀
+    const fileNameWithoutExt = path.parse(fileName).name // 获取去除后缀的文件名
+    return `ai-icon:${fileNameWithoutExt}`
+  })
+
+  return [...dynamicIcons, ...feIcons]
+}
+
+/**
+ * @usage 生成.vue文件路径列表,用于添加菜单时可下拉选择对应的.vue文件路径,防止手动输入报错
+ */
+export function getPagePathes() {
+  const files = globSync('src/views/**/*.vue', {
+    ignore: ['src/views/**/components/**', 'src/views/**/api/**'],
+  })
+  return files.map(item => `/${path.normalize(item).replace(/\\/g, '/')}`)
+}

+ 17 - 0
forge-admin-ui/build/plugin-isme/icons.js

@@ -0,0 +1,17 @@
+import { getIcons } from '..'
+
+const PLUGIN_ICONS_ID = 'isme:icons'
+export function pluginIcons() {
+  return {
+    name: 'isme:icons',
+    resolveId(id) {
+      if (id === PLUGIN_ICONS_ID)
+        return `\0${PLUGIN_ICONS_ID}`
+    },
+    load(id) {
+      if (id === `\0${PLUGIN_ICONS_ID}`) {
+        return `export default ${JSON.stringify(getIcons())}`
+      }
+    },
+  }
+}

+ 2 - 0
forge-admin-ui/build/plugin-isme/index.js

@@ -0,0 +1,2 @@
+export { pluginIcons } from './icons'
+export { pluginPagePathes } from './page-pathes'

+ 17 - 0
forge-admin-ui/build/plugin-isme/page-pathes.js

@@ -0,0 +1,17 @@
+import { getPagePathes } from '..'
+
+const PLUGIN_PAGE_PATHES_ID = 'isme:page-pathes'
+export function pluginPagePathes() {
+  return {
+    name: 'isme:page-pathes',
+    resolveId(id) {
+      if (id === PLUGIN_PAGE_PATHES_ID)
+        return `\0${PLUGIN_PAGE_PATHES_ID}`
+    },
+    load(id) {
+      if (id === `\0${PLUGIN_PAGE_PATHES_ID}`) {
+        return `export default ${JSON.stringify(getPagePathes())}`
+      }
+    },
+  }
+}