Selaa lähdekoodia

升级vxeTable至4.7

tongshangming 3 kuukautta sitten
vanhempi
commit
48411dd105
6 muutettua tiedostoa jossa 482 lisäystä ja 339 poistoa
  1. 31 28
      package.json
  2. 341 222
      pnpm-lock.yaml
  3. 93 0
      src/components/VxeTable.ts
  4. 3 86
      src/main.ts
  5. 2 2
      src/utils/request.ts
  6. 12 1
      vite.config.ts

+ 31 - 28
package.json

@@ -1,6 +1,6 @@
 {
   "name": "fs-admin",
-  "version": "2.4.1",
+  "version": "2.4.4",
   "type": "module",
   "scripts": {
     "dev": "vite --host",
@@ -16,56 +16,59 @@
   "dependencies": {
     "@amap/amap-jsapi-loader": "^1.0.1",
     "@element-plus/icons-vue": "^2.3.1",
-    "@fskj-admin/core": "^1.3.11",
+    "@fskj-admin/core": "^1.4.1",
     "@fskj-admin/micro": "^0.1.0",
     "@icon-park/vue-next": "^1.4.2",
-    "@sentry/vue": "^8.9.2",
-    "@vueuse/core": "^10.11.0",
+    "@sentry/vue": "^8.26.0",
+    "@vueuse/core": "^10.11.1",
+    "@vxe-ui/plugin-render-element": "^4.0.5",
     "@wangeditor/editor": "^5.1.23",
     "@wangeditor/editor-for-vue": "^5.1.12",
-    "axios": "^1.7.2",
-    "dayjs": "^1.11.11",
-    "element-plus": "^2.7.6",
+    "axios": "^1.7.4",
+    "dayjs": "^1.11.12",
+    "element-plus": "^2.8.0",
     "exceljs": "^4.4.0",
     "nprogress": "^0.2.0",
-    "pinia": "^2.1.7",
+    "pinia": "^2.2.1",
     "splitpanes": "^3.1.5",
-    "vue": "^3.4.29",
-    "vue-cropper": "^1.1.3",
-    "vue-router": "^4.3.3",
-    "vxe-table": "~4.6.17",
+    "vue": "^3.4.38",
+    "vue-cropper": "^1.1.4",
+    "vue-router": "^4.4.3",
+    "vxe-pc-ui": "^4.0.95",
+    "vxe-table": "^4.7.65",
     "wujie-vue3": "^1.0.22",
-    "xe-utils": "^3.5.27"
+    "xe-utils": "^3.5.30"
   },
   "devDependencies": {
-    "@iconify-json/ep": "^1.1.15",
-    "@rushstack/eslint-patch": "^1.10.3",
-    "@sentry/vite-plugin": "^2.18.0",
+    "@iconify-json/ep": "^1.1.16",
+    "@rushstack/eslint-patch": "^1.10.4",
+    "@sentry/vite-plugin": "^2.22.2",
     "@tsconfig/node20": "^20.1.4",
-    "@types/node": "^20.14.5",
+    "@types/node": "^20.14.15",
     "@types/nprogress": "^0.2.3",
     "@types/qs": "^6.9.15",
-    "@vitejs/plugin-vue": "^5.0.5",
+    "@vitejs/plugin-vue": "^5.1.2",
     "@vitejs/plugin-vue-jsx": "^3.1.0",
     "@vue/eslint-config-prettier": "^9.0.0",
     "@vue/eslint-config-typescript": "^12.0.0",
     "@vue/tsconfig": "^0.5.1",
     "eslint": "^8.57.0",
-    "eslint-plugin-vue": "^9.26.0",
+    "eslint-plugin-vue": "^9.27.0",
     "npm-run-all": "^4.1.5",
     "plop": "^4.0.1",
-    "prettier": "^3.3.2",
-    "sass": "^1.77.6",
+    "prettier": "^3.3.3",
+    "sass": "^1.77.8",
     "typescript": "~5.3.3",
-    "unocss": "^0.61.0",
-    "unplugin-auto-import": "^0.17.6",
-    "unplugin-icons": "^0.19.0",
+    "unocss": "^0.61.9",
+    "unplugin-auto-import": "^0.17.8",
+    "unplugin-icons": "^0.19.2",
     "unplugin-vue-components": "^0.26.0",
-    "unplugin-vue-define-options": "^1.4.5",
-    "vite": "^5.3.1",
+    "unplugin-vue-define-options": "^1.4.9",
+    "vite": "^5.4.0",
+    "vite-plugin-lazy-import": "^1.0.7",
     "vite-plugin-style-import": "^2.0.0",
     "vite-plugin-svg-icons": "^2.0.1",
-    "vite-plugin-vue-devtools": "^7.3.1",
-    "vue-tsc": "^2.0.21"
+    "vite-plugin-vue-devtools": "^7.3.8",
+    "vue-tsc": "^2.0.29"
   }
 }

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 341 - 222
pnpm-lock.yaml


+ 93 - 0
src/components/VxeTable.ts

@@ -0,0 +1,93 @@
+import type { App } from 'vue'
+import 'xe-utils'
+import {
+  VxeIcon,
+  VxeLoading,
+  // VxeGrid,
+  VxeTooltip,
+  // VxeToolbar,
+  // VxePager,
+  // VxeForm,
+  // VxeFormItem,
+  // VxeFormGather,
+  // VxeCheckbox,
+  // VxeCheckboxGroup,
+  // VxeRadio,
+  // VxeRadioGroup,
+  // VxeRadioButton,
+  // VxeSwitch,
+  // VxeInput,
+  // VxeSelect,
+  // VxeOptgroup,
+  // VxeOption,
+  // VxeTextarea,
+  VxeButton,
+  // VxeButtonGroup,
+  VxeModal
+  // VxeDrawer,
+  // VxeList,
+  // VxePulldown
+} from 'vxe-pc-ui'
+import {
+  VxeUI,
+  VXETable,
+  VxeTable,
+  VxeColumn,
+  VxeColgroup,
+  // VxeGrid,
+  VxeToolbar
+} from 'vxe-table'
+import VxeUIPluginRenderElement from '@vxe-ui/plugin-render-element'
+import '@vxe-ui/plugin-render-element/dist/style.css'
+import 'vxe-table/styles/cssvar.scss'
+import 'vxe-pc-ui/styles/cssvar.scss'
+
+// 导入默认的语言
+import zhCN from 'vxe-pc-ui/lib/language/zh-CN'
+import '@/utils/tableFormat'
+
+VXETable.setI18n('zh-CN', zhCN)
+VXETable.setLanguage('zh-CN')
+VxeUI.use(VxeUIPluginRenderElement)
+
+function LazyVxeUI(app: any) {
+  app.use(VxeIcon)
+  app.use(VxeLoading)
+  // app.use(VxeVxeGrid)
+  app.use(VxeTooltip)
+  // app.use(VxeToolbar)
+  // app.use(VxePager)
+  // app.use(VxeForm)
+  // app.use(VxeFormItem)
+  // app.use(VxeFormGather)
+  // app.use(VxeCheckbox)
+  // app.use(VxeCheckboxGroup)
+  // app.use(VxeRadio)
+  // app.use(VxeRadioGroup)
+  // app.use(VxeRadioButton)
+  // app.use(VxeSwitch)
+  // app.use(VxeInput)
+  // app.use(VxeSelect)
+  // app.use(VxeOptgroup)
+  // app.use(VxeOption)
+  // app.use(VxeTextarea)
+  app.use(VxeButton)
+  // app.use(VxeButtonGroup)
+  app.use(VxeModal)
+  // app.use(VxeDrawer)
+  // app.use(VxeList)
+  // app.use(VxePulldown)
+}
+function LazyVxeTable(app: any) {
+  app.use(VxeTable)
+  app.use(VxeColumn)
+  app.use(VxeColgroup)
+  // app.use(VxeGrid)
+  app.use(VxeToolbar)
+}
+function registerVxeTable(app: App): void {
+  app.use(LazyVxeUI)
+  app.use(LazyVxeTable)
+}
+
+export default registerVxeTable

+ 3 - 86
src/main.ts

@@ -10,51 +10,9 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue'
 // import { install } from '@icon-park/vue-next/es/all'
 
 import registerComponent from '@/components/index'
+import registerVxeTable from '@/components/VxeTable'
 import directives from '@/directive'
 
-import 'xe-utils'
-import {
-  // VXETable,
-  Filter,
-  Edit,
-  Menu,
-  Export,
-  Keyboard,
-  Validator,
-
-  // 可选组件
-  Icon,
-  Column,
-  Colgroup,
-  // Grid,
-  Tooltip,
-  Toolbar,
-  Pager,
-  // Form,
-  // FormItem,
-  // FormGather,
-  Checkbox,
-  CheckboxGroup,
-  Radio,
-  RadioGroup,
-  RadioButton,
-  Switch,
-  Input,
-  Select,
-  Optgroup,
-  Option,
-  // Textarea,
-  Button,
-  Modal,
-  // List,
-  // Pulldown,
-
-  // 表格
-  Table
-} from 'vxe-table'
-import 'vxe-table/styles/cssvar.scss'
-import '@/utils/tableFormat'
-
 import FsAdminCore from '@fskj-admin/core'
 import '@fskj-admin/core/lib/style.css'
 import uploadConfig from './config/uploadConfig'
@@ -67,60 +25,19 @@ import 'virtual:svg-icons-register'
 
 // import WujieVue from 'wujie-vue3'
 
-function useTable(app: any) {
-  // 表格功能
-  app.use(Filter).use(Edit).use(Menu).use(Export).use(Keyboard).use(Validator)
-
-  // 可选组件
-  app
-    .use(Icon)
-    .use(Column)
-    .use(Colgroup)
-    // .use(Grid)
-    .use(Tooltip)
-    .use(Toolbar)
-    .use(Pager)
-    // .use(Form)
-    // .use(FormItem)
-    // .use(FormGather)
-    .use(Checkbox)
-    .use(CheckboxGroup)
-    .use(Radio)
-    .use(RadioGroup)
-    .use(RadioButton)
-    .use(Switch)
-    .use(Input)
-    .use(Select)
-    .use(Optgroup)
-    .use(Option)
-    // .use(Textarea)
-    .use(Button)
-    .use(Modal)
-    // .use(List)
-    // .use(Pulldown)
-
-    // 安装表格
-    .use(Table)
-
-  // 给 vue 实例挂载内部对象,例如:
-  // app.config.globalProperties.$XModal = VXETable.modal
-  // app.config.globalProperties.$XPrint = VXETable.print
-  // app.config.globalProperties.$XSaveFile = VXETable.saveFile
-  // app.config.globalProperties.$XReadFile = VXETable.readFile
-}
-
 const app = createApp(App)
 
 app.use(createPinia())
 app.use(router)
 app.use(ElementPlus)
-app.use(useTable)
+
 app.use(FsAdminCore, {
   upload: uploadConfig
 })
 // app.use(WujieVue)
 app.use(directives)
 registerComponent(app)
+registerVxeTable(app)
 
 for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
   app.component(key, component)

+ 2 - 2
src/utils/request.ts

@@ -11,8 +11,8 @@ const request = axios.create({
 
 // 异常拦截处理器
 const errorHandler = (error: any) => {
-  const status = error.response.status
-  const data = error.response.data
+  const status = error.response?.status
+  const data = error.response?.data
 
   if (status === 400) {
     ElMessage.error(data.msg)

+ 12 - 1
vite.config.ts

@@ -11,6 +11,7 @@ import { createStyleImportPlugin, VxeTableResolve } from 'vite-plugin-style-impo
 import Unocss from 'unocss/vite'
 import VueDevTools from 'vite-plugin-vue-devtools'
 import { sentryVitePlugin } from '@sentry/vite-plugin'
+import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import'
 
 export default defineConfig(({ mode }) => {
   const env = loadEnv(mode, process.cwd(), '')
@@ -51,7 +52,17 @@ export default defineConfig(({ mode }) => {
               ignore: ['node_modules']
             }
           })
-        : null
+        : null,
+      lazyImport({
+        resolvers: [
+          VxeResolver({
+            libraryName: 'vxe-table'
+          }),
+          VxeResolver({
+            libraryName: 'vxe-pc-ui'
+          })
+        ]
+      })
     ],
     resolve: {
       alias: {

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä