Skip to content

Commit 00a48bd

Browse files
authored
Merge pull request #378 from personball/master
Fix vue template when add more routers in appRouters
2 parents 087151c + c8b56eb commit 00a48bd

File tree

8 files changed

+99
-112
lines changed

8 files changed

+99
-112
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Core/Localization/SourceFiles/AbpProjectName-zh-Hans.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<text name="UserNameOrEmail" value="用户名或邮箱地址" />
1616
<text name="Password" value="密码" />
1717
<text name="RememberMe" value="记住我" />
18+
<text name="ForgetPassword" value="忘记密码"/>
19+
<text name="NotSelected" value="未选"/>
20+
<text name="ChangeTenant" value="更改租户"/>
21+
<text name="LeaveEmptyToSwitchToHost" value="留空以切换到Host"/>
1822
<text name="LogIn" value="登录" />
1923
<text name="LoginFailed" value="登录失败!" />
2024
<text name="AppName" >AbpProjectName</text>

vue/src/lib/util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Vue from 'vue';
2-
import {FieldType,CompareType,Filter} from '../store/entities/filter'
32
import appconst from './appconst'
43
class Util{
54
abp:any=window.abp;

vue/src/router/router.ts

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,59 @@
11
declare global {
2+
interface RouterMeta {
3+
title: string;
4+
}
5+
interface Router {
6+
path: string;
7+
name: string;
8+
icon?: string;
9+
permission?: string;
10+
meta?: RouterMeta;
11+
component: any;
12+
children?: Array<Router>;
13+
}
214
interface System {
3-
import (request: string): Promise<any>
15+
import(request: string): Promise<any>
416
}
517
var System: System
618
}
719
import login from '../views/login.vue'
820
import home from '../views/home/home.vue'
921
import main from '../views/main.vue'
22+
1023
export const locking = {
1124
path: '/locking',
1225
name: 'locking',
1326
component: () => import('../components/lockscreen/components/locking-page.vue')
1427
};
15-
export const loginRouter = {
28+
export const loginRouter: Router = {
1629
path: '/',
1730
name: 'login',
1831
meta: {
1932
title: 'LogIn'
2033
},
21-
component:()=>import('../views/login.vue')
34+
component: () => import('../views/login.vue')
2235
};
23-
export const otherRouters={
24-
path:'/main',
25-
name:'main',
26-
permission:'',
27-
meta:{title:'ManageMenu'},
28-
component:main,
29-
children:[
30-
{path: 'home', meta:{title:'HomePage'}, name: 'home', component:()=>import('../views/home/home.vue')}
36+
export const otherRouters: Router = {
37+
path: '/main',
38+
name: 'main',
39+
permission: '',
40+
meta: { title: 'ManageMenu' },
41+
component: main,
42+
children: [
43+
{ path: 'home', meta: { title: 'HomePage' }, name: 'home', component: () => import('../views/home/home.vue') }
3144
]
3245
}
33-
export const appRouters=[{
34-
path:'/setting',
35-
name:'setting',
36-
permission:'',
37-
meta:{title:'ManageMenu'},
38-
icon:'&#xe68a;',
39-
component:main,
40-
children:[
41-
{path: 'user',permission:'Pages.Users', meta:{title:'Users'}, name: 'user', component:()=>import('../views/setting/user/user.vue')},
42-
{path: 'role',permission:'Pages.Roles', meta:{title:'Roles'}, name: 'role', component:()=>import('../views/setting/role/role.vue')},
43-
{path: 'tenant',permission:'Pages.Tenants', meta:{title:'Tenants'}, name: 'tenant', component:()=>import('../views/setting/tenant/tenant.vue')}
46+
export const appRouters: Array<Router> = [{
47+
path: '/setting',
48+
name: 'setting',
49+
permission: '',
50+
meta: { title: 'ManageMenu' },
51+
icon: '&#xe68a;',
52+
component: main,
53+
children: [
54+
{ path: 'user', permission: 'Pages.Users', meta: { title: 'Users' }, name: 'user', component: () => import('../views/setting/user/user.vue') },
55+
{ path: 'role', permission: 'Pages.Roles', meta: { title: 'Roles' }, name: 'role', component: () => import('../views/setting/role/role.vue') },
56+
{ path: 'tenant', permission: 'Pages.Tenants', meta: { title: 'Tenants' }, name: 'tenant', component: () => import('../views/setting/tenant/tenant.vue') }
4457
]
4558
}]
4659
export const routers = [

vue/src/store/entities/filter.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

vue/src/store/modules/app.ts

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
import { appRouters,otherRouters} from '../../router/router'
1+
import { appRouters, otherRouters } from '../../router/router'
22
import Util from '../../lib/util';
33
import Vue from 'vue';
4-
import {Store,Module,ActionContext} from 'vuex'
4+
import { Store, Module, ActionContext } from 'vuex'
55
import Vuex from 'vuex';
6-
import ajax from '../../lib/ajax'
6+
import ajax from '../../lib/ajax'
77
import appconst from '../../lib/appconst'
88
Vue.use(Vuex);
9-
interface AppState{
10-
cachePage:Array<any>;
11-
lang:string;
9+
interface AppState {
10+
cachePage: Array<any>;
11+
lang: string;
1212
isFullScreen: boolean;
1313
openedSubmenuArr: Array<any>;
1414
menuTheme: string;
1515
themeColor: string,
16-
pageOpenedList:Array<any>;
16+
pageOpenedList: Array<any>;
1717
currentPageName: string;
18-
currentPath:Array<any>;
18+
currentPath: Array<any>;
1919
menuList: Array<any>;
20-
routers:Array<any>;
20+
routers: Array<any>;
2121
tagsList: Array<any>;
2222
messageCount: number;
23-
dontCache:Array<any>;
24-
noticeList:Array<any>;
23+
dontCache: Array<any>;
24+
noticeList: Array<any>;
2525
}
26-
class AppModule implements Module<AppState,any>{
27-
namespaced=true;
28-
state={
26+
class AppModule implements Module<AppState, any>{
27+
namespaced = true;
28+
state = {
2929
cachePage: [],
3030
lang: '',
3131
isFullScreen: false,
32-
openedSubmenuArr: [],
32+
openedSubmenuArr: [],
3333
menuTheme: 'dark',
3434
themeColor: '',
3535
pageOpenedList: [{
36-
meta:{title: 'HomePage'},
36+
meta: { title: 'HomePage' },
3737
path: '',
3838
name: 'home'
3939
}],
4040
currentPageName: '',
4141
currentPath: [
4242
{
43-
meta:{title: 'HomePage'},
43+
meta: { title: 'HomePage' },
4444
path: '',
4545
name: 'home'
4646
}
@@ -53,35 +53,34 @@ class AppModule implements Module<AppState,any>{
5353
tagsList: [...otherRouters.children],
5454
messageCount: 0,
5555
dontCache: [],
56-
noticeList:[{read:false,type:0,title:'First notice',description:'One day ago'},{read:false,type:1},{read:false,type:0,title:'Second notice',description:'One month ago'}]
56+
noticeList: [{ read: false, type: 0, title: 'First notice', description: 'One day ago' }, { read: false, type: 1 }, { read: false, type: 0, title: 'Second notice', description: 'One month ago' }]
5757
};
58-
mutations= {
59-
logout(state:AppState){
58+
mutations = {
59+
logout(state: AppState) {
6060
localStorage.clear();
6161
sessionStorage.clear();
6262
},
63-
setTagsList (state:AppState, list:Array<any>) {
63+
setTagsList(state: AppState, list: Array<any>) {
6464
state.tagsList.push(...list);
6565
},
66-
updateMenulist (state:AppState) {
67-
let menuList:Array<any> = [];
66+
updateMenulist(state: AppState) {
67+
let menuList: Array<Router> = [];
6868
appRouters.forEach((item, index) => {
6969
if (item.permission !== undefined) {
70-
let childrenArr = [];
71-
childrenArr = item.children.filter(child => {
72-
let childany=child as any;
73-
if (childany.permission !== undefined) {
74-
if(Util.abp.auth.hasPermission(childany.permission)){
70+
let hasPermissionMenuArr: Array<Router> = [];
71+
hasPermissionMenuArr = item.children.filter(child => {
72+
if (child.permission !== undefined) {
73+
if (Util.abp.auth.hasPermission(child.permission)) {
7574
return child;
76-
}
75+
}
7776
} else {
7877
return child;
7978
}
8079
});
81-
if(childrenArr.length>0){
82-
item.children=childrenArr;
80+
if (hasPermissionMenuArr.length > 0) {
81+
item.children = hasPermissionMenuArr;
8382
menuList.push(item);
84-
}
83+
}
8584
} else {
8685
if (item.children.length === 1) {
8786
menuList.push(item);
@@ -99,13 +98,13 @@ class AppModule implements Module<AppState,any>{
9998
});
10099
state.menuList = menuList;
101100
},
102-
changeMenuTheme (state:AppState, theme:string) {
101+
changeMenuTheme(state: AppState, theme: string) {
103102
state.menuTheme = theme;
104103
},
105-
changeMainTheme (state:AppState, mainTheme:string) {
104+
changeMainTheme(state: AppState, mainTheme: string) {
106105
state.themeColor = mainTheme;
107106
},
108-
addOpenSubmenu (state:AppState, name:any) {
107+
addOpenSubmenu(state: AppState, name: any) {
109108
let hasThisName = false;
110109
let isEmpty = false;
111110
if (name.length === 0) {
@@ -118,26 +117,26 @@ class AppModule implements Module<AppState,any>{
118117
state.openedSubmenuArr.push(name);
119118
}
120119
},
121-
closePage (state:AppState, name:any) {
120+
closePage(state: AppState, name: any) {
122121
state.cachePage.forEach((item, index) => {
123122
if (item === name) {
124123
state.cachePage.splice(index, 1);
125124
}
126125
});
127126
},
128-
initCachepage (state:AppState) {
127+
initCachepage(state: AppState) {
129128
if (localStorage.cachePage) {
130129
state.cachePage = JSON.parse(localStorage.cachePage);
131130
}
132131
},
133-
removeTag (state:AppState, name:string) {
132+
removeTag(state: AppState, name: string) {
134133
state.pageOpenedList.map((item, index) => {
135134
if (item.name === name) {
136135
state.pageOpenedList.splice(index, 1);
137136
}
138137
});
139138
},
140-
pageOpenedList (state:AppState, get:any) {
139+
pageOpenedList(state: AppState, get: any) {
141140
let openedPage = state.pageOpenedList[get.index];
142141
if (get.argu) {
143142
openedPage.argu = get.argu;
@@ -148,12 +147,12 @@ class AppModule implements Module<AppState,any>{
148147
state.pageOpenedList.splice(get.index, 1, openedPage);
149148
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
150149
},
151-
clearAllTags (state:AppState) {
150+
clearAllTags(state: AppState) {
152151
state.pageOpenedList.splice(1);
153152
state.cachePage.length = 0;
154153
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
155154
},
156-
clearOtherTags (state:AppState, vm:Vue) {
155+
clearOtherTags(state: AppState, vm: Vue) {
157156
let currentName = vm.$route.name;
158157
let currentIndex = 0;
159158
state.pageOpenedList.forEach((item, index) => {
@@ -173,34 +172,34 @@ class AppModule implements Module<AppState,any>{
173172
state.cachePage = newCachepage;
174173
localStorage.pageOpenedList = JSON.stringify(state.pageOpenedList);
175174
},
176-
setOpenedList (state:AppState) {
175+
setOpenedList(state: AppState) {
177176
state.pageOpenedList = localStorage.pageOpenedList ? JSON.parse(localStorage.pageOpenedList) : [otherRouters.children[0]];
178177
},
179-
setCurrentPath (state:AppState, pathArr:Array<any>) {
178+
setCurrentPath(state: AppState, pathArr: Array<any>) {
180179
state.currentPath = pathArr;
181180
},
182-
setCurrentPageName (state:AppState, name:string) {
181+
setCurrentPageName(state: AppState, name: string) {
183182
state.currentPageName = name;
184183
},
185-
clearOpenedSubmenu (state:AppState) {
184+
clearOpenedSubmenu(state: AppState) {
186185
state.openedSubmenuArr.length = 0;
187186
},
188-
increateTag (state:AppState, tagObj:any) {
187+
increateTag(state: AppState, tagObj: any) {
189188
if (!Util.oneOf(tagObj.name, state.dontCache)) {
190189
state.cachePage.push(tagObj.name);
191190
localStorage.cachePage = JSON.stringify(state.cachePage);
192191
}
193192
state.pageOpenedList.push(tagObj);
194193
}
195194
}
196-
actions={
197-
async login(content:ActionContext<AppState,any>,payload:any){
198-
let rep=await ajax.post("/api/TokenAuth/Authenticate",payload.data);
195+
actions = {
196+
async login(content: ActionContext<AppState, any>, payload: any) {
197+
let rep = await ajax.post("/api/TokenAuth/Authenticate", payload.data);
199198
var tokenExpireDate = payload.data.rememberMe ? (new Date(new Date().getTime() + 1000 * rep.data.result.expireInSeconds)) : undefined;
200-
Util.abp.auth.setToken(rep.data.result.accessToken,tokenExpireDate);
201-
Util.abp.utils.setCookieValue(appconst.authorization.encrptedAuthTokenName,rep.data.result.encryptedAccessToken,tokenExpireDate,Util.abp.appPath)
199+
Util.abp.auth.setToken(rep.data.result.accessToken, tokenExpireDate);
200+
Util.abp.utils.setCookieValue(appconst.authorization.encrptedAuthTokenName, rep.data.result.encryptedAccessToken, tokenExpireDate, Util.abp.appPath)
202201
},
203202
}
204203
}
205-
const appModule=new AppModule();
204+
const appModule = new AppModule();
206205
export default appModule;

vue/src/views/setting/role/role.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@
3838
</template>
3939
<script lang="ts">
4040
import { Component, Vue,Inject, Prop,Watch } from 'vue-property-decorator';
41-
import Util from '../../../lib/util'
42-
import AbpBase from '../../../lib/abpbase'
43-
import {FieldType,Filter,CompareType} from '../../../store/entities/filter'
44-
import PageRequest from '../../../store/entities/page-request'
41+
import Util from '@/lib/util'
42+
import AbpBase from '@/lib/abpbase'
43+
import PageRequest from '@/store/entities/page-request'
4544
import CreateRole from './create-role.vue'
4645
import EditRole from './edit-role.vue'
4746

vue/src/views/setting/tenant/tenant.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@
4343
</template>
4444
<script lang="ts">
4545
import { Component, Vue,Inject, Prop,Watch } from 'vue-property-decorator';
46-
import Util from '../../../lib/util'
47-
import AbpBase from '../../../lib/abpbase'
48-
import {FieldType,Filter,CompareType} from '../../../store/entities/filter'
49-
import PageRequest from '../../../store/entities/page-request'
46+
import Util from '@/lib/util'
47+
import AbpBase from '@/lib/abpbase'
48+
import PageRequest from '@/store/entities/page-request'
5049
import CreateTenant from './create-tenant.vue'
5150
import EditTenant from './edit-tenant.vue'
5251

vue/src/views/setting/user/user.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@
4848
</template>
4949
<script lang="ts">
5050
import { Component, Vue,Inject, Prop,Watch } from 'vue-property-decorator';
51-
import Util from '../../../lib/util'
52-
import AbpBase from '../../../lib/abpbase'
53-
import {FieldType,Filter,CompareType} from '../../../store/entities/filter'
54-
import PageRequest from '../../../store/entities/page-request'
51+
import Util from '@/lib/util'
52+
import AbpBase from '@/lib/abpbase'
53+
import PageRequest from '@/store/entities/page-request'
5554
import CreateUser from './create-user.vue'
5655
import EditUser from './edit-user.vue'
5756
class PageUserRequest extends PageRequest{

0 commit comments

Comments
 (0)