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 ...@@ -6,13 +6,12 @@ import store from './redux/store' // Redux --> store
import { Provider } from 'react-redux' // Redux --> Provider import { Provider } from 'react-redux' // Redux --> Provider
// import AUPop from "./components/AUPop/AUPop.jsx" // Redux --> AUPop // 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 import AUPop from "./pop/AUPopMobx/AUPopMobx.jsx" // Mobx --> AUPop
//此处为spark-cli动态生成 //此处为spark-cli动态生成
import PageHome from "./pages/PageHome/PageHome.jsx"; import PageHome from "./pages/PageHome/PageHome.jsx";
class App extends Component { class App extends Component {
// use redux type // use redux type
// render() { // render() {
// return ( // return (
...@@ -34,7 +33,7 @@ class App extends Component { ...@@ -34,7 +33,7 @@ class App extends Component {
{/* 页面 */} {/* 页面 */}
<PageHome /> <PageHome />
{/* 弹窗 */} {/* 弹窗 */}
<AUPop AUPopState={AUPopState.popArr} /> <AUPop AUPopState={AUPopState} />
</> </>
) )
} }
......
...@@ -4,6 +4,7 @@ import { AUPopState, popWatcher } from '../../pop/AUState.js' // Mobx --> AUStat ...@@ -4,6 +4,7 @@ import { AUPopState, popWatcher } from '../../pop/AUState.js' // Mobx --> AUStat
import popMap from '../PopMap.js' import popMap from '../PopMap.js'
import { observer } from 'mobx-react-lite' import { observer } from 'mobx-react-lite'
import { toJS } from "mobx";
import './AUPopMobx.less' import './AUPopMobx.less'
...@@ -96,6 +97,11 @@ class AUPopMobx extends Component { ...@@ -96,6 +97,11 @@ class AUPopMobx extends Component {
} }
} }
const AUPop = observer(({ AUPopState }) => <AUPopMobx popState={AUPopState} /> ) // export default observer(({ AUPopState }) => <AUPopMobx AUPopState={AUPopState} /> )
export default observer(({ AUPopState }) => {
export default AUPop console.log(AUPopState)
\ No newline at end of file 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' ...@@ -5,16 +5,19 @@ import { CONSO_START_mark, ConsoleStyleTitle, ConsoFunc } from './api/tools'
// useProxies: "never" // useProxies: "never"
// }) // })
class PopState { export class PopState {
nowShow nowShow
popArr popArr
aaa
constructor() { constructor() {
this.popArr = [] this.popArr = []
this.nowShow = '' this.nowShow = 0
this.aaa = arguments[0]
// makeAutoObservable(this) // makeAutoObservable(this)
makeAutoObservable(this, { makeAutoObservable(this, {
nowShow: observable, nowShow: observable,
popArr: observable,
addPop: action.bound, addPop: action.bound,
changePop: action.bound, changePop: action.bound,
computedPopArr: computed computedPopArr: computed
...@@ -23,12 +26,14 @@ class PopState { ...@@ -23,12 +26,14 @@ class PopState {
addPop = (data) => { addPop = (data) => {
console.log(`${CONSO_START_mark}\n addPop:`, ConsoleStyleTitle, data) console.log(`${CONSO_START_mark}\n addPop:`, ConsoleStyleTitle, data)
this.nowShow += 1
this.popArr.push(data) this.popArr.push(data)
} }
changePop = (data) => { changePop = (data) => {
console.log(`${CONSO_START_mark}\n changePop:`, ConsoleStyleTitle, data) console.log(`${CONSO_START_mark}\n changePop:`, ConsoleStyleTitle, this.popArr)
this.popArr = [data] this.nowShow += 1
// this.popArr = [data]
} }
get computedPopArr () { get computedPopArr () {
...@@ -36,8 +41,74 @@ class PopState { ...@@ -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 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 = () => { ...@@ -62,7 +62,6 @@ export const AupopCleanAll = () => {
} }
/** /**
* 获取弹窗数组 * 获取弹窗数组
*/ */
...@@ -70,3 +69,5 @@ export const AupopGetPopArr = () => { ...@@ -70,3 +69,5 @@ export const AupopGetPopArr = () => {
return [] return []
} }
// IntersectionObserver
...@@ -20,7 +20,7 @@ import AUPop from "./components/AUPop/AUPop.jsx" // Redux --> AUPop ...@@ -20,7 +20,7 @@ import AUPop from "./components/AUPop/AUPop.jsx" // Redux --> AUPop
import PageHome from "./pages/PageHome/PageHome.jsx"; import PageHome from "./pages/PageHome/PageHome.jsx";
class App extends Component { class App extends Component {
render() { render() {
return ( return (
<Provider store={store}> <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