-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redux Support #93
Redux Support #93
Conversation
@@ -113,7 +113,7 @@ export default { | |||
return matchs.replace(/[^\.\w'"]([a-z_\$][\w\d\._\$]*)/ig, (match, word, n) => { | |||
//console.log(matchs + '------' + match + '--' + word + '--' + n); | |||
let char = match[0]; | |||
let tmp = word.match(/^(\w+)(.*)/); | |||
let tmp = word.match(/^([\w$]+)(.*)/); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是 $ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为对 redux 处理中默认加入了 $state 这个 computed 的值方便直接使用。
而且加上 $ 也是合理的吧,毕竟从变量上来说是可以有$的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对,所以是\s
, 上面的comment竟然被转义了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是在 [] 中的,应该不用转义就好
packages/wepy-cli/src/wepy.js
Outdated
|
||
if (!config.empty) { | ||
dependencies.push('wepy-com-toast'); | ||
dependencies.push('wepy-async-function'); | ||
} | ||
if (useRedux) { | ||
dependencies.push.apply(dependencies, reduxDeps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependencies = dependencies.concat(reduxDeps)
packages/wepy-cli/src/wepy.js
Outdated
|
||
if (!config.empty) { | ||
dependencies.push('wepy-com-toast'); | ||
dependencies.push('wepy-async-function'); | ||
} | ||
if (useRedux) { | ||
dependencies.push.apply(dependencies, reduxDeps); | ||
} | ||
|
||
if (config.lint) { | ||
devDependencies.push.apply(devDependencies, eslintDeps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
packages/wepy-cli/src/wepy.js
Outdated
@@ -94,6 +106,21 @@ let generateProject = (name, config) => { | |||
// --on-lint will not copy eslint config | |||
if (['.editorconfig', '.eslintignore', '.eslintrc'].indexOf(file) !== -1 && !config.lint) | |||
return; | |||
// 只有 redux 的项目拷贝 redux 相关内容 且做替换 | |||
const unReduxFiles = ['src/app.wpy', 'src/components/counter.wpy']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在非--redux
模式下,生成的template中并没有排除 redux 模式的相关文件,这样会导致普通模式下文件再次build报错。
const store = configStore() | ||
setStore(store) | ||
|
||
export default class extends wepy.app { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
示例不够充分,目前只有一个counter
组件使用了redux。需要再加入一个组件,看不同组件中的同一数据流是否存在问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个在我的原始demo是有的,但后来我思考的是 counter 是多个实例的,所以也算是“多”个组件了
@@ -128,6 +128,7 @@ export default { | |||
}, | |||
|
|||
npmHack (filename, code) { | |||
code = code.replace(/process\.env\.NODE_ENV/g, JSON.stringify(process.env.NODE_ENV)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这一句是处理哪里的内容的呢?能否加个注释。
add redux (默认全家桶:redux-actions redux-promise)
#89