Skip to content

Commit a4f65d7

Browse files
committed
chore: test
chore: test chore: add scripts and plugin,remove browserPlugin chore: add scripts
1 parent 8f88e44 commit a4f65d7

File tree

5 files changed

+114
-6
lines changed

5 files changed

+114
-6
lines changed

.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ module.exports = {
55
'no-console': ['error', { allow: ['warn', 'error', 'debug'] }],
66
'vue/v-on-event-hyphenation': 'off',
77
},
8+
ignorePatterns: ['node_modules/', 'dist/', 'browserPlugin/'],
89
}

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77
"prepare": "simple-git-hooks",
88
"serve": "vue-cli-service serve",
99
"build": "vue-cli-service build",
10+
"build:plugin": "npm run build && node ./scripts/build-plugin.mjs",
1011
"lint": "eslint .",
1112
"lint:fix": "eslint . --fix"
13+
1214
},
1315
"dependencies": {
1416
"ant-design-vue": "^4.0.3",
1517
"axios": "^1.5.0",
1618
"url-loader": "^4.1.1",
1719
"vue": "^3.2.13",
18-
"vue-grid-layout": "^3.0.0-beta1",
20+
"vue-grid-layout": "npm:@nrr/vue-grid-layout@3.0.0-beta1",
1921
"vue-router": "^4.0.3",
2022
"vue3-drr-grid-layout": "^1.9.7",
2123
"vue3-smooth-dnd": "^0.0.6",
22-
"vuex": "^4.0.0",
23-
"vue-grid-layout": "npm:@nrr/[email protected]"
24+
"vuex": "^4.0.0"
2425
},
2526
"devDependencies": {
2627
"@antfu/eslint-config": "^0.43.0",

scripts/build-plugin.mjs

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import fs from 'node:fs/promises'
2+
import { statSync } from 'node:fs'
3+
import path from 'node:path'
4+
import process from 'node:process'
5+
6+
const sourceSrc = `${process.cwd()}\\dist`
7+
const targetSrc = `${process.cwd()}\\browserPlugin`
8+
// fs/promises写法
9+
function move(sourceRoot, targetRoot) {
10+
console.debug(`开始移动${sourceRoot}中的文件至${targetRoot}`)
11+
fs.readdir(sourceRoot)
12+
.then((files) => {
13+
files.forEach((file) => {
14+
const sourceFile = path.join(sourceRoot, file)
15+
const targetFile = path.join(targetRoot, file)
16+
17+
if (statSync(sourceFile).isDirectory()) {
18+
fs.stat(targetFile)
19+
.then(() => {
20+
console.debug('已存在该文件夹')
21+
})
22+
.catch((err) => {
23+
if (err.code === 'ENOENT') {
24+
// 在targetSrc中新建同名文件夹
25+
fs.mkdir(targetFile)
26+
.then(() => {
27+
console.debug(`新建${targetFile}文件夹成功`)
28+
})
29+
.catch((err) => {
30+
console.debug(`新建失败ERROR:${err}`)
31+
})
32+
}
33+
else {
34+
console.error('发生错误:', err)
35+
}
36+
})
37+
move(sourceFile, targetFile)
38+
}
39+
else {
40+
const copyFn = () => {
41+
fs.copyFile(sourceFile, targetFile)
42+
.then(() => {
43+
console.debug('复制成功')
44+
})
45+
.catch(() => {
46+
console.debug('复制失败')
47+
})
48+
}
49+
fs.unlink(targetFile)
50+
.then(() => {
51+
console.debug('正在删除同名文件')
52+
copyFn()
53+
})
54+
.catch(() => {
55+
console.debug('无同名文件, 直接复制')
56+
copyFn()
57+
})
58+
}
59+
})
60+
})
61+
}
62+
// fs写法
63+
// fs.readdir(sourceSrc, (err, files) => {
64+
// if (err) {
65+
// console.debug("读取文件夹失败");
66+
// } else {
67+
// files.forEach((file) => {
68+
// const sourceFile = path.join(sourceSrc, file);
69+
// const targetFile = path.join(targetSrc, file);
70+
// fs.unlink(targetFile, (err) => {
71+
// if (!err || err.code !== "ENOENT") {
72+
// fs.copyFile(sourceFile, targetFile, (err) => {
73+
// if (err) {
74+
// console.debug("复制失败");
75+
// } else {
76+
// console.debug("复制成功")
77+
// }
78+
// })
79+
// } else {
80+
// console.debug("删除失败");
81+
// }
82+
// })
83+
84+
// });
85+
// }
86+
// })
87+
fs.stat(targetSrc)
88+
.then((result) => {
89+
if (result.isDirectory())
90+
move(sourceSrc, targetSrc)
91+
else
92+
console.debug('browserPlugin不是一个文件夹')
93+
})
94+
.catch((err) => {
95+
if (err.code === 'ENOENT') {
96+
// 新建browserPlugin文件夹
97+
fs.mkdir('browserPlugin')
98+
.then(() => {
99+
move(sourceSrc, targetSrc)
100+
})
101+
.catch((err) => {
102+
console.debug(`新建失败ERROR:${err}`)
103+
})
104+
}
105+
else {
106+
console.error('发生错误:', err)
107+
}
108+
})

src/components/TagsBox.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import { GridItem, GridLayout } from 'vue3-drr-grid-layout'
33
import 'vue3-drr-grid-layout/dist/style.css'
44
import { nextTick } from 'vue'
5-
65
import Kxz from '@/assets/ico/kxz.png'
76
7+
// 123545678
88
export default ({
99
components: {
1010
GridLayout,

src/components/UserBox.vue

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<script>
22
import { nextTick } from 'vue'
3-
import { eventType } from 'ant-design-vue/es/_util/type'
4-
import Kxz from '@/assets/ico/kxz.png'
53
64
// import Avatar from '@/assets/ico/Avatar.png'
75

0 commit comments

Comments
 (0)