import {Context} from "koa";
import * as Router from 'koa-router';
import * as send from 'koa-send';
import pagesPathRoot from '../../../resources/pages/pages-root';
import * as path from "path";
let router: Router = new Router();
router.get(
"/simple/menu/:idWithPath+",
async (context: Context) =>
{
let relativePath: string = context.request.path.substring(
context.request.path.search(
context.params.idWithPath.split('/')[0]
) + context.params.idWithPath.split('/')[0].length
);
if (relativePath === "") relativePath = "/";
await send(
context, relativePath, {
root: path.join(pagesPathRoot, "simple/menu"),
index: "index.html"
}
);
console.log(pagesPathRoot);
}
);
export default router.routes();
网友评论