Skip to content

Commit

Permalink
feat: 自动接收设备地址
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Dec 3, 2023
1 parent 0fe6009 commit 7ad6ddd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { toValidURL } from '@/utils/check';
import { errorTry, errorWrap } from '@/utils/error';
import { createRouter, createWebHistory } from 'vue-router';

const router = createRouter({
Expand Down Expand Up @@ -34,6 +36,16 @@ const router = createRouter({
path: '/device',
name: 'device',
component: () => import('@/views/DevicePage.vue'),
beforeEnter(to, from, next) {
const u = toValidURL(String(to.query.url));
if (u) {
localStorage.setItem('device_link', u.origin);
const query = { ...to.query };
delete query.url;
return next({ ...to, query });
}
next();
},
},
{
path: '/404',
Expand Down

0 comments on commit 7ad6ddd

Please sign in to comment.