Skip to content

Commit 8ff9805

Browse files
committed
fix: 更新同步插件
1 parent 9b33e9d commit 8ff9805

File tree

6 files changed

+32
-44
lines changed

6 files changed

+32
-44
lines changed

plugin/index.js

+3-27
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,23 @@ class CopyPlugin {
88

99
apply(compiler) {
1010
const { from, to } = this.options
11-
console.log('-----', from, to)
1211
const fromFiles = fs.readdirSync(from)
13-
console.log(fromFiles)
1412
const exists = fs.existsSync(to)
15-
console.log(exists)
1613
if (exists) {
1714
fs.removeSync(to)
1815
}
1916
fromFiles.forEach(pathName => {
17+
if(pathName === '.DS_Store') return
2018
// let name = path.join(from, pathName, pathName + '.vue')
2119
const subFileLists = fs.readdirSync(path.join(from, pathName))
2220
subFileLists.forEach((item) => {
2321
const basename = path.basename(item, '.vue')
2422
fs.copySync(path.join(from, pathName, item), path.join(to, pathName, basename + '.nvue'))
2523
})
2624
})
27-
// fs.exists(to, (exists) => {
28-
// console.log(exists)
29-
// if (exists) {
30-
// fs.removeSync(to)
31-
// }
32-
// fromFiles.forEach(pathName=>{
33-
// let name = path.join(from,pathName,pathName+'.vue')
34-
// console.log(name)
35-
// })
36-
// })
3725

38-
// fs.copy(from, to, (err) => {
39-
// if (err) console.error(err)
40-
// })
4126
compiler.hooks.watchRun.tapAsync('CopyPlugin', (watching, callback) => {
42-
console.log('这里进行了修改,注意看')
27+
// changedFiles 格式为键值对,键为发生变化的文件路径。
4328
// 获取发生变化的文件列表
4429
const changedFiles = watching.watchFileSystem.watcher.mtimes;
4530
Object.keys(changedFiles).forEach(filePath => {
@@ -62,25 +47,16 @@ class CopyPlugin {
6247
// 获取要copy 的路径
6348
const toFilePath = path.join(to, name, '..', basename + '.nvue')
6449

65-
// console.log(name)
66-
// console.log(extname)
67-
// console.log(basename)
6850
console.log(path.join(filePath, '..'))
6951
console.log(from)
7052
if (path.join(filePath, '..').indexOf(from) === -1) {
7153
console.log('不修改这个文件', filePath)
7254
} else {
73-
console.log('修改这个文件到:', toFilePath)
55+
console.log('同步文件到:', toFilePath)
7456
fs.copySync(filePath, toFilePath)
7557
}
7658

77-
// const toFilePath = path.join(to,name)
78-
// const basename = path.basename(toFilePath, path.extname(toFilePath))
79-
// console.log(basename)
80-
// console.log(filePath.split(dirname).pop())
81-
// console.log(path.join(to,'..',basename+'.nvue'))
8259
})
83-
// changedFiles 格式为键值对,键为发生变化的文件路径。
8460
callback();
8561
});
8662
}

src/components/uni-grid-item/uni-grid-item.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
.uni-grid-item {
7373
/* #ifndef APP-NVUE */
7474
height: 100%;
75-
display: flex;
75+
display: flex;
7676
/* #endif */
7777
}
7878
@@ -83,7 +83,7 @@
8383
/* #endif */
8484
position: relative;
8585
flex: 1;
86-
flex-direction: column;
86+
flex-direction: column;
8787
// justify-content: center;
8888
// align-items: center;
8989
}
File renamed without changes.

src/pages/nvue/index/index.nvue

+9-3
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,17 @@
154154
},
155155
methods: {
156156
goDetailPage(e) {
157-
let path = e.url
157+
let path = e.url
158+
// #ifdef APP-NVUE
158159
uni.navigateTo({
159160
url: `/pages/nvue/${path}/${path}`
160-
})
161-
return false
161+
})
162+
// #endif
163+
// #ifndef APP-NVUE
164+
uni.navigateTo({
165+
url: `/pages/nvue/${path}/${path}`
166+
})
167+
// #endif
162168
}
163169
}
164170
}

src/pages/vue/index/index.vue

+10-4
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,17 @@
154154
},
155155
methods: {
156156
goDetailPage(e) {
157-
let path = e.url
157+
let path = e.url
158+
// #ifdef APP-NVUE
158159
uni.navigateTo({
159-
url: `/pages/vue/${path}/${path}`
160-
})
161-
return false
160+
url: `/pages/nvue/${path}/${path}`
161+
})
162+
// #endif
163+
// #ifndef APP-NVUE
164+
uni.navigateTo({
165+
url: `/pages/nvue/${path}/${path}`
166+
})
167+
// #endif
162168
}
163169
}
164170
}

vue.config.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
const path = require('path')
3-
const CopyPlugin = require('./plugin')
3+
const CopyPlugin = require('./plugin')
44

55
module.exports = {
6-
// configureWebpack: {
7-
// plugins: [new CopyPlugin({
8-
// from:path.join(__dirname,'src/pages'),
9-
// to:path.join(__dirname,'src/copy')
10-
// })]
11-
// }
12-
}
6+
configureWebpack: {
7+
plugins: [new CopyPlugin({
8+
from:path.join(__dirname,'src/pages/vue'),
9+
to:path.join(__dirname,'src/pages/nvue')
10+
})]
11+
}
12+
}

0 commit comments

Comments
 (0)