Преглед на файлове

Merge remote-tracking branch 'ali-origin/master'

louhangfei преди 2 години
родител
ревизия
b25d553c6e

+ 0 - 3
.env.development

@@ -7,9 +7,6 @@ VITE_PUBLIC_PATH = /
 # 是否开启mock
 VITE_USE_MOCK = true
 
-# 网站前缀
-VITE_BASE_URL = /
-
 # 是否删除console
 VITE_DROP_CONSOLE = true
 

+ 0 - 1
.env.production

@@ -4,7 +4,6 @@ VITE_USE_MOCK = true
 # 网站根目录
 VITE_PUBLIC_PATH = /
 
-
 # 是否删除console
 VITE_DROP_CONSOLE = true
 

+ 13 - 0
CHANGELOG.md

@@ -2,6 +2,19 @@
 
 ## Pending
 
+## 1.4.0 (2023-11-25)
+
+- 🌟 新增 `BasicForm.schemas` 支持 `hidden`,可配置成函数,示例:组件示例-表单-基础使用
+- 💎 优化 `useECharts` 方法,考虑菜单收起宽度变化
+- `依赖升级`
+
+## 1.3.9 (2023-07-26)
+
+- 🐞 修复 `mock` 配置异常
+- 🐞 修复 `GlobConfig` 类型缺失
+- 💎 优化 `ImportMeta` 类型定义
+- `依赖升级`
+
 ## 1.3.8 (2023-06-12)
 
 - 🐞 修复 `修改密码异常`

+ 5 - 5
mock/_util.ts

@@ -13,7 +13,7 @@ export function resultPageSuccess<T = any>(
   page: number,
   pageSize: number,
   list: T[],
-  { message = 'ok' } = {},
+  { msg = 'ok' } = {},
 ) {
   const pageData = pagination(page, pageSize, list);
 
@@ -24,15 +24,15 @@ export function resultPageSuccess<T = any>(
       pageCount: list.length,
       list: pageData,
     }),
-    message,
+    msg,
   };
 }
 
-export function resultError(message = 'Request failed', { code = -1, result = null } = {}) {
+export function resultError(msg = 'Request failed', { code = -1, data = null } = {}) {
   return {
     code,
-    result,
-    message,
+    data,
+    msg,
     type: 'error',
   };
 }

+ 4 - 2
mock/system/dictionary.ts

@@ -136,12 +136,14 @@ export default [
           return item.label.indexOf(keywords) != -1;
         });
       }
-      const count = list.length > Number(pageSize) ? Math.ceil(list.length / Number(pageSize)) : 0;
+      const count =
+        list.length > Number(pageSize) ? Math.ceil(list.length / Number(pageSize)) : list.length;
+      const itemCount = count > Number(pageSize) ? count * Number(pageSize) : count;
       return resultSuccess({
         page: Number(page),
         pageSize: Number(pageSize),
         pageCount: count,
-        itemCount: count * Number(pageSize),
+        itemCount,
         list,
       });
     },

+ 41 - 41
package.json

@@ -1,6 +1,6 @@
 {
   "name": "naive-admin-element-tenant",
-  "version": "1.3.8",
+  "version": "1.3.9",
   "author": {
     "name": "Ahjung",
     "email": "735878602@qq.com",
@@ -31,7 +31,7 @@
     "deploy": "gh-pages -d dist"
   },
   "dependencies": {
-    "@element-plus/icons-vue": "^2.0.9",
+    "@element-plus/icons-vue": "^2.1.0",
     "@vicons/antd": "^0.12.0",
     "@vicons/ionicons5": "^0.12.0",
     "@vueup/vue-quill": "1.0.0-beta.8",
@@ -40,76 +40,76 @@
     "@wangeditor/editor-for-vue": "^5.1.12",
     "axios": "^0.27.2",
     "blueimp-md5": "^2.19.0",
-    "cropperjs": "^1.5.12",
-    "dayjs": "^1.11.4",
-    "echarts": "^5.3.3",
-    "element-plus": "^2.3.6",
+    "cropperjs": "^1.6.1",
+    "dayjs": "^1.11.10",
+    "echarts": "^5.4.3",
+    "element-plus": "^2.4.2",
     "element-resize-detector": "^1.2.4",
     "lodash-es": "^4.17.21",
     "mockjs": "^1.1.0",
     "nprogress": "^0.2.0",
     "perfect-scrollbar": "^1.5.5",
-    "pinia": "^2.0.16",
+    "pinia": "^2.1.7",
     "print-js": "^1.6.0",
-    "qrcode": "^1.5.1",
-    "qs": "^6.11.0",
-    "vue": "^3.3.4",
-    "vue-router": "^4.1.2",
-    "vue-types": "^4.1.1",
+    "qrcode": "^1.5.3",
+    "qs": "^6.11.2",
+    "vue": "^3.3.8",
+    "vue-router": "^4.2.5",
+    "vue-types": "^4.2.1",
     "vuedraggable": "^4.1.0",
     "xlsx": "^0.18.5"
   },
   "devDependencies": {
-    "@commitlint/cli": "^17.0.3",
-    "@commitlint/config-conventional": "^17.0.3",
-    "@types/element-resize-detector": "^1.1.3",
+    "@commitlint/cli": "^17.8.1",
+    "@commitlint/config-conventional": "^17.8.1",
+    "@types/element-resize-detector": "^1.1.6",
     "@types/intro.js": "^3.0.2",
-    "@types/lodash-es": "^4.17.6",
+    "@types/lodash-es": "^4.17.12",
     "@types/node": "^17.0.45",
-    "@types/qrcode": "^1.4.2",
-    "@typescript-eslint/eslint-plugin": "^5.30.7",
-    "@typescript-eslint/parser": "^5.30.7",
-    "@vitejs/plugin-vue": "^2.3.3",
+    "@types/qrcode": "^1.5.5",
+    "@typescript-eslint/eslint-plugin": "^5.62.0",
+    "@typescript-eslint/parser": "^5.62.0",
+    "@vitejs/plugin-vue": "^2.3.4",
     "@vitejs/plugin-vue-jsx": "^1.3.10",
-    "@vue/compiler-sfc": "^3.3.4",
-    "autoprefixer": "^10.4.7",
+    "@vue/compiler-sfc": "^3.3.8",
+    "autoprefixer": "^10.4.16",
     "colors": "^1.4.0",
-    "commitizen": "^4.2.5",
-    "core-js": "^3.23.5",
+    "commitizen": "^4.3.0",
+    "core-js": "^3.33.3",
     "cross-env": "^7.0.3",
-    "dotenv": "^16.0.1",
-    "eslint": "^8.20.0",
-    "eslint-config-prettier": "^8.5.0",
-    "eslint-define-config": "^1.5.1",
+    "dotenv": "^16.3.1",
+    "eslint": "^8.54.0",
+    "eslint-config-prettier": "^8.10.0",
+    "eslint-define-config": "^1.24.1",
     "eslint-plugin-prettier": "^4.2.1",
     "eslint-plugin-vue": "^8.7.1",
     "esno": "^0.16.3",
     "fs-extra": "^10.1.0",
     "gh-pages": "^4.0.0",
-    "husky": "^8.0.1",
-    "lint-staged": "^13.0.3",
+    "husky": "^8.0.3",
+    "lint-staged": "^13.3.0",
     "picocolors": "^1.0.0",
-    "postcss": "^8.4.14",
-    "prettier": "^2.7.1",
+    "postcss": "^8.4.31",
+    "prettier": "^2.8.8",
     "pretty-quick": "^3.1.3",
     "rimraf": "^3.0.2",
-    "rollup-plugin-visualizer": "^5.8.3",
-    "sass": "^1.53.0",
-    "stylelint": "^14.9.1",
-    "stylelint-config-prettier": "^9.0.3",
+    "rollup-plugin-visualizer": "^5.9.3",
+    "sass": "^1.69.5",
+    "stylelint": "^14.16.1",
+    "stylelint-config-prettier": "^9.0.5",
     "stylelint-config-standard": "^25.0.0",
     "stylelint-order": "^5.0.0",
-    "stylelint-scss": "^4.3.0",
-    "tailwindcss": "^3.3.2",
+    "stylelint-scss": "^4.7.0",
+    "tailwindcss": "^3.3.5",
     "ts-node": "^10.9.1",
-    "typescript": "^4.7.4",
+    "typescript": "^4.9.5",
     "vite": "^3.2.7",
     "vite-plugin-compression": "^0.5.1",
     "vite-plugin-html": "^3.2.0",
-    "vite-plugin-mock": "^2.9.6",
+    "vite-plugin-mock": "^2.9.8",
     "vite-plugin-style-import": "^2.0.0",
     "vite-plugin-vue-setup-extend": "^0.4.0",
-    "vue-eslint-parser": "^9.0.3",
+    "vue-eslint-parser": "^9.3.2",
     "vue-tsc": "^0.35.2"
   },
   "lint-staged": {

Файловите разлики са ограничени, защото са твърде много
+ 1749 - 1549
pnpm-lock.yaml


+ 16 - 3
src/components/Form/src/BasicForm.vue

@@ -5,14 +5,14 @@
         v-bind="getCol"
         v-for="schema in getSchema"
         :key="schema.field"
-        :span="schema.hidden ? 0 : getCol.span"
+        :span="getHidden(schema) ? 0 : getCol.span"
       >
         <el-form-item
           v-bind="schema"
           :label="schema.label"
           :prop="schema.field"
           :showFeedback="schema.showFeedback"
-          v-if="!schema.hidden"
+          v-if="!getHidden(schema)"
         >
           <!--标签名右侧温馨提示-->
           <template #label v-if="schema.labelMessage">
@@ -170,7 +170,7 @@
   import type { Ref } from 'vue';
   import type { FormSchema, FormProps, FormActionType } from './types/form';
 
-  import { isArray } from '@/utils/is/index';
+  import { isArray, isBoolean, isFunction } from '@/utils/is/index';
   import { deepMerge } from '@/utils';
 
   const props = defineProps({ ...basicProps });
@@ -217,6 +217,19 @@
     };
   }
 
+  function getHidden(schema): boolean {
+    const hidden = schema.hidden;
+    const field = schema.field;
+    if (isBoolean(hidden)) return hidden;
+
+    if (isFunction(hidden)) {
+      const values = getFieldsValue();
+      const status = hidden({ schema, values, model: formModel, field });
+      return status;
+    }
+    return false;
+  }
+
   function getSpecComponentProps(schema) {
     const compProps = schema.componentProps ?? {};
     return {

+ 8 - 1
src/components/Form/src/types/form.ts

@@ -4,6 +4,13 @@ import type { CSSProperties } from 'vue';
 import type { ColProps } from 'element-plus/es/components/col/src/col';
 import type { ButtonProps } from 'element-plus/es/components/button/src/button';
 
+export interface RenderReturnParams {
+  schema: FormSchema;
+  values: Recordable;
+  model: Recordable;
+  field: string;
+}
+
 export interface componentProps {
   options?: any[];
   placeholder?: string;
@@ -29,7 +36,7 @@ export interface FormSchema {
   showFeedback?: boolean;
   showLabel?: boolean;
   requireMarkPlacement?: string;
-  hidden?: boolean;
+  hidden?: boolean | ((renderCallbackParams: RenderReturnParams) => boolean);
 }
 
 export interface FormProps {

+ 28 - 17
src/hooks/web/useECharts.ts

@@ -10,12 +10,14 @@ import { useBreakpoint } from '@/hooks/event/useBreakpoint';
 
 import echarts from '@/utils/lib/echarts';
 import { useDesignSetting } from '@/hooks/setting/useDesignSetting';
+import { useProjectSetting } from '@/hooks/setting/useProjectSetting';
 
 export function useECharts(
   elRef: Ref<HTMLDivElement>,
   theme: 'light' | 'dark' | 'default' = 'light',
 ) {
   const { getDarkTheme } = useDesignSetting();
+  const { getMenuSetting } = useProjectSetting();
 
   const getDarkMode = computed(() => {
     const appTheme = getDarkTheme.value ? 'dark' : 'light';
@@ -62,23 +64,26 @@ export function useECharts(
 
   function setOptions(options: EChartsOption, clear = true) {
     cacheOptions.value = options;
-    if (unref(elRef)?.offsetHeight === 0) {
-      useTimeoutFn(() => {
-        setOptions(unref(getOptions));
-      }, 30);
-      return;
-    }
-    nextTick(() => {
-      useTimeoutFn(() => {
-        if (!chartInstance) {
-          initCharts(getDarkMode.value as 'default');
-
-          if (!chartInstance) return;
-        }
-        clear && chartInstance?.clear();
-
-        chartInstance?.setOption(unref(getOptions));
-      }, 30);
+    return new Promise((resolve) => {
+      if (unref(elRef)?.offsetHeight === 0) {
+        useTimeoutFn(() => {
+          setOptions(unref(getOptions));
+          resolve(null);
+        }, 30);
+      }
+      nextTick(() => {
+        useTimeoutFn(() => {
+          if (!chartInstance) {
+            initCharts(getDarkMode.value as 'default');
+
+            if (!chartInstance) return;
+          }
+          clear && chartInstance?.clear();
+
+          chartInstance?.setOption(unref(getOptions));
+          resolve(null);
+        }, 30);
+      });
     });
   }
 
@@ -111,6 +116,12 @@ export function useECharts(
     return chartInstance;
   }
 
+  watch(getMenuSetting.value, (_) => {
+    useTimeoutFn(() => {
+      resizeFn();
+    }, 300);
+  });
+
   return {
     setOptions,
     resize,

+ 2 - 2
src/hooks/web/useTags.ts

@@ -1,5 +1,5 @@
 import { unref } from 'vue';
-import { useRouter } from 'vue-router';
+import { RouteLocationNormalized, useRouter } from 'vue-router';
 import type { Router } from 'vue-router';
 import { useTabsViewStore } from '@/store/modules/tabsView';
 import { useAsyncRouteStore } from '@/store/modules/asyncRoute';
@@ -23,7 +23,7 @@ export function useTabs(_router?: Router) {
   }
 
   //更新tab标题
-  async function updateTabTitle(title: string, tab?: object) {
+  async function updateTabTitle(title: string, tab?: RouteLocationNormalized) {
     const targetTab = tab || getCurrentTab();
     await tabsViewStore.setTabTitle(title, targetTab);
   }

+ 8 - 0
src/views/comp/form/basic.vue

@@ -92,8 +92,10 @@
       field: 'type',
       component: 'Select',
       label: '类型',
+      labelMessage: '选择类型会出现预约时间表单',
       componentProps: {
         placeholder: '请选择类型',
+        clearable: true,
         options: [
           {
             label: '舒适性',
@@ -133,6 +135,12 @@
           console.log(e);
         },
       },
+      // 根据 上面选择的类型,获取页面其他逻辑字段 处理显示表单
+      // 可用字段 schema, values, model, field
+      hidden: ({ model }) => {
+        return !model.type;
+      },
+      rules: [{ required: true, type: 'number', message: '请选择预约时间', trigger: ['change'] }],
     },
     {
       field: 'makeTime',

+ 0 - 1
src/views/list/basicList/index.vue

@@ -21,7 +21,6 @@
         :actionColumn="actionColumn"
         @checked-row-change="onCheckedRow"
         :scroll-x="1090"
-        :pagination="false"
       >
         <template #tableTitle>
           <el-button type="primary" @click="addTable">

+ 4 - 0
tsconfig.json

@@ -43,6 +43,10 @@
     "src/**/*.ts",
     "src/**/*.d.ts",
     "src/**/*.tsx",
+    "src/**/*.svg",
+    "src/**/*.png",
+    "src/**/*.jpg",
+    "src/**/*.gif",
     "src/**/*.vue",
     "types/**/*.d.ts",
     "types/**/*.ts",

+ 17 - 1
types/config.d.ts

@@ -63,7 +63,7 @@ export interface GlobEnvConfig {
   VITE_GLOB_API_URL: string;
   // 接口前缀
   VITE_GLOB_API_URL_PREFIX?: string;
-  // Project abbreviation
+  // 项目简称
   VITE_GLOB_APP_SHORT_NAME: string;
   // 图片上传地址
   VITE_GLOB_UPLOAD_URL?: string;
@@ -72,3 +72,19 @@ export interface GlobEnvConfig {
   //生产环境开启mock
   VITE_GLOB_PROD_MOCK: boolean;
 }
+export interface GlobConfig {
+  // 标题
+  title: string;
+  // 接口地址
+  apiUrl: string;
+  // 图片上传地址
+  uploadUrl?: string;
+  // api 接口前缀
+  urlPrefix?: string;
+  // 项目简称
+  shortName: string;
+  // 生产环境开启 mock
+  prodMock: boolean;
+  // 图片访问地址
+  imgUrl: string | undefined;
+}

+ 7 - 0
types/global.d.ts

@@ -22,6 +22,13 @@ declare global {
   //   __APP__: App<Element>;
   // }
 
+  // 此处 重新定义 ImportMeta 避免 ts 类型报错
+  // 目前框架只用到 env 和 glob
+  interface ImportMeta {
+    env: Record<string, string>;
+    glob: Record<function>;
+  }
+
   // vue
   declare type PropType<T> = VuePropType<T>;
   declare type VueNode = VNodeChild | JSX.Element;