UNPKG

fastlion-amis

Version:

一种MIS页面生成工具

44 lines (40 loc) 1.24 kB
import { Instance, types } from 'mobx-state-tree'; import { createObject, qsparse } from '../utils/helper'; import { ServiceStore } from './service'; export const RootStore = ServiceStore.named('RootStore') .props({ runtimeError: types.frozen(), runtimeErrorStack: types.frozen(), query: types.frozen() }) .views(self => ({ get downStream() { // query慢慢往里面安 if (self.query && self.data.__super) { self.data.__super['__query'] = self.query for (const key in self.query) { if (!self.data.__super[key]) { self.data.__super[key] = self.query[key] } } } return self.data; } })) .actions(self => ({ setRuntimeError(error: any, errorStack: any) { self.runtimeError = error; self.runtimeErrorStack = errorStack; }, updateLocation(location?: any) { const query = (location && location.query) || (location && location.search && qsparse(location.search.substring(1))) || (window.location.search && qsparse(window.location.search.substring(1))); self.query = query; } })); export type IRootStore = Instance<typeof RootStore>;