@yoooloo42/joker 1.0.7 → 1.0.9

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/package.json CHANGED
@@ -1,9 +1,15 @@
1
1
  {
2
2
  "name": "@yoooloo42/joker",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
+ "type": "module",
6
+ "main": "dist/index.cjs.js",
7
+ "module": "dist/index.esm.js",
5
8
  "scripts": {
6
- "test": "echo \"Error: no test specified\" && exit 1"
9
+ "clean": "rm -rf dist",
10
+ "build": "npm run clean && rollup -c",
11
+ "build:prod": "cross-env NODE_ENV=production npm run build",
12
+ "watch": "rollup -c -w"
7
13
  },
8
14
  "repository": {
9
15
  "type": "git",
@@ -16,14 +22,26 @@
16
22
  },
17
23
  "homepage": "https://github.com/13993193075/joker#readme",
18
24
  "dependencies": {
19
- "@yoooloo42/bean": "^1.0.16",
25
+ "@yoooloo42/bean": "^1.0.24",
20
26
  "file-saver": "^2.0.5",
21
27
  "xlsx": "^0.18.5"
22
28
  },
23
29
  "exports": {
24
- "./libs/*": "./src/libs/*.js"
30
+ ".": {
31
+ "import": "./dist/index.esm.js",
32
+ "require": "./dist/index.cjs.js"
33
+ },
34
+ "./*": "./*",
35
+ "./dist/*": "./dist/*"
25
36
  },
26
37
  "files": [
27
- "src"
28
- ]
38
+ "dist"
39
+ ],
40
+ "devDependencies": {
41
+ "@rollup/plugin-commonjs": "^29.0.0",
42
+ "@rollup/plugin-node-resolve": "^16.0.3",
43
+ "@rollup/plugin-terser": "^0.4.4",
44
+ "cross-env": "^10.1.0",
45
+ "rollup": "^4.53.2"
46
+ }
29
47
  }
@@ -1,51 +0,0 @@
1
- import * as XLSX from 'xlsx';
2
- import FileSaver from 'file-saver';
3
-
4
- /**
5
- * 将 JSON 数组数据导出为 Excel 文件
6
- * @param {Array<Object>} json - 要导出的数据数组 (el-table 的 :data 绑定的数据)
7
- * @param {Array<string>} header - 表格的表头(中文名)
8
- * @param {Array<string>} keys - 对应表头的数据字段名(英文键名)
9
- * @param {string} filename - 导出的文件名
10
- */
11
- function jsonToExcel({
12
- json,
13
- header,
14
- keys,
15
- filename = 'excel-file',
16
- }) {
17
- // 1. 转换数据格式
18
- const data = json.map(item => keys.map(key => item[key]));
19
-
20
- // 2. 将表头和数据组合
21
- const aoa = [header, ...data];
22
-
23
- // 3. 创建工作簿和工作表
24
- const ws = XLSX.utils.aoa_to_sheet(aoa);
25
- const wb = XLSX.utils.book_new();
26
- XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
27
-
28
- // 4. 生成 Excel 文件
29
- const wbout = XLSX.write(wb, {
30
- bookType: 'xlsx',
31
- bookSST: true,
32
- type: 'array'
33
- });
34
-
35
- // 5. 保存文件
36
- try {
37
- FileSaver.saveAs(
38
- new Blob([wbout], { type: 'application/octet-stream' }),
39
- `${filename}.xlsx`
40
- );
41
- } catch (e) {
42
- if (typeof console !== 'undefined') console.log(e, wbout);
43
- }
44
- }
45
-
46
- export {
47
- jsonToExcel
48
- }
49
- export default {
50
- jsonToExcel
51
- }
package/src/index.js DELETED
@@ -1,4 +0,0 @@
1
- import FileSaver from './FileSaver/index.js'
2
-
3
- export {FileSaver}
4
- export default {FileSaver}