redirect done

This commit is contained in:
Jesse-Ma
2023-03-14 14:21:23 +08:00
parent fbb2c4064c
commit b86cf176dd
3 changed files with 80 additions and 29 deletions

View File

@@ -4,7 +4,7 @@ import EditNote from "@/views/EditNote.vue";
import ViewNote from "@/views/ViewNote.vue";
import ErrorRoute from "@/views/ErrorRoute.vue";
import ErrorNote from "@/views/ErrorNote.vue";
import { getKeyMeta, getNoteMeta } from "@/api/note";
import { getNoteMeta } from "@/api/note";
import { getStoreKey } from "@/api/lock";
import storage from "@/libs/storage";
@@ -35,6 +35,7 @@ function getNoteView() {
let key = path.substring(1, path.length);
keyMeta = storage.session.getObject(key+".keyMeta");
if (keyMeta && keyMeta.key) {
key = keyMeta.key;
}
@@ -107,30 +108,7 @@ function getNoteView() {
return ErrorNote;
}
function getHomeRedirect() {
let path = location.pathname;
if (path != "/") {
return;
}
//setKeyMeta
keyMeta = getKeyMeta();
// server error
if (!keyMeta) {
errorMeta = 100006;
return "/error_"+errorMeta;
}
return "/" + keyMeta.key;
}
const routes = [
{
path: "/",
name: "home",
redirect: getHomeRedirect(),
},
{ path: "/error_:code([0-9]{6})", component: ErrorNote },
{
path: "/:name([a-z0-9]{10,20})",