general-basic-form 1.1.4 → 1.2.0

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.
package/README.md CHANGED
@@ -60,7 +60,7 @@ import 'general-basic-form/style'
60
60
  :formData.sync: {
61
61
  // 外部传入的表单数据,用于回填
62
62
  }
63
- noUrlParameters
63
+ parametersType="data"
64
64
  :afterReset="afterReset"
65
65
  v-model:loading="loading"
66
66
  />
@@ -135,22 +135,29 @@ this.$refs['GeneralBasicFormRef'].resetQuery()
135
135
  const params = VGeneralBasicFormRef.value['queryParams']
136
136
  resolve(params)
137
137
  } else {
138
- resolve(false)
138
+ reject()
139
139
  }
140
140
  }
141
141
  )
142
142
  })
143
143
 
144
-
145
144
  ![image-20211014191532067](https://raw.githubusercontent.com/Alan1034/PicturesServer/main/PicGo_imgs/202110141915657.png)
146
145
 
146
+ parametersType类型介绍
147
+
148
+ | parametersType形式 | 支持页面刷新 | 参数改变引起路由跳转 | 组件间共享数据 | 存储上限 | 浏览器兼容性 |
149
+ | ------------------ | ------------ | -------------------- | -------------- | -------- | ------------ |
150
+ | url | 是 | 是 | 是 | 中 | 高 |
151
+ | data | 否 | 否 | 否 | 高 | 高 |
152
+ | indexDB | 是 | 否 | 是 | 高 | 中 |
153
+
147
154
  数据示例:
148
155
 
149
156
  showSearch: true, // 显示搜索条件
150
157
  getList(); // 请求数据的函数
151
158
  afterReset(); // 在重置按钮点击完后但还没重新请求时触发的的函数
152
159
  formOnly:true // 只展示表单不展示按钮
153
- noUrlParameters:true // 不接受和不改变url的参数
160
+ parametersType:"url" // 见parametersType类型介绍
154
161
  loading:false // 加载动画
155
162
  formData:{} // 注意,因为可能出现的性能问题在组件watch formData的变化时没有使用deep,所以有时候深度的修改会不生效,导致表单数据不完整
156
163
  noInputBlank: true //校验input框不能仅输入空格
@@ -159,6 +166,7 @@ this.$refs['GeneralBasicFormRef'].resetQuery()
159
166
  pageSizeKey:"limit", //每页显示个数选择器的选项设置
160
167
  defCurrentPage:1, //默认的页数
161
168
  defPageSize:10, //默认的每页显示个数
169
+ queryWhenReady:false,//初始化完成后自动触发查找数据函数,建议用这个this.$refs["VGeneralBasicFormRef"].handleQuery({ defaultPageFirst: false })
162
170
  formItem: [
163
171
  {
164
172
  label: '',
@@ -621,7 +629,7 @@ import { VTabs } from "general-basic-form";
621
629
 
622
630
  ```
623
631
  tabPanes:[],// 定义标签页的数据
624
- noUrlParameters:false,// 不接受和不改变url的参数
632
+ parametersType:"url" // 见parametersType类型介绍
625
633
  activeNameKey:"activeName",//保存标签页的字段KEY
626
634
  defActiveName:null,//标签页的选中值
627
635
  getList:()=>{},// 查找数据调用的函数
package/package.json CHANGED
@@ -1,70 +1,60 @@
1
- {
2
- "name": "general-basic-form",
3
- "version": "1.1.4",
4
- "description": "",
5
- "main": "./dist/index.umd.cjs",
6
- "type": "module",
7
- "scripts": {
8
- "build": "cross-env CURRENT_ENV=prod run-p type-check && run-p build-only",
9
- "test:e2e": "playwright test",
10
- "build-only": "vite build",
11
- "type-check": "tsc --noEmit -p tsconfig.json --composite false",
12
- "link": "tsx script/link.ts && yarn link",
13
- "unlink": "tsx script/unlinkModule.ts && yarn unlink && run-p build",
14
- "linkNode": "tsx script/linkNode.ts && yarn link && run-p dev",
15
- "unlinkNode": "tsx script/unlinkNode.ts && yarn unlink && run-p buildts",
16
- "dev": "tsc -w -p .",
17
- "buildts": "rimraf dist && tsc -p ."
18
- },
19
- "keywords": [
20
- "general-basic-form",
21
- "form",
22
- "vue",
23
- "vue2",
24
- "vue3",
25
- "element-plus",
26
- "element",
27
- "typescript"
28
- ],
29
- "author": "chendeli419287484@qq.com",
30
- "license": "ISC",
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/Alan1034/GeneralBasicForm.git"
34
- },
35
- "devDependencies": {
36
- "@playwright/test": "^1.36.1",
37
- "@types/node": "^20.8.10",
38
- "@vitejs/plugin-legacy": "^4.1.1",
39
- "@vitejs/plugin-vue2": "^2.3.1",
40
- "@vitejs/plugin-vue2-jsx": "^1.1.1",
41
- "chalk": "^2.4.2",
42
- "cross-env": "^7.0.3",
43
- "less": "^4.2.0",
44
- "npm-run-all": "^4.1.5",
45
- "rimraf": "^5.0.5",
46
- "sass": "^1.77.8",
47
- "tsx": "^4.0.0",
48
- "typescript": "^5.2.2",
49
- "vite-plugin-image-optimizer": "^1.1.6"
50
- },
51
- "peerDependencies": {
52
- "vue": "^2.7.0-0"
53
- },
54
- "typings": "./dist/index.d.ts",
55
- "dependencies": {
56
- "network-spanner": "^1.2.8"
57
- },
58
- "module": "./dist/index.js",
59
- "exports": {
60
- ".": {
61
- "import": "./dist/index.js",
62
- "require": "./dist/index.umd.cjs",
63
- "types": "./dist/index.d.ts"
64
- },
65
- "./style": "./dist/style.css"
66
- },
67
- "files": [
68
- "/dist"
69
- ]
70
- }
1
+ {
2
+ "name": "general-basic-form",
3
+ "version": "1.2.0",
4
+ "description": "",
5
+ "main": "./src/index.ts",
6
+ "type": "module",
7
+ "scripts": {
8
+ "build": "cross-env CURRENT_ENV=prod run-p type-check && run-p build-only",
9
+ "test:e2e": "playwright test",
10
+ "build-only": "vite build",
11
+ "type-check": "tsc --noEmit -p tsconfig.json --composite false",
12
+ "link": "tsx script/link.ts && yarn link",
13
+ "unlink": "tsx script/unlinkModule.ts && yarn unlink && run-p build",
14
+ "linkNode": "tsx script/linkNode.ts && yarn link && run-p dev",
15
+ "unlinkNode": "tsx script/unlinkNode.ts && yarn unlink && run-p buildts",
16
+ "dev": "tsc -w -p .",
17
+ "buildts": "rimraf dist && tsc -p ."
18
+ },
19
+ "keywords": [
20
+ "general-basic-form",
21
+ "form",
22
+ "vue",
23
+ "vue2",
24
+ "vue3",
25
+ "vue-router",
26
+ "element-plus",
27
+ "element",
28
+ "typescript"
29
+ ],
30
+ "author": "chendeli419287484@qq.com",
31
+ "license": "ISC",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/Alan1034/GeneralBasicForm.git"
35
+ },
36
+ "devDependencies": {
37
+ "@playwright/test": "^1.36.1",
38
+ "@types/node": "^20.8.10",
39
+ "@vitejs/plugin-legacy": "^4.1.1",
40
+ "@vitejs/plugin-vue2": "^2.3.1",
41
+ "@vitejs/plugin-vue2-jsx": "^1.1.1",
42
+ "chalk": "^2.4.2",
43
+ "cross-env": "^7.0.3",
44
+ "less": "^4.2.0",
45
+ "npm-run-all": "^4.1.5",
46
+ "rimraf": "^5.0.5",
47
+ "sass": "^1.77.8",
48
+ "tsx": "^4.0.0",
49
+ "typescript": "^5.2.2",
50
+ "vite-plugin-image-optimizer": "^1.1.6"
51
+ },
52
+ "peerDependencies": {
53
+ "vue": "^2.7.0-0"
54
+ },
55
+ "typings": "./publish/index.d.ts",
56
+ "dependencies": {
57
+ "general-basic-indexdb": "^1.0.1",
58
+ "network-spanner": "^1.2.8"
59
+ }
60
+ }
@@ -0,0 +1,17 @@
1
+ /*
2
+ * @Author: 陈德立*******419287484@qq.com
3
+ * @Date: 2023-11-07 17:55:59
4
+ * @LastEditTime: 2023-11-08 10:24:14
5
+ * @LastEditors: 陈德立*******419287484@qq.com
6
+ * @Github: https://github.com/Alan1034
7
+ * @Description:
8
+ * @FilePath: \GeneralBasicForm\public\index.d.ts
9
+ *
10
+ */
11
+ /// <reference types="vite/client" />
12
+ declare module "*.vue" {
13
+ import { DefineComponent } from "vue"
14
+ const component: DefineComponent<{}, {}, any>
15
+ export default component
16
+ }
17
+ declare module "general-basic-form";
@@ -0,0 +1,24 @@
1
+ import path from "path";
2
+ import fs from 'fs'
3
+ import chalk from 'chalk'
4
+ import { fileURLToPath } from 'url'
5
+ const __filenameNew = fileURLToPath(import.meta.url)
6
+ const __dirnameNew = path.dirname(__filenameNew)
7
+ export const updateMain = (mainDir:string) => {
8
+ try {
9
+ const packageTxt = fs.readFileSync(path.join(__dirnameNew, '../package.json'), 'utf8');
10
+ const packageJson = JSON.parse(packageTxt);
11
+
12
+ delete packageJson.files
13
+ delete packageJson.module
14
+ delete packageJson.exports
15
+ packageJson.typings = "./publish/index.d.ts"
16
+ packageJson.main = mainDir
17
+ const versionData = JSON.stringify(packageJson, null, 2);
18
+ fs.writeFileSync(path.join(__dirnameNew, '../package.json'), versionData, 'utf8');
19
+ console.log(chalk.green.bold('修改入口配置成功!当前入口路径为为:' + mainDir));
20
+ } catch (error) {
21
+ console.log(chalk.red.bold('修改入口配置出错:', error.toString()));
22
+ }
23
+
24
+ }
package/script/link.ts ADDED
@@ -0,0 +1,14 @@
1
+ /*
2
+ * @Author: 陈德立*******419287484@qq.com
3
+ * @Date: 2023-11-10 09:39:59
4
+ * @LastEditTime: 2023-11-15 18:38:43
5
+ * @LastEditors: 陈德立*******419287484@qq.com
6
+ * @Github: https://github.com/Alan1034
7
+ * @Description: link处理流程
8
+ * @FilePath: \VueNpmFrame\script\link.ts
9
+ *
10
+ */
11
+ import { updateMain } from "./initialization";
12
+
13
+
14
+ updateMain("./src/index.ts")
@@ -0,0 +1,14 @@
1
+ /*
2
+ * @Author: 陈德立*******419287484@qq.com
3
+ * @Date: 2023-11-10 09:39:59
4
+ * @LastEditTime: 2024-03-01 11:27:02
5
+ * @LastEditors: 陈德立*******419287484@qq.com
6
+ * @Github: https://github.com/Alan1034
7
+ * @Description: link处理流程
8
+ * @FilePath: \VueNpmFrame\script\linkNode.ts
9
+ *
10
+ */
11
+ import { updateMain } from "./initialization";
12
+
13
+
14
+ updateMain("./dist/src/index.js")
@@ -0,0 +1,48 @@
1
+ /*
2
+ * @Author: 陈德立*******419287484@qq.com
3
+ * @Date: 2023-11-10 09:39:59
4
+ * @LastEditTime: 2023-11-25 23:52:27
5
+ * @LastEditors: 陈德立*******419287484@qq.com
6
+ * @Github: https://github.com/Alan1034
7
+ * @Description: unlink处理流程
8
+ * @FilePath: \vite-plugin-update-version\script\unlinkModule.ts
9
+ *
10
+ */
11
+ import path from "path";
12
+ import fs from 'fs'
13
+ import chalk from 'chalk'
14
+ import { fileURLToPath } from 'url'
15
+ const __filenameNew = fileURLToPath(import.meta.url)
16
+ const __dirnameNew = path.dirname(__filenameNew)
17
+ const updateMain = () => {
18
+ try {
19
+ const packageTxt = fs.readFileSync(path.join(__dirnameNew, '../package.json'), 'utf8');
20
+ const packageJson = JSON.parse(packageTxt);
21
+ const umdDir = "./dist/index.umd.cjs"
22
+ const esDir = "./dist/index.js"
23
+ const types = "./dist/index.d.ts"
24
+ packageJson.type = "module"
25
+ packageJson.main = umdDir
26
+ packageJson.module = esDir
27
+ packageJson.exports = {
28
+ ".": {
29
+ "import": esDir,
30
+ "require": umdDir,
31
+ "types": types
32
+ },
33
+ "./style": "./dist/style.css"
34
+ }
35
+ packageJson.typings = types
36
+ packageJson.files = [
37
+ "/dist"
38
+ ]
39
+ const versionData = JSON.stringify(packageJson, null, 2);
40
+ fs.writeFileSync(path.join(__dirnameNew, '../package.json'), versionData, 'utf8');
41
+ console.log(chalk.green.bold('修改入口配置成功!当前入口路径为为:' + umdDir));
42
+ } catch (error) {
43
+ console.log(chalk.red.bold('修改入口配置出错:', error.toString()));
44
+ }
45
+
46
+ }
47
+
48
+ updateMain()
@@ -0,0 +1,38 @@
1
+ /*
2
+ * @Author: 陈德立*******419287484@qq.com
3
+ * @Date: 2023-11-10 09:39:59
4
+ * @LastEditTime: 2024-03-01 11:33:05
5
+ * @LastEditors: 陈德立*******419287484@qq.com
6
+ * @Github: https://github.com/Alan1034
7
+ * @Description: unlink处理流程
8
+ * @FilePath: \VueNpmFrame\script\unlinkNode.ts
9
+ *
10
+ */
11
+ import path from "path";
12
+ import fs from 'fs'
13
+ import chalk from 'chalk'
14
+ import { fileURLToPath } from 'url'
15
+ const __filenameNew = fileURLToPath(import.meta.url)
16
+ const __dirnameNew = path.dirname(__filenameNew)
17
+ const updateMain = () => {
18
+ try {
19
+ const packageTxt = fs.readFileSync(path.join(__dirnameNew, '../package.json'), 'utf8');
20
+ const packageJson = JSON.parse(packageTxt);
21
+ const cjsDir = "./dist/src/index.js"
22
+ const types = "./dist/src/index.d.ts"
23
+ delete packageJson.type
24
+ packageJson.main = cjsDir
25
+ packageJson.typings = types
26
+ packageJson.files = [
27
+ "/dist"
28
+ ]
29
+ const versionData = JSON.stringify(packageJson, null, 2);
30
+ fs.writeFileSync(path.join(__dirnameNew, '../package.json'), versionData, 'utf8');
31
+ console.log(chalk.green.bold('修改入口配置成功!当前入口路径为为:' + cjsDir));
32
+ } catch (error) {
33
+ console.log(chalk.red.bold('修改入口配置出错:', error.toString()));
34
+ }
35
+
36
+ }
37
+
38
+ updateMain()
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "include": [
3
+ "public/index.d.tsex.d.ts",
4
+ "src/**/*",
5
+ "src/**/*.vue",
6
+ "public/*",
7
+ ],
8
+ "exclude": [],
9
+ "compilerOptions": {
10
+ "declaration": true,
11
+ "allowJs": true,
12
+ "composite": true
13
+ }
14
+ }
package/vite.config.js ADDED
@@ -0,0 +1,121 @@
1
+ import legacy from '@vitejs/plugin-legacy'
2
+ import { fileURLToPath } from 'url'
3
+ import { defineConfig, loadEnv, splitVendorChunkPlugin } from 'vite'
4
+ import vue from '@vitejs/plugin-vue2'
5
+ import vueJsx from '@vitejs/plugin-vue2-jsx'
6
+ import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
7
+ import path from 'path';
8
+ const __filenameNew = fileURLToPath(import.meta.url)
9
+ const __dirnameNew = path.dirname(__filenameNew)
10
+ const resolve = (dir) => path.resolve(__dirnameNew, dir);
11
+ // https://vitejs.dev/config/
12
+ export default defineConfig(({ command, mode }) => {
13
+ // 根据当前工作目录中的 `mode` 加载 .env 文件
14
+ // 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
15
+ const env = loadEnv(mode, process.cwd(), '')
16
+ // console.log(command)
17
+ // console.log(env)
18
+ // console.log(env.CURRENT_ENV)
19
+ // console.log(env.APP_ENV)
20
+ // console.log(env.VUE_APP_BASE_API)
21
+ return {
22
+ // vite环境变量配置
23
+ define: {
24
+ "CURRENT_ENV": JSON.stringify(env.CURRENT_ENV),
25
+ },
26
+ server: {
27
+ open: true,
28
+ },
29
+ resolve: {
30
+ alias: {
31
+ '@': resolve('src'),//路径化名
32
+ },
33
+
34
+ extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
35
+ },
36
+
37
+ plugins: [
38
+ /**
39
+ * @description: vite自带的文件分割配置
40
+ * @return {*}
41
+ */
42
+ {
43
+ ...splitVendorChunkPlugin(),
44
+ apply: 'build',
45
+ },
46
+ /**
47
+ * @description: 图片压缩插件
48
+ * @return {*}
49
+ */
50
+ {
51
+ ...ViteImageOptimizer({
52
+ /* pass your config */
53
+ }),
54
+ // enforce: 'pre',
55
+ apply: 'build',
56
+ },
57
+ /**
58
+ * @description: 兼容旧版本浏览器
59
+ * @return {*}
60
+ */
61
+ {
62
+ ...legacy({
63
+ targets: ['defaults'],
64
+ }),
65
+ apply: 'build',
66
+ },
67
+ vue(),
68
+ vueJsx(),
69
+ ],
70
+ css: {
71
+ preprocessorOptions: {
72
+ less: {
73
+ // 支持内联 JavaScript
74
+ javascriptEnabled: true,
75
+ },
76
+ },
77
+ },
78
+ /**
79
+ * @description: 打包时才调用
80
+ * @return {*}
81
+ */
82
+ build: {
83
+ lib: {
84
+ // Could also be a dictionary or array of multiple entry points
85
+ // 添加打包入口文件夹
86
+ entry: resolve(`${__dirnameNew}/src`, 'index.ts'),
87
+ // formats: ['es', 'cjs', 'umd', 'iife'],
88
+ name: 'Index',
89
+ // the proper extensions will be added
90
+ // fileName: (format) => `index.${format}.js`,
91
+ fileName: "index",
92
+ },
93
+ rollupOptions: {
94
+ // 确保外部化处理那些你不想打包进库的依赖
95
+ external: ['vue'],
96
+ output: {
97
+ // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
98
+ globals: {
99
+ vue: 'Vue',
100
+ },
101
+ },
102
+ },
103
+ // minify: 'terser',
104
+ //打包环境移除console.log,debugger
105
+ // terserOptions: {
106
+ // compress: {
107
+ // drop_console: true,
108
+ // drop_debugger: true,
109
+ // },
110
+ // },
111
+ //打包文件按照类型分文件夹显示(貌似会导致性能下降)
112
+ // rollupOptions: {
113
+ // output: {
114
+ // chunkFileNames: 'js/[name]-chunk-[hash:7].js',
115
+ // entryFileNames: 'js/[name]-app-[hash:7].js',
116
+ // assetFileNames: '[ext]/[name]-chunk-[hash:7].[ext]',
117
+ // },
118
+ // },
119
+ },
120
+ }
121
+ })