NewLife/NewLife.CubeVue

修改项目设置,准备发包
笑笑 authored at 2023-03-17 18:26:54
1799c18
Tree
1 Parent(s) 2623360
Summary: 7 changed files with 57 additions and 46 deletions.
Modified +6 -5
Modified +21 -6
Modified +17 -22
Modified +2 -0
Modified +2 -1
Modified +6 -7
Modified +3 -5
Modified +6 -5
diff --git a/package.json b/package.json
index a2dd0dd..e6e1446 100644
--- a/package.json
+++ b/package.json
@@ -1,18 +1,19 @@
 {
   "name": "@newlifex/cube-ui",
-  "version": "0.1.0",
+  "version": "0.2.0",
   "description": "NewLife.Cube New UI",
   "scripts": {
-    "start": "vite --help",
+    "start": "vue-tsc --help",
     "serve": "vite",
-    "build": "vue-tsc --noEmit && vite build --outDir ./demo/lib --emptyOutDir",
+    "build": "vue-tsc --declaration --emitDeclarationOnly --outDir ./dist/types  && vite build --outDir ./dist --emptyOutDir=false",
     "lib": "vue-cli-service build --no-clean --target lib --dest ./demo/lib --name CubeUI ./src/index.ts",
     "publish": "yarn lib && npm publish --access public --registry=https://registry.npmjs.com/"
   },
   "files": [
-    "lib/*.js",
-    "lib/*.css"
+    "dist"
   ],
+  "main": "dist/CubeUI.js",
+  "types": "dist/types/index.d.ts",
   "dependencies": {
     "@ant-design-vue/pro-layout": "^3.2.3",
     "@ant-design/icons-vue": "^6.1.0",
Modified +21 -6
diff --git a/src/components/FormControl.vue b/src/components/FormControl.vue
index 5d8dc3e..d4de0ac 100644
--- a/src/components/FormControl.vue
+++ b/src/components/FormControl.vue
@@ -89,8 +89,8 @@
       active-color="#13ce66"
       inactive-color="#ff4949"
       :disabled="
-      options.disabled === 'true' || options.disabled === true ? true : false
-    "
+        options.disabled === 'true' || options.disabled === true ? true : false
+      "
     />
   </template>
 
@@ -114,7 +114,22 @@
 </template>
 
 <script lang="ts">
-import { defineComponent, PropType } from 'vue';
+interface FieldConfig {
+  displayName: string;
+  name: string;
+  width: string;
+  itemType: string;
+  dataType: string;
+  options: any;
+  url: string | Array<any>;
+  showInList: boolean;
+  showInSearch: boolean;
+  showInDetail: boolean;
+  data: any;
+}
+
+import type { PropType } from 'vue';
+import { defineComponent } from 'vue';
 // import CustomSelect from './CustomSelect.vue'
 export default defineComponent({
   name: 'FormControl',
@@ -124,7 +139,7 @@ export default defineComponent({
     modelValue: [Object],
     // 字段配置
     configs: {
-      type: Object,
+      type: Object as PropType<FieldConfig>,
       default: {},
     },
   },
@@ -488,7 +503,7 @@ export default defineComponent({
     // 获取远程数据
     getRemoteData(query = '') {
       const vm = this;
-      const url = vm.configs.url;
+      const url = vm.configs.url as string;
       const method = vm.options.method || 'post';
       const keyField = vm.options.keyField || 'txtKeywords';
 
@@ -528,7 +543,7 @@ export default defineComponent({
     // 解析url中的数据
     getLocalData() {
       const vm = this;
-      const data = JSON.parse(vm.configs.url);
+      const data = JSON.parse(vm.configs.url as string);
       vm.dataList = data;
     },
     getValueByDataType(data: any, option: any) {
Modified +17 -22
diff --git a/src/index.ts b/src/index.ts
index 5915b19..33f2429 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -11,8 +11,12 @@ import { fileContext } from './services/file-context';
 import { createStore } from './store';
 import { getMenu } from './utils/menu';
 
-let elementUI: any;
-let elementIcons: any;
+// const files = require.context('@/', true, /^.*\.(vue|tsx)$/);
+// tslint:disable-next-line:whitespace
+const files = import.meta.glob('@/**/*.(vue|tsx)', { eager: true });
+
+// 注入视图文件
+fileContext.addFiles(files);
 
 const install: any = (app: any) => {
   if (install.installed) {
@@ -20,13 +24,6 @@ const install: any = (app: any) => {
   }
   install.installed = true;
 
-  // const files = require.context('@/', true, /^.*\.(vue|tsx)$/);
-  // tslint:disable-next-line:whitespace
-  const files = import.meta.glob('@/**/*.(vue|tsx)', { eager: true });
-
-  // 注入视图文件
-  fileContext.addFiles(files);
-
   app.component('LayoutDefault', LayoutDefault);
   app.component('LayoutAntdv', LayoutAntdv);
   app.component('Navbar', Navbar);
@@ -53,8 +50,8 @@ const install: any = (app: any) => {
   // 创建api,公用接口,注入$api
   createApi(app, axios);
 
-  store.dispatch('setMessage', elementUI.ElMessage);
-  store.dispatch('setMessageBox', elementUI.ElMessageBox);
+  store.dispatch('setMessage', Element.ElMessage);
+  store.dispatch('setMessageBox', Element.ElMessageBox);
 
   // 尝试从本地缓存加载菜单
   const accessedRouters = getMenu();
@@ -75,18 +72,18 @@ const install: any = (app: any) => {
     options.routes = menuRouters.concat(options.routes);
   });
 
-  app.use(elementUI, { size: store.state.app.size });
-  for (const key in elementIcons) {
-    if (Object.prototype.hasOwnProperty.call(elementIcons, key)) {
-      const e = elementIcons[key];
+  app.use(Element, { size: store.state.app.size });
+  for (const key in ElementIcons) {
+    if (Object.prototype.hasOwnProperty.call(ElementIcons, key)) {
+      const e = (ElementIcons as any)[key];
       app.component(e.name, e);
     }
   }
 
-  app.config.globalProperties.$message = elementUI.ElMessage;
-  app.config.globalProperties.$messageBox = elementUI.ElMessageBox;
+  app.config.globalProperties.$message = Element.ElMessage;
+  app.config.globalProperties.$messageBox = Element.ElMessageBox;
   app.config.globalProperties.$warn = (config: any) => {
-    elementUI.ElMessage.warning(config);
+    Element.ElMessage.warning(config);
   };
 
   // 注入的计算属性自动解包
@@ -94,9 +91,6 @@ const install: any = (app: any) => {
 };
 
 export const createCubeUI = () => {
-  elementUI = Element;
-  elementIcons = ElementIcons;
-
   return {
     install,
   };
@@ -106,7 +100,8 @@ export default {
   install,
 };
 
-export * from '@/components/index';
+export * from './components/index';
 export * from './services/file-context';
 export * from './utils';
+export { LayoutDefault, LayoutAntdv, Navbar, Sidebar, AppMain };
 export { createStore, createRouter, createAxios, createApi };
Modified +2 -0
diff --git a/src/layouts/default/components/navbar.vue b/src/layouts/default/components/navbar.vue
index b0fb205..4777f1f 100644
--- a/src/layouts/default/components/navbar.vue
+++ b/src/layouts/default/components/navbar.vue
@@ -65,12 +65,14 @@
 </template>
 
 <script lang="ts">
+import { ElDropdown } from 'element-plus';
 import { defineComponent } from 'vue';
 import Hamburger from './hamburger.vue';
 
 export default defineComponent({
   components: {
     Hamburger,
+    ElDropdown,
     // Screenfull,
     // SizeSelect,
     // ThemePicker,
Modified +2 -1
diff --git a/src/layouts/default/components/sidebar/index.vue b/src/layouts/default/components/sidebar/index.vue
index 920f37f..b6cbe68 100644
--- a/src/layouts/default/components/sidebar/index.vue
+++ b/src/layouts/default/components/sidebar/index.vue
@@ -24,12 +24,13 @@
 
 <script lang="ts">
 import { getMenu } from '@/utils/menu';
+import { ElMenu, ElScrollbar } from 'element-plus';
 import { defineComponent } from 'vue';
 import SidebarItem from './SidebarItem.vue';
 
 export default defineComponent({
   name: 'Sidebar',
-  components: { SidebarItem },
+  components: { SidebarItem, ElScrollbar, ElMenu },
   computed: {
     menuRouters(): any {
       const vm = this;
Modified +6 -7
diff --git a/src/store/index.ts b/src/store/index.ts
index d685d8a..a819533 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -1,10 +1,9 @@
+import { createStore as create, Store, StoreOptions } from 'vuex';
+import getters from './getters';
+import moduleApp from './modules/app';
+import entity from './modules/entity';
 import route from './modules/route';
 import user from './modules/user';
-import entity from './modules/entity';
-import moduleApp from './modules/app';
-import getters from './getters';
-import { createStore as create, Store, StoreOptions } from 'vuex';
-import { App } from 'vue';
 
 interface S {
   app: typeof moduleApp.state;
@@ -27,8 +26,8 @@ export const storeOptions: StoreOptions<S> = {
 };
 
 export const createStore = (
-  app: App<Element>,
-  configure: ((options: StoreOptions<S>) => void) | undefined | null = null,
+  app: any,
+  configure: ((options: StoreOptions<S>) => void) | undefined = undefined,
 ): Store<S> => {
   if (configure) {
     configure(storeOptions);
Modified +3 -5
diff --git a/tsconfig.json b/tsconfig.json
index b843830..d673cb0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -11,8 +11,6 @@
     "resolveJsonModule": true,
     "isolatedModules": true,
     "esModuleInterop": true,
-    "declaration": true,
-    "emitDeclarationOnly": true,
     "lib": [
       "ESNext",
       "DOM"
@@ -21,12 +19,12 @@
     "types": [
       "vite/client"
     ],
+    "baseUrl": ".",
     "paths": {
       "@/*": [
-        "./src/*"
-      ]
+        "src/*"
+      ],
     },
-    "outDir": "dist"
   },
   "include": [
     "src/**/*.ts",