zyf-model-engine 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/.editorconfig +15 -0
  2. package/.env +13 -0
  3. package/.env.development +20 -0
  4. package/.env.production +25 -0
  5. package/.env.test +25 -0
  6. package/.eslintignore +15 -0
  7. package/.eslintrc-auto-import.json +65 -0
  8. package/.eslintrc.cjs +66 -0
  9. package/.husky/commit-msg +4 -0
  10. package/.husky/pre-commit +5 -0
  11. package/.prettierignore +9 -0
  12. package/.prettierrc.cjs +41 -0
  13. package/.stylelintignore +4 -0
  14. package/.stylelintrc.cjs +40 -0
  15. package/.vscode/extensions.json +14 -0
  16. package/.vscode/settings.json +92 -0
  17. package/CHANGELOG.md +246 -0
  18. package/LICENSE +21 -0
  19. package/README.md +205 -0
  20. package/auto-imports.d.ts +132 -0
  21. package/build/getEnv.ts +46 -0
  22. package/build/plugins.ts +138 -0
  23. package/build/proxy.ts +28 -0
  24. package/commitlint.config.cjs +84 -0
  25. package/components.d.ts +28 -0
  26. package/index.html +105 -0
  27. package/lint-staged.config.cjs +8 -0
  28. package/package.json +108 -0
  29. package/postcss.config.cjs +5 -0
  30. package/public/logo.png +0 -0
  31. package/src/App.vue +16 -0
  32. package/src/api/config/servicePort.ts +3 -0
  33. package/src/api/enums/httpEnum.ts +35 -0
  34. package/src/api/helper/axiosCancel.ts +50 -0
  35. package/src/api/helper/axiosFileCancel.ts +62 -0
  36. package/src/api/helper/checkStatus.ts +97 -0
  37. package/src/api/index.ts +142 -0
  38. package/src/api/interface/index.ts +27 -0
  39. package/src/assets/global-icons/icon-demo.svg +1 -0
  40. package/src/assets/iconfont/iconfont.scss +44 -0
  41. package/src/assets/iconfont/iconfont.ttf +0 -0
  42. package/src/assets/images/empty-img.png +0 -0
  43. package/src/assets/option-icons/add.svg +1 -0
  44. package/src/assets/option-icons/check.svg +1 -0
  45. package/src/assets/option-icons/config.svg +1 -0
  46. package/src/assets/option-icons/del.svg +1 -0
  47. package/src/assets/option-icons/detail.svg +1 -0
  48. package/src/assets/option-icons/edit.svg +2 -0
  49. package/src/assets/option-icons/export.svg +1 -0
  50. package/src/assets/option-icons/folder.svg +1 -0
  51. package/src/assets/option-icons/full-screen.svg +1 -0
  52. package/src/assets/option-icons/more.svg +1 -0
  53. package/src/assets/option-icons/return.svg +1 -0
  54. package/src/assets/option-icons/search.svg +1 -0
  55. package/src/components/CSvgIcon/index.scss +23 -0
  56. package/src/components/CSvgIcon/index.vue +74 -0
  57. package/src/components/CTree/index.scss +48 -0
  58. package/src/components/CTree/index.vue +176 -0
  59. package/src/components/CTree/interface/index.ts +6 -0
  60. package/src/components/Dialog/index.scss +74 -0
  61. package/src/components/Dialog/index.vue +87 -0
  62. package/src/components/Empty/index.scss +16 -0
  63. package/src/components/Empty/index.vue +43 -0
  64. package/src/components/Grid/components/GridItem.vue +68 -0
  65. package/src/components/Grid/index.vue +167 -0
  66. package/src/components/Grid/interface/index.ts +6 -0
  67. package/src/components/Loading/index.scss +67 -0
  68. package/src/components/Loading/index.vue +13 -0
  69. package/src/components/Overflow/index.vue +76 -0
  70. package/src/components/ProTable/components/ColSetting.vue +45 -0
  71. package/src/components/ProTable/components/Pagination.vue +29 -0
  72. package/src/components/ProTable/components/SearchForm/components/SearchFormItem.vue +93 -0
  73. package/src/components/ProTable/components/SearchForm/index.scss +12 -0
  74. package/src/components/ProTable/components/SearchForm/index.vue +91 -0
  75. package/src/components/ProTable/components/TableColumn.vue +56 -0
  76. package/src/components/ProTable/index.scss +14 -0
  77. package/src/components/ProTable/index.vue +274 -0
  78. package/src/components/ProTable/interface/index.ts +86 -0
  79. package/src/components/ScrollBox/index.vue +44 -0
  80. package/src/components/SvgIcon/index.vue +20 -0
  81. package/src/components/Tabs/index.vue +142 -0
  82. package/src/config/index.ts +12 -0
  83. package/src/config/nprogress.ts +12 -0
  84. package/src/config/piniaPersist.ts +19 -0
  85. package/src/config/serviceLoading.ts +45 -0
  86. package/src/enums/httpEnum.ts +24 -0
  87. package/src/hooks/interface/index.ts +32 -0
  88. package/src/hooks/useOnline.ts +27 -0
  89. package/src/hooks/useTable.ts +167 -0
  90. package/src/main.ts +35 -0
  91. package/src/plugins/button/button.vue +56 -0
  92. package/src/plugins/index.js +26 -0
  93. package/src/plugins/index.vue +24 -0
  94. package/src/plugins/msg/msg.vue +56 -0
  95. package/src/stores/commonStore.ts +9 -0
  96. package/src/stores/index.ts +8 -0
  97. package/src/stores/interface/index.ts +1 -0
  98. package/src/styles/common.scss +87 -0
  99. package/src/styles/element.scss +233 -0
  100. package/src/styles/reset.scss +20 -0
  101. package/src/styles/var.scss +2 -0
  102. package/src/typings/global.d.ts +37 -0
  103. package/src/typings/window.d.ts +8 -0
  104. package/src/utils/color.ts +59 -0
  105. package/src/utils/commonUtils.ts +175 -0
  106. package/src/utils/errorHandler.ts +28 -0
  107. package/src/utils/is.ts +147 -0
  108. package/src/utils/layoutUtils.ts +83 -0
  109. package/src/utils/localUtils.ts +42 -0
  110. package/src/utils/serviceDict.ts +9 -0
  111. package/src/vite-env.d.ts +6 -0
  112. package/tsconfig.json +50 -0
  113. package/vite.config.ts +76 -0
@@ -0,0 +1,83 @@
1
+ import { isArray } from "@/utils/is";
2
+ import { FieldNamesProps } from "@/components/ProTable/interface";
3
+
4
+ /**
5
+ * @description 格式化表格单元格默认值 (el-table-column)
6
+ * @param {Number} row 行
7
+ * @param {Number} col 列
8
+ * @param {*} callValue 当前单元格值
9
+ * @returns {String}
10
+ * */
11
+ export function formatTableColumn(row: number, col: number, callValue: any) {
12
+ // 如果当前值为数组,使用 / 拼接(根据需求自定义)
13
+ if (isArray(callValue)) return callValue.length ? callValue.join(" / ") : "--";
14
+ return callValue ?? "--";
15
+ }
16
+
17
+ /**
18
+ * @description 处理值无数据情况
19
+ * @param {*} callValue 需要处理的值
20
+ * @returns {String}
21
+ * */
22
+ export function formatValue(callValue: any) {
23
+ // 如果当前值为数组,使用 / 拼接(根据需求自定义)
24
+ if (isArray(callValue)) return callValue.length ? callValue.join(" / ") : "--";
25
+ return callValue ?? "--";
26
+ }
27
+
28
+ /**
29
+ * @description 处理 prop 为多级嵌套的情况,返回的数据 (列如: prop: user.name)
30
+ * @param {Object} row 当前行数据
31
+ * @param {String} prop 当前 prop
32
+ * @returns {*}
33
+ * */
34
+ export function handleRowAccordingToProp(row: { [key: string]: any }, prop: string) {
35
+ if (!prop.includes(".")) return row[prop] ?? "--";
36
+ prop.split(".").forEach(item => (row = row[item] ?? "--"));
37
+ return row;
38
+ }
39
+
40
+ /**
41
+ * @description 处理 prop,当 prop 为多级嵌套时 ==> 返回最后一级 prop
42
+ * @param {String} prop 当前 prop
43
+ * @returns {String}
44
+ * */
45
+ export function handleProp(prop: string) {
46
+ const propArr = prop.split(".");
47
+ if (propArr.length == 1) return prop;
48
+ return propArr[propArr.length - 1];
49
+ }
50
+
51
+ /**
52
+ * @description 根据枚举列表查询当需要的数据(如果指定了 label 和 value 的 key值,会自动识别格式化)
53
+ * @param {String} callValue 当前单元格值
54
+ * @param {Array} enumData 字典列表
55
+ * @param {Array} fieldNames label && value && children 的 key 值
56
+ * @param {String} type 过滤类型(目前只有 tag)
57
+ * @returns {String}
58
+ * */
59
+ export function filterEnum(callValue: any, enumData?: any, fieldNames?: FieldNamesProps, type?: "tag") {
60
+ const value = fieldNames?.value ?? "value";
61
+ const label = fieldNames?.label ?? "label";
62
+ const children = fieldNames?.children ?? "children";
63
+ let filterData: { [key: string]: any } = {};
64
+ // 判断 enumData 是否为数组
65
+ if (Array.isArray(enumData)) filterData = findItemNested(enumData, callValue, value, children);
66
+ // 判断是否输出的结果为 tag 类型
67
+ if (type == "tag") {
68
+ return filterData?.tagType ? filterData.tagType : "";
69
+ } else {
70
+ return filterData ? filterData[label] : "--";
71
+ }
72
+ }
73
+
74
+ /**
75
+ * @description 递归查找 callValue 对应的 enum 值
76
+ * */
77
+ export function findItemNested(enumData: any, callValue: any, value: string, children: string) {
78
+ return enumData.reduce((accumulator: any, current: any) => {
79
+ if (accumulator) return accumulator;
80
+ if (current[value] === callValue) return current;
81
+ if (current[children]) return findItemNested(current[children], callValue, value, children);
82
+ }, null);
83
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @description 获取localStorage
3
+ * @param {String} key Storage名称
4
+ * @returns {String}
5
+ */
6
+
7
+ import { DEMO_KEY } from "@/config";
8
+ export function localGet(key: string) {
9
+ const value = window.localStorage.getItem(DEMO_KEY + key);
10
+ try {
11
+ return JSON.parse(window.localStorage.getItem(DEMO_KEY + key) as string);
12
+ } catch (error) {
13
+ return value;
14
+ }
15
+ }
16
+
17
+ /**
18
+ * @description 存储localStorage
19
+ * @param {String} key Storage名称
20
+ * @param {*} value Storage值
21
+ * @returns {void}
22
+ */
23
+ export function localSet(key: string, value: any) {
24
+ window.localStorage.setItem(DEMO_KEY + key, JSON.stringify(value));
25
+ }
26
+
27
+ /**
28
+ * @description 清除localStorage
29
+ * @param {String} key Storage名称
30
+ * @returns {void}
31
+ */
32
+ export function localRemove(key: string) {
33
+ window.localStorage.removeItem(DEMO_KEY + key);
34
+ }
35
+
36
+ /**
37
+ * @description 清除所有localStorage
38
+ * @returns {void}
39
+ */
40
+ export function localClear() {
41
+ window.localStorage.clear();
42
+ }
@@ -0,0 +1,9 @@
1
+ // ? 系统全局字典
2
+
3
+ /**
4
+ * @description:用户状态
5
+ */
6
+ export const userStatus = [
7
+ { label: "启用", value: 1 },
8
+ { label: "禁用", value: 0 }
9
+ ];
@@ -0,0 +1,6 @@
1
+ /// <reference types="vite/client" />
2
+ declare module "*.vue" {
3
+ import { ComponentOptions } from "vue";
4
+ const componentOptions: ComponentOptions;
5
+ export default componentOptions;
6
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "target": "ESNext",
5
+ "useDefineForClassFields": true,
6
+ "module": "ESNext",
7
+ "moduleResolution": "Node",
8
+ "types": ["vite/client", "element-plus/global"],
9
+ "sourceMap": true,
10
+ /* Strict Type-Checking Options */
11
+ "strict": false /* 不使用严格的类型检查. */,
12
+ "noImplicitAny": false /* 是否在表达式和声明上有隐含的any类型时报错. */,
13
+ "declarationDir": "./lib/types",
14
+ "emitDeclarationOnly": true,
15
+ // "strictNullChecks": true, /* Enable strict null checks. */
16
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
17
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
18
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
19
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
20
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
21
+ "allowSyntheticDefaultImports": true,
22
+ "jsx": "preserve",
23
+ "resolveJsonModule": true,
24
+ "isolatedModules": true,
25
+ "esModuleInterop": true,
26
+ "lib": ["ESNext", "DOM"],
27
+ "skipLibCheck": true,
28
+ // "noEmit": true,
29
+ "baseUrl": "./",
30
+ "paths": {
31
+ "@": ["src"],
32
+ "@/*": ["src/*"]
33
+ }
34
+ },
35
+ "include": [
36
+ "src/**/*.ts",
37
+ "src/*.ts",
38
+ "src/**/*.js",
39
+ "src/**/*.d.ts",
40
+ "src/**/*.tsx",
41
+ "build/**/*.ts",
42
+ "build/**/*.d.ts",
43
+ "lib/**/*.ts",
44
+ "lib/**/*.d.ts",
45
+ "vite.config.ts",
46
+ "./components.d.ts",
47
+ "./auto-imports.d.ts"
48
+ ],
49
+ "exclude": ["node_modules", "dist", "src/views/**/*.ts"]
50
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { defineConfig, loadEnv, ConfigEnv, UserConfig } from "vite";
2
+ import { resolve } from "path";
3
+ import { wrapperEnv } from "./build/getEnv";
4
+ import { createProxy } from "./build/proxy";
5
+ import { createVitePlugins } from "./build/plugins";
6
+ import pkg from "./package.json";
7
+ import dayjs from "dayjs";
8
+
9
+ const { dependencies, devDependencies, name, version } = pkg;
10
+ const __APP_INFO__ = {
11
+ pkg: { dependencies, devDependencies, name, version },
12
+ lastBuildTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
13
+ };
14
+
15
+ const fs: any = {
16
+ maxFileSize: 5 * 1024 * 1024
17
+ };
18
+
19
+ // @see: https://vitejs.dev/config/
20
+ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
21
+ const root = process.cwd();
22
+ const env = loadEnv(mode, root);
23
+ const viteEnv = wrapperEnv(env);
24
+ return {
25
+ base: viteEnv.VITE_PUBLIC_PATH,
26
+ root,
27
+ resolve: {
28
+ alias: {
29
+ "@": resolve(__dirname, "./src"),
30
+ packages: resolve("packages")
31
+ }
32
+ },
33
+ define: {
34
+ __APP_INFO__: JSON.stringify(__APP_INFO__)
35
+ },
36
+ css: {
37
+ preprocessorOptions: {
38
+ scss: {
39
+ api: "modern-compiler",
40
+ additionalData: `@import "@/styles/var.scss";`
41
+ }
42
+ }
43
+ },
44
+ server: {
45
+ host: "0.0.0.0",
46
+ port: viteEnv.VITE_PORT,
47
+ open: viteEnv.VITE_OPEN,
48
+ cors: true,
49
+ // Load proxy configuration from .env.development
50
+ proxy: createProxy(viteEnv.VITE_PROXY),
51
+ fs: fs
52
+ },
53
+ plugins: createVitePlugins(viteEnv),
54
+ esbuild: {
55
+ pure: viteEnv.VITE_DROP_CONSOLE ? ["console.log", "debugger"] : []
56
+ },
57
+ build: {
58
+ outDir: "lib", //输出文件名称
59
+ lib: {
60
+ entry: resolve(__dirname, "src/plugins/index.js"), //指定组件编译入口文件
61
+ name: "zyf-model-engine",
62
+ fileName: "zyf-model-engine"
63
+ }, //库编译模式配置
64
+ rollupOptions: {
65
+ // 确保外部化处理那些你不想打包进库的依赖
66
+ external: ["vue"],
67
+ output: {
68
+ // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
69
+ globals: {
70
+ vue: "Vue"
71
+ }
72
+ }
73
+ } // rollup打包配置
74
+ }
75
+ };
76
+ });