2
0

初始化项目

This commit is contained in:
caiyuchao
2024-11-14 11:06:38 +08:00
parent 988b9e6799
commit 4ffac789e1
320 changed files with 34244 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<LookForward />
</template>
<style scoped></style>

View File

@@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<div>three</div>
</template>
<style scoped></style>

View File

@@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<div>two</div>
</template>
<style scoped></style>

View File

@@ -0,0 +1,24 @@
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { computed } from 'vue';
import { useRouterPush } from '@/hooks/common/router';
import { $t } from '@/locales';
const route = useRoute();
const { routerPushByKey } = useRouterPush();
const routeQuery = computed(() => JSON.stringify(route.query));
</script>
<template>
<div>
<LookForward>
<div>
<AButton @click="routerPushByKey('function_tab')">{{ $t('page.function.multiTab.backTab') }}</AButton>
<div class="py-24px">{{ $t('page.function.multiTab.routeParam') }}: {{ routeQuery }}</div>
</div>
</LookForward>
</div>
</template>
<style scoped></style>

View File

@@ -0,0 +1,30 @@
<script setup lang="ts">
import { $t } from '@/locales';
async function logout() {
await fetchCustomBackendError('8888', $t('request.logoutMsg'));
}
async function logoutWithModal() {
await fetchCustomBackendError('7777', $t('request.logoutWithModalMsg'));
}
async function refreshToken() {
await fetchCustomBackendError('9999', $t('request.tokenExpired'));
}
</script>
<template>
<ASpace direction="vertical" :size="16">
<ACard :title="$t('request.logout')" :bordered="false" size="small" class="card-wrapper">
<AButton @click="logout">{{ $t('common.trigger') }}</AButton>
</ACard>
<ACard :title="$t('request.logoutWithModal')" :bordered="false" size="small" class="card-wrapper">
<AButton @click="logoutWithModal">{{ $t('common.trigger') }}</AButton>
</ACard>
<ACard :title="$t('request.refreshToken')" :bordered="false" size="small" class="card-wrapper">
<AButton @click="refreshToken">{{ $t('common.trigger') }}</AButton>
</ACard>
</ASpace>
</template>
<style scoped></style>

View File

@@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<LookForward />
</template>
<style scoped></style>

View File

@@ -0,0 +1,62 @@
<script setup lang="ts">
import { ref } from 'vue';
import { useRouterPush } from '@/hooks/common/router';
import { $t } from '@/locales';
import { useTabStore } from '@/store/modules/tab';
const tabStore = useTabStore();
const { routerPushByKey } = useRouterPush();
const tabLabel = ref('');
function changeTabLabel() {
tabStore.setTabLabel(tabLabel.value);
}
function resetTabLabel() {
tabStore.resetTabLabel();
}
</script>
<template>
<ASpace direction="vertical" :size="16">
<ACard :title="$t('page.function.tab.tabOperate.title')" :bordered="false" size="small" class="card-wrapper">
<ADivider orientation="left">{{ $t('page.function.tab.tabOperate.addTab') }}</ADivider>
<AButton @click="routerPushByKey('about')">{{ $t('page.function.tab.tabOperate.addTabDesc') }}</AButton>
<ADivider orientation="left">{{ $t('page.function.tab.tabOperate.closeTab') }}</ADivider>
<ASpace :size="16">
<AButton @click="tabStore.removeActiveTab">
{{ $t('page.function.tab.tabOperate.closeCurrentTab') }}
</AButton>
<AButton @click="tabStore.removeTabByRouteName('about')">
{{ $t('page.function.tab.tabOperate.closeAboutTab') }}
</AButton>
</ASpace>
<ADivider orientation="left">{{ $t('page.function.tab.tabOperate.addMultiTab') }}</ADivider>
<ASpace :size="16" wrap class="m-0!">
<AButton @click="routerPushByKey('function_multi-tab')">
{{ $t('page.function.tab.tabOperate.addMultiTabDesc1') }}
</AButton>
<AButton @click="routerPushByKey('function_multi-tab', { query: { a: '1' } })">
{{ $t('page.function.tab.tabOperate.addMultiTabDesc2') }}
</AButton>
</ASpace>
</ACard>
<ACard :title="$t('page.function.tab.tabTitle.title')" :bordered="false" size="small" class="card-wrapper">
<ADivider orientation="left">{{ $t('page.function.tab.tabTitle.changeTitle') }}</ADivider>
<AInputSearch
v-model:value="tabLabel"
:enter-button="$t('page.function.tab.tabTitle.change')"
class="max-w-240px"
@search="changeTabLabel"
/>
<ADivider orientation="left">{{ $t('page.function.tab.tabTitle.resetTitle') }}</ADivider>
<AButton @click="resetTabLabel">{{ $t('page.function.tab.tabTitle.reset') }}</AButton>
</ACard>
</ASpace>
</template>
<style scoped></style>

View File

@@ -0,0 +1,92 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useLoading } from '@sa/hooks';
import { $t } from '@/locales';
import { useAppStore } from '@/store/modules/app';
import { useAuthStore } from '@/store/modules/auth';
import { useAuth } from '@/hooks/business/auth';
const appStore = useAppStore();
const authStore = useAuthStore();
const { hasAuth } = useAuth();
const { loading, startLoading, endLoading } = useLoading();
type AccountKey = 'super' | 'admin' | 'user';
interface Account {
key: AccountKey;
label: string;
username: string;
password: string;
}
const accounts = computed<Account[]>(() => [
{
key: 'super',
label: $t('page.login.pwdLogin.superAdmin'),
username: 'Super',
password: '123456'
},
{
key: 'admin',
label: $t('page.login.pwdLogin.admin'),
username: 'Admin',
password: '123456'
},
{
key: 'user',
label: $t('page.login.pwdLogin.user'),
username: 'User',
password: '123456'
}
]);
const loginAccount = ref<AccountKey>('super');
async function handleToggleAccount(account: Account) {
loginAccount.value = account.key;
startLoading();
await authStore.login(account.username, account.password, false);
endLoading();
appStore.reloadPage();
}
</script>
<template>
<ASpace direction="vertical" :size="16">
<ACard :title="$t('route.function_toggle-auth')" :bordered="false" size="small" class="card-wrapper">
<ADescriptions layout="vertical" bordered size="small" :column="1">
<ADescriptionsItem :label="$t('page.manage.user.userRole')">
<ASpace>
<ATag v-for="role in authStore.userInfo.roles" :key="role">{{ role }}</ATag>
</ASpace>
</ADescriptionsItem>
<ADescriptionsItem ions-item :label="$t('page.function.toggleAuth.toggleAccount')">
<ASpace>
<AButton
v-for="account in accounts"
:key="account.key"
:loading="loading && loginAccount === account.key"
:disabled="loading && loginAccount !== account.key"
@click="handleToggleAccount(account)"
>
{{ account.label }}
</AButton>
</ASpace>
</ADescriptionsItem>
</ADescriptions>
</ACard>
<ACard :title="$t('page.function.toggleAuth.authHook')" :bordered="false" size="small" class="card-wrapper">
<ASpace>
<AButton v-if="hasAuth('B_CODE1')">{{ $t('page.function.toggleAuth.superAdminVisible') }}</AButton>
<AButton v-if="hasAuth('B_CODE2')">{{ $t('page.function.toggleAuth.adminVisible') }}</AButton>
<AButton v-if="hasAuth('B_CODE3')">
{{ $t('page.function.toggleAuth.adminOrUserVisible') }}
</AButton>
</ASpace>
</ACard>
</ASpace>
</template>
<style scoped></style>