update: convert js to ts
This commit is contained in:
parent
80f9a724df
commit
71605b426d
|
@ -8,6 +8,6 @@
|
|||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import SvgIcon from '@/components/SvgIcon';// svg component
|
||||
|
||||
import.meta.globEager('./svg/*.svg');
|
||||
|
||||
export default SvgIcon;
|
5
src/icons/index.ts
Normal file
5
src/icons/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import SvgIcon from '@/components/SvgIcon/index.vue';// svg component
|
||||
|
||||
import.meta.glob('./svg/*.svg', { eager: true });
|
||||
|
||||
export default SvgIcon;
|
|
@ -7,7 +7,7 @@ import { setupStore } from './store';
|
|||
import '@/styles/index.scss';
|
||||
import SvgIcon from './icons'; // icon
|
||||
import './permission'; // permission control
|
||||
import vPermission from './directive/permission/index.js'; // permission control
|
||||
import vPermission from './directive/permission/index'; // permission control
|
||||
|
||||
const app = createApp(App);
|
||||
setupStore(app);
|
|
@ -37,7 +37,12 @@ router.beforeEach(async (to, from, next) => {
|
|||
try {
|
||||
// get user info
|
||||
// note: roles must be a object array! such as: ['admin'] or ,['developer','editor']
|
||||
const { roles } = await userStore().getInfo();
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const infoRes = await userStore().getInfo() as any;
|
||||
let roles = [];
|
||||
if (infoRes.roles) {
|
||||
roles = infoRes.roles;
|
||||
}
|
||||
|
||||
// generate accessible routes map based on roles
|
||||
const accessRoutes = await permissionStore().generateRoutes(roles);
|
||||
|
@ -53,7 +58,8 @@ router.beforeEach(async (to, from, next) => {
|
|||
// hack method to ensure that addRoutes is complete
|
||||
// set the replace: true, so the navigation will not leave a history record
|
||||
next({ ...to, replace: true });
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (error: any) {
|
||||
// remove token and go to login page to re-login
|
||||
await userStore().resetToken();
|
||||
ElMessage.error(error.message || 'Has Error');
|
|
@ -1,8 +1,7 @@
|
|||
import { createPinia, acceptHMRUpdate } from 'pinia';
|
||||
import type { StoreDefinition } from 'pinia';
|
||||
// https://webpack.js.org/guides/dependency-management/#requirecontext
|
||||
const modulesFiles = import.meta.globEager('./modules/*.ts');
|
||||
|
||||
const modulesFiles = import.meta.glob('./modules/*.ts', { eager: true });
|
||||
// console.log('modulesFiles=', modulesFiles);
|
||||
|
||||
// you do not need `import app from './modules/app'`
|
||||
|
|
|
@ -5,7 +5,7 @@ import router, { resetRouter } from '@/router';
|
|||
import tagsViewStore from './tagsView';
|
||||
import permissionStore from './permission';
|
||||
|
||||
interface IUserState {
|
||||
export interface IUserState {
|
||||
token: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
|
|
Loading…
Reference in New Issue
Block a user