Commit ad390144 authored by AU-PRO's avatar AU-PRO

add new code

parent 9b23e470
......@@ -6,13 +6,12 @@ import store from './redux/store' // Redux --> store
import { Provider } from 'react-redux' // Redux --> Provider
// import AUPop from "./components/AUPop/AUPop.jsx" // Redux --> AUPop
import { AUPopState, popWatcher } from './pop/AUState.js' // Mobx --> AUState
import { AUPopState } from './pop/AUState.js' // Mobx --> AUState
import AUPop from "./pop/AUPopMobx/AUPopMobx.jsx" // Mobx --> AUPop
//此处为spark-cli动态生成
import PageHome from "./pages/PageHome/PageHome.jsx";
class App extends Component {
// use redux type
// render() {
// return (
......@@ -34,7 +33,7 @@ class App extends Component {
{/* 页面 */}
<PageHome />
{/* 弹窗 */}
<AUPop AUPopState={AUPopState.popArr} />
<AUPop AUPopState={AUPopState} />
</>
)
}
......
......@@ -4,6 +4,7 @@ import { AUPopState, popWatcher } from '../../pop/AUState.js' // Mobx --> AUStat
import popMap from '../PopMap.js'
import { observer } from 'mobx-react-lite'
import { toJS } from "mobx";
import './AUPopMobx.less'
......@@ -96,6 +97,11 @@ class AUPopMobx extends Component {
}
}
const AUPop = observer(({ AUPopState }) => <AUPopMobx popState={AUPopState} /> )
export default AUPop
\ No newline at end of file
// export default observer(({ AUPopState }) => <AUPopMobx AUPopState={AUPopState} /> )
export default observer(({ AUPopState }) => {
console.log(AUPopState)
return (
<AUPopMobx pop={toJS(AUPopState.popArr)}/>
// <span>Seconds passed: {AUPopState.nowShow}</span>
)
})
\ No newline at end of file
......@@ -5,16 +5,19 @@ import { CONSO_START_mark, ConsoleStyleTitle, ConsoFunc } from './api/tools'
// useProxies: "never"
// })
class PopState {
export class PopState {
nowShow
popArr
aaa
constructor() {
this.popArr = []
this.nowShow = ''
this.nowShow = 0
this.aaa = arguments[0]
// makeAutoObservable(this)
makeAutoObservable(this, {
nowShow: observable,
popArr: observable,
addPop: action.bound,
changePop: action.bound,
computedPopArr: computed
......@@ -23,12 +26,14 @@ class PopState {
addPop = (data) => {
console.log(`${CONSO_START_mark}\n addPop:`, ConsoleStyleTitle, data)
this.nowShow += 1
this.popArr.push(data)
}
changePop = (data) => {
console.log(`${CONSO_START_mark}\n changePop:`, ConsoleStyleTitle, data)
this.popArr = [data]
console.log(`${CONSO_START_mark}\n changePop:`, ConsoleStyleTitle, this.popArr)
this.nowShow += 1
// this.popArr = [data]
}
get computedPopArr () {
......@@ -36,8 +41,74 @@ class PopState {
}
}
export const AUPopState = new PopState()
export const AUPopState = new PopState(100)
export const popWatcher = autorun(() => {
autorun(() => {
console.log(`${CONSO_START_mark}\n AUTORUN::: this.popArr:`, ConsoleStyleTitle, AUPopState.popArr)
return AUPopState.popArr
})
\ No newline at end of file
})
// ready for mobx can't use
// author: 沈阳楠
// export const EventDispatcher = (function () {
// function EventDispatcher() {
// this._events = {}
// }
// EventDispatcher.ins = function () {
// if (EventDispatcher.ins == null) {
// EventDispatcher.ins = new EventDispatcher()
// }
// return EventDispatcher.ins
// }()
// EventDispatcher.prototype.dispatch = function (eventName, data) {
// for (let i in this._events[eventName]) {
// var _event = this._events[eventName][i]
// _event.callback.call(_event.target.context, data)
// }
// }
// EventDispatcher.prototype.addEventListener = function (eventName, callback, target) {
// var _events = this._events[eventName]
// if (_events) {
// _events.push({
// callback: callback,
// target: target
// })
// } else {
// this._events[eventName] = [{
// callback: callback,
// target: target
// }]
// }
// }
// EventDispatcher.prototype.removeEventListener = function (eventName, callback, target) {
// for (let i = this._events[eventName].length - 1; i >= 0; i--) {
// var _event = this._events[eventName][i]
// if (_event.callback == callback && _event.target == target) {
// this._events[eventName].splice(i, 1)
// }
// }
// }
// EventDispatcher.prototype.removeAllEventListener = function (eventName) {
// this._events[eventName] = null
// }
// return EventDispatcher
// }())
// EventDispatcher.ins.addEventListener("aaaa", this.isStart, this)
// EventDispatcher.ins.addEventListener("aaaa", () => {
// EventDispatcher.ins.removeEventListener("aaaa", this.isStart, this)
// }, this)
// EventDispatcher.ins.dispatch("aaaa", 3213123)
\ No newline at end of file
......@@ -62,7 +62,6 @@ export const AupopCleanAll = () => {
}
/**
* 获取弹窗数组
*/
......@@ -70,3 +69,5 @@ export const AupopGetPopArr = () => {
return []
}
// IntersectionObserver
......@@ -20,7 +20,7 @@ import AUPop from "./components/AUPop/AUPop.jsx" // Redux --> AUPop
import PageHome from "./pages/PageHome/PageHome.jsx";
class App extends Component {
render() {
return (
<Provider store={store}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment