fix: bugs

pull/2/head
xingyu 2022-08-03 17:23:12 +08:00
parent 3b441fd7ef
commit af2b1eb25f
7 changed files with 32 additions and 40 deletions

View File

@ -8,7 +8,7 @@ const props = defineProps({
required: true
},
value: {
type: [String, Number] as PropType<string | number>,
type: [String, Number, Boolean] as PropType<string | number | boolean>,
required: true
}
})

View File

@ -11,6 +11,7 @@ import { useDictStoreWithOut } from '@/store/modules/dict'
import { useUserStoreWithOut } from '@/store/modules/user'
import { listSimpleDictDataApi } from '@/api/system/dict/dict.data'
import { isRelogin } from '@/config/axios'
import { getInfoApi } from '@/api/login'
const { start, done } = useNProgress()
@ -52,6 +53,8 @@ router.beforeEach(async (to, from, next) => {
}
if (userStore.getRoles.length === 0) {
isRelogin.show = true
const res = await getInfoApi()
await userStore.setUserInfoAction(res)
isRelogin.show = false
// 后端过滤菜单
await permissionStore.generateRoutes()

View File

@ -27,9 +27,6 @@ export const useUserStore = defineStore({
nickname: ''
}
}),
persist: {
enabled: true
},
getters: {
getPermissions(): string[] {
return this.permissions

View File

@ -21,19 +21,17 @@ import {
getPassword,
getTenantName
} from '@/utils/auth'
import { useUserStore } from '@/store/modules/user'
import { usePermissionStore } from '@/store/modules/permission'
import { useRouter } from 'vue-router'
import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
import { Icon } from '@/components/Icon'
import { LoginStateEnum, useLoginState, useFormValid } from './useLogin'
import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router'
import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { Verify } from '@/components/Verifition'
const { currentRoute, addRoute, push } = useRouter()
const { currentRoute, push } = useRouter()
const permissionStore = usePermissionStore()
const userStore = useUserStore()
const formLogin = ref()
const { validForm } = useFormValid(formLogin)
const { setLoginState, getLoginState } = useLoginState()
@ -111,23 +109,11 @@ const handleLogin = async (params) => {
loginData.loginForm.captchaVerification = params.captchaVerification
const res = await LoginApi.loginApi(loginData.loginForm)
setToken(res)
const userInfo = await LoginApi.getInfoApi()
await userStore.setUserInfoAction(userInfo)
await getRoutes()
loginLoading.value = false
}
//
const getRoutes = async () => {
//
await permissionStore.generateRoutes()
permissionStore.getAddRouters.forEach((route) => {
addRoute(route as RouteRecordRaw) // 访
})
if (!redirect.value) {
redirect.value = '/'
}
push({ path: redirect.value || permissionStore.addRouters[0].path })
loginLoading.value = false
}
//

View File

@ -5,13 +5,12 @@ import LoginFormTitle from './LoginFormTitle.vue'
import { ElForm, ElFormItem, ElInput, ElRow, ElCol, ElMessage } from 'element-plus'
import { useI18n } from '@/hooks/web/useI18n'
import { required } from '@/utils/formRules'
import { getTenantIdByNameApi, sendSmsCodeApi, smsLoginApi, getInfoApi } from '@/api/login'
import { getTenantIdByNameApi, sendSmsCodeApi, smsLoginApi } from '@/api/login'
import { useCache } from '@/hooks/web/useCache'
import { usePermissionStore } from '@/store/modules/permission'
import { useRouter } from 'vue-router'
import { setToken } from '@/utils/auth'
import { useUserStore } from '@/store/modules/user'
import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router'
import type { RouteLocationNormalizedLoaded } from 'vue-router'
import { useLoginState, LoginStateEnum, useFormValid } from './useLogin'
const formSmsLogin = ref()
const { validForm } = useFormValid(formSmsLogin)
@ -21,9 +20,8 @@ const iconHouse = useIcon({ icon: 'ep:house' })
const iconCellphone = useIcon({ icon: 'ep:cellphone' })
const iconCircleCheck = useIcon({ icon: 'ep:circle-check' })
const { wsCache } = useCache()
const userStore = useUserStore()
const permissionStore = usePermissionStore()
const { currentRoute, addRoute, push } = useRouter()
const { currentRoute, push } = useRouter()
const loginLoading = ref(false)
const { t } = useI18n()
@ -102,24 +100,16 @@ const signIn = async () => {
await smsLoginApi(smsVO.loginSms)
.then(async (res) => {
setToken(res?.token)
const userInfo = await getInfoApi()
await userStore.setUserInfoAction(userInfo)
getRoutes()
if (!redirect.value) {
redirect.value = '/'
}
push({ path: redirect.value || permissionStore.addRouters[0].path })
})
.catch(() => {})
.finally(() => {
loginLoading.value = false
})
}
//
const getRoutes = async () => {
//
await permissionStore.generateRoutes()
permissionStore.getAddRouters.forEach((route) => {
addRoute(route as RouteRecordRaw) // 访
})
push({ path: redirect.value || permissionStore.addRouters[0].path })
}
</script>
<template>
<el-form

View File

@ -135,7 +135,7 @@ defineExpose({
:name="item.filePath"
:key="item.filePath"
>
<el-button text style="float: right" @click="copy(item.code)">
<el-button link style="float: right" @click="copy(item.code)">
{{ t('common.copy') }}
</el-button>
<pre>{{ item.code }}</pre>

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref } from 'vue'
import { ref, unref } from 'vue'
import dayjs from 'dayjs'
import { ElMessage, ElUpload, UploadInstance, UploadRawFile, ElImage } from 'element-plus'
import { useTable } from '@/hooks/web/useTable'
@ -8,6 +8,7 @@ import type { FileVO } from '@/api/infra/fileList/types'
import { allSchemas } from './fileList.data'
import * as FileApi from '@/api/infra/fileList'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { useClipboard } from '@vueuse/core'
const { t } = useI18n() //
@ -76,6 +77,18 @@ const handleDetail = (row: FileVO) => {
dialogTitle.value = t('action.detail')
dialogVisible.value = true
}
// ========== ==========
const handleCopy = async (text: string) => {
const { copy, copied, isSupported } = useClipboard({ source: text })
if (!isSupported) {
ElMessage.error(t('common.copyError'))
} else {
await copy()
if (unref(copied)) {
ElMessage.success(t('common.copySuccess'))
}
}
}
// ========== ==========
getList()
</script>
@ -117,6 +130,9 @@ getList()
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template>
<template #action="{ row }">
<el-button link type="primary" @click="handleCopy(row.url)">
<Icon icon="ep:copy-document" class="mr-1px" /> {{ t('common.copy') }}
</el-button>
<el-button link type="primary" @click="handleDetail(row)">
<Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
</el-button>