fix: 修复部分已知的问题

This commit is contained in:
xlsea 2025-05-09 17:37:24 +08:00
parent f946d05815
commit 7a27cdb3ab
6 changed files with 24 additions and 27 deletions

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
import { computed } from 'vue';
import type { VNode } from 'vue';
import { useBoolean, useLoading } from '@sa/hooks';
import { useBoolean } from '@sa/hooks';
import { useAuthStore } from '@/store/modules/auth';
import { useRouterPush } from '@/hooks/common/router';
import { useSvgIcon } from '@/hooks/common/icon';
@ -16,9 +16,6 @@ const authStore = useAuthStore();
const { routerPushByKey, toLogin } = useRouterPush();
const { SvgIconVNode } = useSvgIcon();
// 使 useBoolean
const { loading: avatarLoading, endLoading: endAvatarLoading } = useLoading(true);
// 使 useBoolean
const { bool: avatarError, setTrue: setError, setFalse: clearError } = useBoolean(false);
function loginOrRegister() {
@ -26,12 +23,10 @@ function loginOrRegister() {
}
function handleAvatarLoad() {
endAvatarLoading();
clearError();
}
function handleAvatarError() {
endAvatarLoading();
setError();
}
@ -95,22 +90,20 @@ function handleDropdown(key: DropdownKey) {
</NButton>
<NDropdown v-else placement="bottom" trigger="click" :options="options" @select="handleDropdown">
<div class="flex cursor-pointer items-center rounded-md px-2 py-1 transition-colors duration-300 hover:bg-black/6">
<NSpin :show="avatarLoading">
<div class="flex items-center gap-2" :class="{ 'opacity-50': avatarError }">
<NAvatar
v-if="authStore.userInfo.user?.avatar"
:size="24"
round
:src="authStore.userInfo.user?.avatar"
@load="handleAvatarLoad"
@error="handleAvatarError"
/>
<NAvatar v-else :size="32" round :src="defaultAvatar" @load="handleAvatarLoad" @error="handleAvatarError" />
<span class="max-w-120px truncate text-14px font-medium">
{{ authStore.userInfo.user?.nickName }}
</span>
</div>
</NSpin>
<div class="flex items-center gap-2" :class="{ 'opacity-50': avatarError }">
<NAvatar
v-if="authStore.userInfo.user?.avatar"
:size="24"
round
:src="authStore.userInfo.user?.avatar"
@load="handleAvatarLoad"
@error="handleAvatarError"
/>
<NAvatar v-else :size="32" round :src="defaultAvatar" @load="handleAvatarLoad" @error="handleAvatarError" />
<span class="max-w-120px truncate text-14px font-medium">
{{ authStore.userInfo.user?.nickName }}
</span>
</div>
</div>
</NDropdown>
</template>

View File

@ -13,7 +13,7 @@ export function fetchSocialAuthBinding(source: Api.System.SocialSource, tenantId
}
/** 解绑账户 */
export function fetchSocialAuthUnbinding(socialId: string) {
export function fetchSocialAuthUnbinding(socialId: CommonType.IdType) {
return request<string>({
url: `/auth/unlock/${socialId}`,
method: 'delete'

View File

@ -97,7 +97,9 @@ export const useRouteStore = defineStore(SetupStoreId.Route, () => {
// @ts-expect-error no query field
const query = route.query ? String(route.query) : undefined;
route.path = route.path.startsWith('//') ? route.path.substring(1) : route.path;
route.path = parent ? parent.path + route.path : route.path;
const name = humpToLine(route.path.substring(1).replace('/', '_'));
route.name = parent ? `${parent.name}_${name}` : name;
route.meta = route.meta ? route.meta : { title: route.name };

View File

@ -152,6 +152,8 @@ declare namespace Api {
/** social */
type Social = Common.CommonRecord<{
/** 主键 */
id: CommonType.IdType;
/** 用户ID */
userId: CommonType.IdType;
/** 租户ID */

View File

@ -30,8 +30,8 @@ const tenantOption = ref<SelectOption[]>([]);
const model: Api.Auth.PwdLoginForm = reactive({
tenantId: '000000',
username: '',
password: ''
username: 'admin',
password: 'admin123'
});
type RuleKey = Extract<keyof Api.Auth.PwdLoginForm, 'username' | 'password' | 'code' | 'tenantId'>;

View File

@ -34,7 +34,7 @@ async function bindSsoAccount(type: Api.System.SocialSource) {
}
/** 解绑SSO账户 */
async function unbindSsoAccount(socialId: string) {
async function unbindSsoAccount(socialId: CommonType.IdType) {
startBtnLoading();
const { error } = await fetchSocialAuthUnbinding(socialId);
if (!error) {
@ -83,7 +83,7 @@ function getSocial(key: string) {
type="error"
size="small"
:loading="btnLoading"
@click="unbindSsoAccount(socialList.find(s => s.source === source.key)?.authId || '')"
@click="unbindSsoAccount(getSocial(source.key)?.id || '')"
>
解绑
</NButton>