show domain page for all user

1. show ドメイン管理
2. hide ドメイン適用
3. force redirect to domain page if user no domain exist
This commit is contained in:
xue jiahao
2024-11-06 21:56:14 +08:00
parent 9d853944cb
commit e362c80e98
4 changed files with 38 additions and 71 deletions

View File

@@ -4,6 +4,7 @@
tag="a" tag="a"
:target="target?target:'_blank'" :target="target?target:'_blank'"
:href="link" :href="link"
:disable="disable"
v-if="!isSeparator" v-if="!isSeparator"
> >
<q-item-section <q-item-section
@@ -33,6 +34,7 @@ export interface EssentialLinkProps {
icon?: string; icon?: string;
isSeparator?: boolean; isSeparator?: boolean;
target?:string; target?:string;
disable?:boolean;
} }
withDefaults(defineProps<EssentialLinkProps>(), { withDefaults(defineProps<EssentialLinkProps>(), {
caption: '', caption: '',

View File

@@ -22,6 +22,8 @@
<div v-if="isAdmin()"> <div v-if="isAdmin()">
<EssentialLink v-for="link in adminLinks" :key="link.title" v-bind="link" /> <EssentialLink v-for="link in adminLinks" :key="link.title" v-bind="link" />
</div> </div>
<EssentialLink v-for="link in domainLinks" :key="link.title" v-bind="link" />
</q-list> </q-list>
</q-drawer> </q-drawer>
@@ -32,7 +34,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { onMounted } from 'vue'; import { onMounted, computed } from 'vue';
import EssentialLink, { EssentialLinkProps } from 'components/EssentialLink.vue'; import EssentialLink, { EssentialLinkProps } from 'components/EssentialLink.vue';
import DomainSelector from 'components/DomainSelector.vue'; import DomainSelector from 'components/DomainSelector.vue';
import { useAuthStore } from 'stores/useAuthStore'; import { useAuthStore } from 'stores/useAuthStore';
@@ -45,14 +47,16 @@ const essentialLinks: EssentialLinkProps[] = [
caption: '設計書から導入する', caption: '設計書から導入する',
icon: 'home', icon: 'home',
link: '/', link: '/',
target: '_self' target: '_self',
disable: !authStore.hasDomain,
}, },
{ {
title: 'フローエディター', title: 'フローエディター',
caption: 'イベントを設定する', caption: 'イベントを設定する',
icon: 'account_tree', icon: 'account_tree',
link: '/#/FlowChart', link: '/#/FlowChart',
target: '_self' target: '_self',
disable: !authStore.hasDomain,
}, },
// { // {
// title: '条件エディター', // title: '条件エディター',
@@ -83,58 +87,23 @@ const essentialLinks: EssentialLinkProps[] = [
// link:'https://cybozu.dev/ja/kintone/docs/', // link:'https://cybozu.dev/ja/kintone/docs/',
// icon:'help_outline' // icon:'help_outline'
// }, // },
];
const domainLinks: EssentialLinkProps[] = [
{
title: 'ドメイン管理',
caption: 'kintoneのドメイン設定',
icon: 'domain',
link: '/#/domain',
target: '_self'
},
// { // {
// title:'', // title: 'ドメイン適用',
// isSeparator:true // caption: 'ユーザー使用可能なドメインの設定',
// icon: 'assignment_ind',
// link: '/#/userDomain',
// target: '_self'
// }, // },
// {
// title: 'Docs',
// caption: 'quasar.dev',
// icon: 'school',
// link: 'https://quasar.dev'
// },
// {
// title: 'Icons',
// caption: 'Material Icons',
// icon: 'insert_emoticon',
// link: 'https://fonts.google.com/icons?selected=Material+Icons:insert_emoticon:'
// },
// {
// title: 'Github',
// caption: 'github.com/quasarframework',
// icon: 'code',
// link: 'https://github.com/quasarframework'
// },
// {
// title: 'Discord Chat Channel',
// caption: 'chat.quasar.dev',
// icon: 'chat',
// link: 'https://chat.quasar.dev'
// },
// {
// title: 'Forum',
// caption: 'forum.quasar.dev',
// icon: 'record_voice_over',
// link: 'https://forum.quasar.dev'
// },
// {
// title: 'Twitter',
// caption: '@quasarframework',
// icon: 'rss_feed',
// link: 'https://twitter.quasar.dev'
// },
// {
// title: 'Facebook',
// caption: '@QuasarFramework',
// icon: 'public',
// link: 'https://facebook.quasar.dev'
// },
// {
// title: 'Quasar Awesome',
// caption: 'Community Quasar projects',
// icon: 'favorite',
// link: 'https://awesome.quasar.dev'
// }
]; ];
const adminLinks: EssentialLinkProps[] = [ const adminLinks: EssentialLinkProps[] = [
@@ -145,20 +114,6 @@ const adminLinks: EssentialLinkProps[] = [
link: '/#/user', link: '/#/user',
target: '_self' target: '_self'
}, },
{
title: 'ドメイン管理',
caption: 'kintoneのドメイン設定',
icon: 'domain',
link: '/#/domain',
target: '_self'
},
{
title: 'ドメイン適用',
caption: 'ユーザー使用可能なドメインの設定',
icon: 'assignment_ind',
link: '/#/userDomain',
target: '_self'
},
] ]
const version = process.env.version; const version = process.env.version;

View File

@@ -47,6 +47,13 @@ export default route(function (/* { store, ssrContext } */) {
authStore.returnUrl = to.fullPath; authStore.returnUrl = to.fullPath;
return '/login'; return '/login';
} }
// redirect to domain setting page if no domain exist
const domainPages = [...publicPages, '/domain'];
if (!authStore.hasDomain && !domainPages.includes(to.path)) {
authStore.returnUrl = to.fullPath;
return '/domain';
}
}); });
return routerInstance; return routerInstance;
}); });

View File

@@ -33,6 +33,9 @@ export const useAuthStore = defineStore('auth', {
toggleLeftDrawer(): boolean { toggleLeftDrawer(): boolean {
return this.LeftDrawer; return this.LeftDrawer;
}, },
hasDomain(): boolean {
return this.currentDomain.id === null;
}
}, },
actions: { actions: {
toggleLeftMenu() { toggleLeftMenu() {
@@ -60,11 +63,11 @@ export const useAuthStore = defineStore('auth', {
} }
}, },
async getCurrentDomain(): Promise<IDomainInfo> { async getCurrentDomain(): Promise<IDomainInfo> {
const activedomain = await api.get(`api/activedomain`); const activedomain = (await api.get(`api/activedomain`))?.data;
return { return {
id: activedomain.data.id, id: activedomain?.id,
domainName: activedomain.data.name, domainName: activedomain?.name,
kintoneUrl: activedomain.data.url, kintoneUrl: activedomain?.url,
}; };
}, },
async getUserDomains(): Promise<IDomainInfo[]> { async getUserDomains(): Promise<IDomainInfo[]> {