release v2.0.0 #4

Merged
crimsen merged 481 commits from develop into master 2024-01-18 15:15:08 +00:00
6 changed files with 13 additions and 28 deletions
Showing only changes of commit ba485f87c5 - Show all commits

View File

@ -45,8 +45,7 @@ export default boot<Store<StateInterface>>(({ Vue, store, router }) => {
query: { redirect: router.currentRoute.fullPath } query: { redirect: router.currentRoute.fullPath }
}); });
} else if (e.response && e.response.status == 401) { } else if (e.response && e.response.status == 401) {
if (router.currentRoute.name !== 'login') if (router.currentRoute.name !== 'login') return store.dispatch('session/clearCurrent');
return store.dispatch('session/clearCurrent');
} }
} }
return Promise.reject(error); return Promise.reject(error);

View File

@ -3,9 +3,7 @@ import { formatDateTime } from 'src/utils/datetime';
export default boot(({ Vue }) => { export default boot(({ Vue }) => {
Vue.filter('date', formatDateTime); Vue.filter('date', formatDateTime);
Vue.filter('time', (date: Date, seconds = false) => Vue.filter('time', (date: Date, seconds = false) => formatDateTime(date, false, true, seconds));
formatDateTime(date, false, true, seconds)
);
Vue.filter('dateTime', (date: Date, seconds = false, weekday = false) => Vue.filter('dateTime', (date: Date, seconds = false, weekday = false) =>
formatDateTime(date, true, true, seconds, weekday) formatDateTime(date, true, true, seconds, weekday)
); );

View File

@ -24,15 +24,14 @@ export default boot<Store<StateInterface>>(({ router, store }) => {
// Check if special permissions are required // Check if special permissions are required
if ( if (
to.matched.every((record: RouteRecord) => { to.matched.every((record: RouteRecord) => {
if (!('meta' in record) || !('permissions' in record.meta)) if (!('meta' in record) || !('permissions' in record.meta)) return true;
return true;
if (record.meta) { if (record.meta) {
if ((<{ permissions: FG.Permission[] }>record.meta).permissions) { if ((<{ permissions: FG.Permission[] }>record.meta).permissions) {
return (<{ permissions: FG.Permission[] }>( return (<{ permissions: FG.Permission[] }>record.meta).permissions.every(
record.meta (permission: string) => {
)).permissions.every((permission: string) => {
return store.state.user.currentPermissions.includes(permission); return store.state.user.currentPermissions.includes(permission);
}); }
);
} }
} }
}) })
@ -42,11 +41,7 @@ export default boot<Store<StateInterface>>(({ router, store }) => {
next({ name: 'login', query: { redirect: to.fullPath } }); next({ name: 'login', query: { redirect: to.fullPath } });
} }
} else { } else {
if ( if (to.name == 'login' && store.state.user.currentUser && !to.params['logout']) {
to.name == 'login' &&
store.state.user.currentUser &&
!to.params['logout']
) {
// Called login while already logged in // Called login while already logged in
void next({ name: 'dashboard' }); void next({ name: 'dashboard' });
} else { } else {

View File

@ -10,9 +10,7 @@ const plugin: FG_Plugin.Plugin = {
requiredModules: ['User'], requiredModules: ['User'],
requiredBackendModules: ['balance'], requiredBackendModules: ['balance'],
version: '0.0.1', version: '0.0.1',
store: new Map<string, Module<BalanceInterface, StateInterface>>([ store: new Map<string, Module<BalanceInterface, StateInterface>>([['balance', balance]]),
['balance', balance]
]),
widgets: [ widgets: [
{ {
priority: 0, priority: 0,

View File

@ -25,15 +25,13 @@ const state: UserStateInterface = {
roles: [], roles: [],
permissions: [], permissions: [],
currentUser: loadUserFromLocalStorage(), currentUser: loadUserFromLocalStorage(),
currentPermissions: currentPermissions: SessionStorage.getItem<FG.Permission[]>('currentPermissions') || [],
SessionStorage.getItem<FG.Permission[]>('currentPermissions') || [],
loading: 0 loading: 0
}; };
const mutations: MutationTree<UserStateInterface> = { const mutations: MutationTree<UserStateInterface> = {
setCurrentUser(state, data: FG.User) { setCurrentUser(state, data: FG.User) {
if (typeof data.birthday === 'string') if (typeof data.birthday === 'string') data.birthday = new Date(data.birthday);
data.birthday = new Date(data.birthday);
SessionStorage.set('currentUser', data); SessionStorage.set('currentUser', data);
state.currentUser = data; state.currentUser = data;
}, },

View File

@ -1,10 +1,7 @@
import { Store } from 'vuex'; import { Store } from 'vuex';
import { StateInterface } from 'src/store'; import { StateInterface } from 'src/store';
export function hasPermission( export function hasPermission(permission: string, store: Store<StateInterface>) {
permission: string,
store: Store<StateInterface>
) {
return store.state.user.currentPermissions.includes(permission); return store.state.user.currentPermissions.includes(permission);
} }