当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript mithril.route函数代码示例

本文整理汇总了TypeScript中mithril.route函数的典型用法代码示例。如果您正苦于以下问题:TypeScript route函数的具体用法?TypeScript route怎么用?TypeScript route使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了route函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: initializeRouter

export function initializeRouter() {
  route.prefix('');

  const container = document.querySelector('#container');
  route(container, '/', {
    '/': { onmatch: getRooms, render: HomePage }
  });
}
开发者ID:vdsabev,项目名称:betahaus-sofia-office-manager,代码行数:8,代码来源:router.ts

示例2:

        pubsub.on('connected', connection => {
            document.body.className =
                'theme--' + (connection.settings().theme || 'dark-orange')

            connected = true
            document.title =
                'Gandalf - connected to ' + connection.settings().name
            m.route('/sql/' + connection.settings().name)
        })
开发者ID:jakobrun,项目名称:gandalf,代码行数:9,代码来源:main.ts

示例3: default

					},
					"Click me"
				)
			];
		}
	};
}

///////////////////////////////////////////////////////////
//
// Test that all are mountable components
//
m.route(document.body, '/', {
	'/comp0': comp0,
	'/comp1': comp1,
	'/comp2': comp2,
	'/comp3': comp3,
	'/comp4': comp4,
	'/comp5': comp5
});

///////////////////////////////////////////////////////////
//
// Concise module example with default export
//
interface Attrs {
	name: string;
}

export default (): Component<Attrs, {}> => {
	const count = 0;
	return {
开发者ID:DenisCarriere,项目名称:DefinitelyTyped,代码行数:32,代码来源:test-factory-component.ts

示例4: pagify

      for (const page of adminPages) {
        if (window.authorizer.hasAccess(page, 2)) {
          m.route.set(`/admin/${page}`);
          return null;
        }
      }
      return null;
    }
  };
  return component;
}

m.route(document.body, "/overview", {
  "/login": pagify("login", loginPage),
  "/overview": pagify("overview", overviewPage),
  "/devices": pagify("devices", devicesPage),
  "/devices/:id": pagify("devices", devicePage),
  "/faults": pagify("faults", faultsPage),
  "/admin": redirectAdminPage(),
  "/admin/presets": pagify("presets", presetsPage),
  "/admin/provisions": pagify("provisions", provisionsPage),
  "/admin/virtualParameters": pagify(
    "virtualParameters",
    virtualParametersPage
  ),
  "/admin/files": pagify("files", filesPage),
  "/admin/config": pagify("config", configPage),
  "/admin/users": pagify("users", usersPage),
  "/admin/permissions": pagify("permissions", permissionsPage)
});
开发者ID:zaidka,项目名称:genieacs,代码行数:30,代码来源:app.ts

示例5: createSplitter

    .then(settings => {
        const splitter = createSplitter(m)

        const pubsub = new EventEmitter()
        createGlobalShortcuts(pubsub)
        createCommitControl(pubsub)
        const errorHandler = createErrorHandler(m)
        const loginModule = createLoginModule(m, pubsub, connect, settings)
        const actions = createActions(m, pubsub, createPopupmenu)
        const tableSearch = createTableSearch(m, pubsub, createPopupmenu)
        const statusbar = createStatusbar(m, pubsub)
        const editor = createEditor(m, pubsub, CodeMirror)
        const result = createResult(m, pubsub)
        const editConnection = createEditConnection(m, pubsub, settings)
        const bookmarkModule = createBookmarkModel(
            m,
            fs,
            pubsub,
            editor,
            createPopupmenu
        )
        const historyModule = createHistoryView(
            m,
            pubsub,
            createPopupmenu,
            getHistoryModel
        )
        const columnsPrompt = createColumnsPrompt(
            m,
            editor,
            getTables,
            pubsub,
            createPopupmenu
        )
        let connected = false

        window.addEventListener(
            'beforeunload',
            () => {
                pubsub.emit('disconnect')
            },
            false
        )

        createExecuter(pubsub, editor, m)
        createSchemaHandler(fs, pubsub)
        createSqlHint(pubsub, editor, getTables, CodeMirror)

        pubsub.on('new-window', () => {
            console.log('emit new-window')
            ipcRenderer.send('new-window')
        })

        pubsub.on('connected', connection => {
            document.body.className =
                'theme--' + (connection.settings().theme || 'dark-orange')

            connected = true
            document.title =
                'Gandalf - connected to ' + connection.settings().name
            m.route('/sql/' + connection.settings().name)
        })

        function Controller() {
            const connName = m.route.param('conn')
            if (!connected && connName) {
                const connSettings = settings.connections.find(
                    c => c.name === connName
                )
                if (connSettings && connSettings.host === 'hsql:inmemory') {
                    console.log('reconnect to hsql:inmemory!!')
                    connect(
                        { host: connSettings.host },
                        connSettings
                    ).then(connection => {
                        pubsub.emit('connected', connection)
                    })
                } else {
                    pubsub.emit('login')
                }
            }
        }
        const sqlModule = {
            controller: Controller,
            view() {
                return [
                    loginModule.view(),
                    editor.view(),
                    splitter(),
                    result.view(),
                    statusbar.view(),
                    actions.view(),
                    tableSearch.view(),
                    bookmarkModule.view(),
                    historyModule.view(),
                    columnsPrompt.view(),
                    errorHandler.view(),
                    editConnection.view(),
                ]
            },
//.........这里部分代码省略.........
开发者ID:jakobrun,项目名称:gandalf,代码行数:101,代码来源:main.ts

示例6: m

	const root = window.document.createElement("div");
	m.render(root, m("div"));
	console.assert(root.childNodes.length === 1);
}

{
	const root = window.document.createElement("div");
	m.mount(root, { view: () => m("div") });
	console.assert(root.childNodes.length === 1);
	console.assert(root.firstChild!.nodeName === "DIV");
}

{
	const root = window.document.createElement("div");
	m.route(root, "/a", {
		"/a": { view: () => m("div") }
	});

	setTimeout(() => {
		console.assert(root.childNodes.length === 1);
		console.assert(root.firstChild!.nodeName === "DIV");
	}, FRAME_BUDGET);
}

{
	const root = window.document.createElement("div");
	m.route.prefix("#");
	m.route(root, "/a", {
		"/a": { view: () => m("div") }
	});
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:30,代码来源:test-api.ts

示例7: BudgetContext

        m.startComputation();
        context.loadData(data);
        m.endComputation();
    });
} else {
    let storedBudgetData = localStorage.getItem(budgetDataKey) || "";
    context = new BudgetContext(storedBudgetData);
}

let menu = new Menu.MenuComponent([
    new Menu.BasicMenuItem(new RegExp("expenses"), `/expenses/${DF.formatDateForUrl(moment())}`, "Expenses"),
    new Menu.BasicMenuItem(new RegExp("rates"), `/rates/${DF.formatDateForUrl(moment())}`, "Rates"),
    new Menu.DropdownMenuItem(new RegExp("summary"), "Summary",
        [
            new Menu.BasicMenuItem(new RegExp("weekly"), `/summary/${DF.formatDateForUrl(moment())}/weekly`, "Weekly"),
            new Menu.BasicMenuItem(new RegExp("categories"), `/summary/${DF.formatDateForUrl(moment())}/categories`, "By Category"),
        ])
]);

let pageModel = new PageModel(root, context, fileDialog, fileNameKey, storedFileName);

let page = Page.bind(null, pageModel, menu);

m.route.mode = "search";

m.route(root, `/expenses/${DF.formatDateForUrl(moment())}`, {
    "/rates/:date": new page(new RatesComponent(context)),
    "/expenses/:date": new page(new ExpenseComponent(context)),
    "/summary/:date/:type": new page(new SummaryComponent(context)),
    "/categories": new page(new CategoryComponent(context))
});
开发者ID:AlexanderLindsay,项目名称:dailybudgeteer,代码行数:31,代码来源:start.ts


注:本文中的mithril.route函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。