Browse Source

Try router support

master
Forks 8 years ago
parent
commit
e405b3dc02
5 changed files with 37 additions and 21 deletions
  1. +0
    -1
      index.html
  2. +2
    -1
      main.ts
  3. +1
    -10
      package-lock.json
  4. +30
    -0
      src/index.tsx
  5. +4
    -9
      tsconfig.json

src/index.html → index.html View File

@ -21,7 +21,6 @@
</head>
<body>
Foo
<div id="root"></div>
<script>
require("./src");

+ 2
- 1
main.ts View File

@ -1,3 +1,4 @@
import { start } from "mammoth";
import * as path from "path";
start();
start(path.join(__dirname, "index.html"));

+ 1
- 10
package-lock.json View File

@ -4,14 +4,6 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@types/electron": {
"version": "1.6.10",
"resolved": "https://registry.npmjs.org/@types/electron/-/electron-1.6.10.tgz",
"integrity": "sha512-MOCVyzIwkBEloreoCVrTV108vSf8fFIJPsGruLCoAoBZdxtnJUqKA4lNonf/2u1twSjAspPEfmEheC+TLm/cMw==",
"requires": {
"electron": "1.7.10"
}
},
"@types/history": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/@types/history/-/history-4.6.2.tgz",
@ -813,9 +805,8 @@
}
},
"mammoth": {
"version": "git+ssh://git@192.168.1.5:forks/mammoth-lib.git#4d84cd231c82ffd56bce590838cf54294bbf5cf5",
"version": "git+ssh://git@192.168.1.5:forks/mammoth-lib.git#c42cb53ed52ffe5b52b384f460f9d84860dcdb8d",
"requires": {
"@types/electron": "1.6.10",
"@types/history": "4.6.2",
"@types/node": "8.5.5",
"@types/react": "16.0.34",


+ 30
- 0
src/index.tsx View File

@ -0,0 +1,30 @@
import { createStore, history, pushState } from "mammoth/app";
import * as ReactDOM from "react-dom";
import * as React from "react";
import { ConnectedRouter } from "react-router-redux";
import { Provider } from "react-redux";
import { Route } from "react-router";
const store = createStore({
});
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}>
<>
<Route exact path="/" component={Root} />
<Route exact path="/login" component={Login} />
</>
</ConnectedRouter>
</Provider>,
document.getElementById("root"),
)
function Root() {
return <div><a onClick={() => pushState("/login")}>Goto login</a></div>;
}
function Login() {
return <div><a onClick={() => pushState("/")}>Goto root</a></div>;
}

+ 4
- 9
tsconfig.json View File

@ -1,12 +1,12 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"jsx": "react", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
@ -17,21 +17,18 @@
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */
"strict": true /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
@ -41,13 +38,11 @@
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */


Loading…
Cancel
Save