Преглед изворни кода

feat(架构): 添加模块支持

shizhongming пре 2 година
родитељ
комит
1b5f86751e

+ 4 - 0
modules/smart-ui-app/.eslintrc.cjs

@@ -0,0 +1,4 @@
+module.exports = {
+  root: true,
+  extends: ['@vben/eslint-config/strict'],
+};

+ 10 - 0
modules/smart-ui-app/build.config.ts

@@ -0,0 +1,10 @@
+import { defineBuildConfig } from 'unbuild';
+
+export default defineBuildConfig({
+  clean: true,
+  entries: ['src/index'],
+  declaration: true,
+  rollup: {
+    emitCJS: true,
+  },
+});

+ 40 - 0
modules/smart-ui-app/package.json

@@ -0,0 +1,40 @@
+{
+  "name": "@smart/smart-ui-app",
+  "version": "1.0.0",
+  "homepage": "https://github.com/vbenjs/vue-vben-admin",
+  "bugs": {
+    "url": "https://github.com/vbenjs/vue-vben-admin/issues"
+  },
+  "repository": {
+    "type": "git",
+    "url": "git+https://github.com/vbenjs/vue-vben-admin.git",
+    "directory": "packages/hooks"
+  },
+  "license": "MIT",
+  "sideEffects": false,
+  "type": "module",
+  "exports": {
+    ".": {
+      "default": "./src/index.ts"
+    }
+  },
+  "main": "./src/index.ts",
+  "module": "./src/index.ts",
+  "files": [
+    "dist"
+  ],
+  "scripts": {
+    "//build": "pnpm unbuild",
+    "//stub": "pnpm unbuild --stub",
+    "clean": "pnpm rimraf .turbo node_modules dist",
+    "lint": "pnpm eslint ."
+  },
+  "dependencies": {
+    "@vueuse/core": "^10.7.1",
+    "lodash-es": "^4.17.21",
+    "vue": "3.3.4"
+  },
+  "devDependencies": {
+    "@vben/types": "workspace:*"
+  }
+}

+ 1 - 0
modules/smart-ui-app/src/index.ts

@@ -0,0 +1 @@
+export * from './init';

+ 6 - 0
modules/smart-ui-app/src/init.ts

@@ -0,0 +1,6 @@
+import { SmartUiInitParams } from '@vben/types';
+
+export const init = (params: SmartUiInitParams) => {
+  console.log(params);
+  console.log('初始化');
+};

+ 5 - 0
modules/smart-ui-app/tsconfig.json

@@ -0,0 +1,5 @@
+{
+  "$schema": "https://json.schemastore.org/tsconfig",
+  "extends": "@vben/ts-config/vue-app.json",
+  "include": ["src"]
+}

+ 1 - 0
package.json

@@ -72,6 +72,7 @@
     "@iconify/iconify": "^3.1.1",
     "@logicflow/core": "^1.2.18",
     "@logicflow/extension": "^1.2.19",
+    "@smart/smart-ui-app": "workspace:*",
     "@vben/hooks": "workspace:*",
     "@vue/shared": "^3.4.5",
     "@vueuse/core": "^10.7.1",

+ 6 - 0
packages/types/src/utils.ts

@@ -1,3 +1,5 @@
+import { App } from 'vue';
+
 /**
  * 任意类型的异步函数
  */
@@ -56,3 +58,7 @@ export {
   type Recordable,
   type TimeoutHandle,
 };
+
+export interface SmartUiInitParams {
+  app: App<Element>;
+}

+ 21 - 2
pnpm-lock.yaml

@@ -20,6 +20,9 @@ importers:
       '@logicflow/extension':
         specifier: ^1.2.19
         version: 1.2.19
+      '@smart/smart-ui-app':
+        specifier: workspace:*
+        version: link:modules/smart-ui-app
       '@vben/hooks':
         specifier: workspace:*
         version: link:packages/hooks
@@ -450,6 +453,22 @@ importers:
         specifier: ^2.0.1
         version: 2.0.1(vite@5.0.10)
 
+  modules/smart-ui-app:
+    dependencies:
+      '@vueuse/core':
+        specifier: ^10.7.1
+        version: 10.7.1(vue@3.3.4)
+      lodash-es:
+        specifier: ^4.17.21
+        version: 4.17.21
+      vue:
+        specifier: 3.3.4
+        version: 3.3.4
+    devDependencies:
+      '@vben/types':
+        specifier: workspace:*
+        version: link:../../packages/types
+
   packages/hooks:
     dependencies:
       '@vueuse/core':
@@ -2519,7 +2538,7 @@ packages:
     dev: true
 
   /@types/web-bluetooth@0.0.20:
-    resolution: {integrity: sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==}
+    resolution: {integrity: sha512-g9gZnnXVq7gM7v3tJCWV/qw7w+KeOlSHAhgF9RytFyifW6AF61hdT2ucrYhPq9hLs5JIryeupHV3qGk95dH9ow==, tarball: https://registry.npmmirror.com/@types/web-bluetooth/-/web-bluetooth-0.0.20.tgz}
     dev: false
 
   /@types/yargs-parser@21.0.3:
@@ -11994,7 +12013,7 @@ packages:
     dev: true
 
   /vue-demi@0.14.6(vue@3.3.4):
-    resolution: {integrity: sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==}
+    resolution: {integrity: sha512-8QA7wrYSHKaYgUxDA5ZC24w+eHm3sYCbp0EzcDwKqN3p6HqtTCGR/GVsPyZW92unff4UlcSh++lmqDWN3ZIq4w==, tarball: https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.6.tgz}
     engines: {node: '>=12'}
     hasBin: true
     requiresBuild: true

+ 1 - 0
pnpm-workspace.yaml

@@ -2,3 +2,4 @@ packages:
   - 'internal/*'
   - 'packages/*'
   - 'apps/*'
+  - 'modules/*'

+ 3 - 0
src/main.ts

@@ -18,6 +18,8 @@ import { setupStore } from '@/store';
 
 import App from './App.vue';
 
+import { init } from '@smart/smart-ui-app';
+
 async function bootstrap() {
   const app = createApp(App);
 
@@ -58,6 +60,7 @@ async function bootstrap() {
   // https://next.router.vuejs.org/api/#isready
   // await router.isReady();
 
+  init({ app });
   app.mount('#app');
 }
 

+ 1 - 1
vite.config.ts

@@ -19,7 +19,7 @@ export default defineApplicationConfig({
     server: {
       proxy: {
         '/basic-api': {
-          target: 'http://localhost:9095',
+          target: 'http://localhost:8080',
           changeOrigin: true,
           ws: true,
           rewrite: (path) => path.replace(new RegExp(`^/basic-api`), ''),