-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
186 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<mxfile host="65bd71144e"> | ||
<diagram id="GILjV6VJQhHbRAu13tSy" name="第 1 页"> | ||
<mxGraphModel dx="926" dy="619" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1169" pageHeight="827" math="0" shadow="0"> | ||
<root> | ||
<mxCell id="0"/> | ||
<mxCell id="1" parent="0"/> | ||
<mxCell id="8" style="edgeStyle=entityRelationEdgeStyle;rounded=0;sketch=1;orthogonalLoop=1;jettySize=auto;html=1;fontFamily=Comic Sans MS;fontSize=24;" edge="1" parent="1" source="2" target="5"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="9" style="edgeStyle=entityRelationEdgeStyle;rounded=0;sketch=1;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fontFamily=Comic Sans MS;fontSize=24;" edge="1" parent="1" source="2" target="6"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="10" style="edgeStyle=entityRelationEdgeStyle;rounded=0;sketch=1;orthogonalLoop=1;jettySize=auto;html=1;fontFamily=Comic Sans MS;fontSize=24;strokeWidth=3;" edge="1" parent="1" source="2" target="7"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="2" value="Router" style="rounded=1;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=4;hachureGap=8;hachureAngle=45;fillColor=#f8cecc;sketch=1;strokeColor=#b85450;fontStyle=1;fontFamily=Comic Sans MS;fontSize=24;" vertex="1" parent="1"> | ||
<mxGeometry x="420" y="210" width="120" height="60" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="4" style="edgeStyle=entityRelationEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fontFamily=Comic Sans MS;fontSize=24;sketch=1;strokeWidth=3;" edge="1" parent="1" source="3" target="2"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="3" value="AJAX<br>API" style="rounded=1;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=4;hachureGap=8;hachureAngle=45;fillColor=#e1d5e7;sketch=1;fontFamily=Comic Sans MS;fontSize=24;strokeColor=#9673a6;" vertex="1" parent="1"> | ||
<mxGeometry x="160" y="210" width="120" height="60" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="5" value="Route" style="ellipse;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=2;hachureGap=8;fillColor=#fff2cc;fillStyle=dots;sketch=1;fontFamily=Comic Sans MS;fontSize=24;strokeColor=#d6b656;" vertex="1" parent="1"> | ||
<mxGeometry x="640" y="110" width="120" height="60" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="6" value="Route" style="ellipse;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=2;hachureGap=8;fillColor=#fff2cc;fillStyle=dots;sketch=1;fontFamily=Comic Sans MS;fontSize=24;strokeColor=#d6b656;" vertex="1" parent="1"> | ||
<mxGeometry x="640" y="210" width="120" height="60" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="15" style="edgeStyle=elbowEdgeStyle;rounded=0;sketch=1;orthogonalLoop=1;jettySize=auto;elbow=vertical;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fontFamily=Comic Sans MS;fontSize=18;startArrow=diamond;startFill=1;strokeWidth=3;" edge="1" parent="1" source="7" target="11"> | ||
<mxGeometry relative="1" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="7" value="Route" style="ellipse;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=2;hachureGap=8;fillColor=#fff2cc;fillStyle=dots;sketch=1;fontFamily=Comic Sans MS;fontSize=24;strokeColor=#d6b656;" vertex="1" parent="1"> | ||
<mxGeometry x="640" y="300" width="120" height="60" as="geometry"/> | ||
</mxCell> | ||
<mxCell id="14" style="edgeStyle=elbowEdgeStyle;rounded=0;sketch=1;orthogonalLoop=1;jettySize=auto;html=1;fontFamily=Comic Sans MS;fontSize=18;startArrow=diamond;startFill=1;elbow=vertical;entryX=0.5;entryY=1;entryDx=0;entryDy=0;strokeWidth=3;" edge="1" parent="1" source="11" target="3"> | ||
<mxGeometry relative="1" as="geometry"> | ||
<mxPoint x="720" y="460" as="targetPoint"/> | ||
<Array as="points"> | ||
<mxPoint x="580" y="410"/> | ||
</Array> | ||
</mxGeometry> | ||
</mxCell> | ||
<mxCell id="11" value="Main<br>&nbsp;Callback" style="rhombus;whiteSpace=wrap;html=1;strokeWidth=2;fillWeight=-1;hachureGap=8;fillStyle=cross-hatch;fillColor=#d5e8d4;sketch=1;fontFamily=Comic Sans MS;fontSize=18;strokeColor=#82b366;" vertex="1" parent="1"> | ||
<mxGeometry x="860" y="300" width="120" height="60" as="geometry"/> | ||
</mxCell> | ||
</root> | ||
</mxGraphModel> | ||
</diagram> | ||
</mxfile> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@konghayao/fake-server", | ||
"version": "0.0.1", | ||
"description": "", | ||
"main": "parseURL.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"path-to-regexp": "^6.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* @license | ||
* Copyright 2021 KonghaYao 江夏尧 <dongzhongzhidong@qq.com> | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
/** | ||
* The Regexps were copied from Purl (A JavaScript URL parser) v2.3.1 | ||
* which developed and maintained by Mark Perkins, mark@allmarkedup.com | ||
* Source repository: https://github.com/allmarkedup/jQuery-URL-Parser | ||
* Licensed under an MIT-style license. | ||
*/ | ||
const key = [ | ||
"source", | ||
"protocol", | ||
"authority", | ||
"userInfo", | ||
"user", | ||
"password", | ||
"host", | ||
"port", | ||
"relative", | ||
"path", | ||
"directory", | ||
"file", | ||
"query", | ||
"hash", | ||
]; // keys available to query | ||
const parser = { | ||
//less intuitive, more accurate to the specs | ||
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, | ||
// more intuitive, fails on relative paths and deviates from specs | ||
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, | ||
}; | ||
|
||
function parseUri(url, strictMode = false) { | ||
const res = parser[strictMode ? "strict" : "loose"].exec(decodeURI(url)); | ||
|
||
const uri = key.reduce((col, keyName, index) => { | ||
col[keyName] = res[index] || ""; | ||
return col; | ||
}, {}); | ||
|
||
// build query and hash parameters | ||
uri.queryParams = parseString(uri.query); | ||
|
||
// compile a 'base' domain attribute | ||
uri["base"] = uri.host | ||
? (uri.protocol ? uri.protocol + "://" + uri.host : uri.host) + | ||
(uri.port ? ":" + uri.port : "") | ||
: ""; | ||
|
||
return uri; | ||
} | ||
|
||
function parseString(queryString) { | ||
return String(queryString) | ||
.split(/&|;/) | ||
.reduce(function (collection, pair) { | ||
try { | ||
pair = decodeURIComponent(pair.replace(/\+/g, " ")); | ||
} catch (e) { | ||
// ignore | ||
} | ||
let [key, value] = pair.split(/=/g); | ||
collection[key] = value; | ||
return collection; | ||
}, {}); | ||
} | ||
|
||
export function parseURL(url, strictMode = false) { | ||
return parseUri(url, strictMode); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { map } from 'rxjs/operators'; | ||
import { of } from 'rxjs'; | ||
import { pathToRegexp } from 'path-to-regexp'; | ||
function normalizeRouters(Routers) { | ||
return Object.entries(Routers); | ||
} | ||
function createRegexp(path, config = {}) { | ||
return pathToRegexp(path, [], config); | ||
} | ||
class Route { | ||
constructor(path, cb) {} | ||
use(plugin) {} | ||
} | ||
class Router { | ||
constructor(Routers) { | ||
this.#RouterMap = new Map(normalizeRouters(Routers)); | ||
} | ||
#RouterMap; | ||
#RouteMatchers = []; | ||
addRoute(path, mainCallback) { | ||
const route = new Route(path, mainCallback); | ||
const pathRegexp = createRegexp(path); | ||
this.#RouterMap.set(pathRegexp, route); | ||
this.#RouteMatchers.push(pathRegexp); | ||
return route; | ||
} | ||
deleteRouter() {} | ||
enableRouter() {} | ||
disableRouter() {} | ||
receiveMessage(path, message) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.