Commit af2b1eb25f17bace718ca0de3db8a87c0b5c8ac5
1 parent
3b441fd7
fix: bugs
Showing
7 changed files
with
32 additions
and
40 deletions
yudao-ui-admin-vue3/src/components/DictTag/src/DictTag.vue
| @@ -8,7 +8,7 @@ const props = defineProps({ | @@ -8,7 +8,7 @@ const props = defineProps({ | ||
| 8 | required: true | 8 | required: true |
| 9 | }, | 9 | }, |
| 10 | value: { | 10 | value: { |
| 11 | - type: [String, Number] as PropType<string | number>, | 11 | + type: [String, Number, Boolean] as PropType<string | number | boolean>, |
| 12 | required: true | 12 | required: true |
| 13 | } | 13 | } |
| 14 | }) | 14 | }) |
yudao-ui-admin-vue3/src/router/index.ts
| @@ -11,6 +11,7 @@ import { useDictStoreWithOut } from '@/store/modules/dict' | @@ -11,6 +11,7 @@ import { useDictStoreWithOut } from '@/store/modules/dict' | ||
| 11 | import { useUserStoreWithOut } from '@/store/modules/user' | 11 | import { useUserStoreWithOut } from '@/store/modules/user' |
| 12 | import { listSimpleDictDataApi } from '@/api/system/dict/dict.data' | 12 | import { listSimpleDictDataApi } from '@/api/system/dict/dict.data' |
| 13 | import { isRelogin } from '@/config/axios' | 13 | import { isRelogin } from '@/config/axios' |
| 14 | +import { getInfoApi } from '@/api/login' | ||
| 14 | 15 | ||
| 15 | const { start, done } = useNProgress() | 16 | const { start, done } = useNProgress() |
| 16 | 17 | ||
| @@ -52,6 +53,8 @@ router.beforeEach(async (to, from, next) => { | @@ -52,6 +53,8 @@ router.beforeEach(async (to, from, next) => { | ||
| 52 | } | 53 | } |
| 53 | if (userStore.getRoles.length === 0) { | 54 | if (userStore.getRoles.length === 0) { |
| 54 | isRelogin.show = true | 55 | isRelogin.show = true |
| 56 | + const res = await getInfoApi() | ||
| 57 | + await userStore.setUserInfoAction(res) | ||
| 55 | isRelogin.show = false | 58 | isRelogin.show = false |
| 56 | // 后端过滤菜单 | 59 | // 后端过滤菜单 |
| 57 | await permissionStore.generateRoutes() | 60 | await permissionStore.generateRoutes() |
yudao-ui-admin-vue3/src/store/modules/user.ts
| @@ -27,9 +27,6 @@ export const useUserStore = defineStore({ | @@ -27,9 +27,6 @@ export const useUserStore = defineStore({ | ||
| 27 | nickname: '' | 27 | nickname: '' |
| 28 | } | 28 | } |
| 29 | }), | 29 | }), |
| 30 | - persist: { | ||
| 31 | - enabled: true | ||
| 32 | - }, | ||
| 33 | getters: { | 30 | getters: { |
| 34 | getPermissions(): string[] { | 31 | getPermissions(): string[] { |
| 35 | return this.permissions | 32 | return this.permissions |
yudao-ui-admin-vue3/src/views/Login/components/LoginForm.vue
| @@ -21,19 +21,17 @@ import { | @@ -21,19 +21,17 @@ import { | ||
| 21 | getPassword, | 21 | getPassword, |
| 22 | getTenantName | 22 | getTenantName |
| 23 | } from '@/utils/auth' | 23 | } from '@/utils/auth' |
| 24 | -import { useUserStore } from '@/store/modules/user' | ||
| 25 | import { usePermissionStore } from '@/store/modules/permission' | 24 | import { usePermissionStore } from '@/store/modules/permission' |
| 26 | import { useRouter } from 'vue-router' | 25 | import { useRouter } from 'vue-router' |
| 27 | import { useI18n } from '@/hooks/web/useI18n' | 26 | import { useI18n } from '@/hooks/web/useI18n' |
| 28 | import { required } from '@/utils/formRules' | 27 | import { required } from '@/utils/formRules' |
| 29 | import { Icon } from '@/components/Icon' | 28 | import { Icon } from '@/components/Icon' |
| 30 | import { LoginStateEnum, useLoginState, useFormValid } from './useLogin' | 29 | import { LoginStateEnum, useLoginState, useFormValid } from './useLogin' |
| 31 | -import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router' | 30 | +import type { RouteLocationNormalizedLoaded } from 'vue-router' |
| 32 | import { Verify } from '@/components/Verifition' | 31 | import { Verify } from '@/components/Verifition' |
| 33 | 32 | ||
| 34 | -const { currentRoute, addRoute, push } = useRouter() | 33 | +const { currentRoute, push } = useRouter() |
| 35 | const permissionStore = usePermissionStore() | 34 | const permissionStore = usePermissionStore() |
| 36 | -const userStore = useUserStore() | ||
| 37 | const formLogin = ref() | 35 | const formLogin = ref() |
| 38 | const { validForm } = useFormValid(formLogin) | 36 | const { validForm } = useFormValid(formLogin) |
| 39 | const { setLoginState, getLoginState } = useLoginState() | 37 | const { setLoginState, getLoginState } = useLoginState() |
| @@ -111,23 +109,11 @@ const handleLogin = async (params) => { | @@ -111,23 +109,11 @@ const handleLogin = async (params) => { | ||
| 111 | loginData.loginForm.captchaVerification = params.captchaVerification | 109 | loginData.loginForm.captchaVerification = params.captchaVerification |
| 112 | const res = await LoginApi.loginApi(loginData.loginForm) | 110 | const res = await LoginApi.loginApi(loginData.loginForm) |
| 113 | setToken(res) | 111 | setToken(res) |
| 114 | - const userInfo = await LoginApi.getInfoApi() | ||
| 115 | - await userStore.setUserInfoAction(userInfo) | ||
| 116 | - await getRoutes() | ||
| 117 | - loginLoading.value = false | ||
| 118 | -} | ||
| 119 | - | ||
| 120 | -// 获取路由 | ||
| 121 | -const getRoutes = async () => { | ||
| 122 | - // 后端过滤菜单 | ||
| 123 | - await permissionStore.generateRoutes() | ||
| 124 | - permissionStore.getAddRouters.forEach((route) => { | ||
| 125 | - addRoute(route as RouteRecordRaw) // 动态添加可访问路由表 | ||
| 126 | - }) | ||
| 127 | if (!redirect.value) { | 112 | if (!redirect.value) { |
| 128 | redirect.value = '/' | 113 | redirect.value = '/' |
| 129 | } | 114 | } |
| 130 | push({ path: redirect.value || permissionStore.addRouters[0].path }) | 115 | push({ path: redirect.value || permissionStore.addRouters[0].path }) |
| 116 | + loginLoading.value = false | ||
| 131 | } | 117 | } |
| 132 | 118 | ||
| 133 | // 社交登录 | 119 | // 社交登录 |
yudao-ui-admin-vue3/src/views/Login/components/MobileForm.vue
| @@ -5,13 +5,12 @@ import LoginFormTitle from './LoginFormTitle.vue' | @@ -5,13 +5,12 @@ import LoginFormTitle from './LoginFormTitle.vue' | ||
| 5 | import { ElForm, ElFormItem, ElInput, ElRow, ElCol, ElMessage } from 'element-plus' | 5 | import { ElForm, ElFormItem, ElInput, ElRow, ElCol, ElMessage } from 'element-plus' |
| 6 | import { useI18n } from '@/hooks/web/useI18n' | 6 | import { useI18n } from '@/hooks/web/useI18n' |
| 7 | import { required } from '@/utils/formRules' | 7 | import { required } from '@/utils/formRules' |
| 8 | -import { getTenantIdByNameApi, sendSmsCodeApi, smsLoginApi, getInfoApi } from '@/api/login' | 8 | +import { getTenantIdByNameApi, sendSmsCodeApi, smsLoginApi } from '@/api/login' |
| 9 | import { useCache } from '@/hooks/web/useCache' | 9 | import { useCache } from '@/hooks/web/useCache' |
| 10 | import { usePermissionStore } from '@/store/modules/permission' | 10 | import { usePermissionStore } from '@/store/modules/permission' |
| 11 | import { useRouter } from 'vue-router' | 11 | import { useRouter } from 'vue-router' |
| 12 | import { setToken } from '@/utils/auth' | 12 | import { setToken } from '@/utils/auth' |
| 13 | -import { useUserStore } from '@/store/modules/user' | ||
| 14 | -import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router' | 13 | +import type { RouteLocationNormalizedLoaded } from 'vue-router' |
| 15 | import { useLoginState, LoginStateEnum, useFormValid } from './useLogin' | 14 | import { useLoginState, LoginStateEnum, useFormValid } from './useLogin' |
| 16 | const formSmsLogin = ref() | 15 | const formSmsLogin = ref() |
| 17 | const { validForm } = useFormValid(formSmsLogin) | 16 | const { validForm } = useFormValid(formSmsLogin) |
| @@ -21,9 +20,8 @@ const iconHouse = useIcon({ icon: 'ep:house' }) | @@ -21,9 +20,8 @@ const iconHouse = useIcon({ icon: 'ep:house' }) | ||
| 21 | const iconCellphone = useIcon({ icon: 'ep:cellphone' }) | 20 | const iconCellphone = useIcon({ icon: 'ep:cellphone' }) |
| 22 | const iconCircleCheck = useIcon({ icon: 'ep:circle-check' }) | 21 | const iconCircleCheck = useIcon({ icon: 'ep:circle-check' }) |
| 23 | const { wsCache } = useCache() | 22 | const { wsCache } = useCache() |
| 24 | -const userStore = useUserStore() | ||
| 25 | const permissionStore = usePermissionStore() | 23 | const permissionStore = usePermissionStore() |
| 26 | -const { currentRoute, addRoute, push } = useRouter() | 24 | +const { currentRoute, push } = useRouter() |
| 27 | const loginLoading = ref(false) | 25 | const loginLoading = ref(false) |
| 28 | const { t } = useI18n() | 26 | const { t } = useI18n() |
| 29 | 27 | ||
| @@ -102,24 +100,16 @@ const signIn = async () => { | @@ -102,24 +100,16 @@ const signIn = async () => { | ||
| 102 | await smsLoginApi(smsVO.loginSms) | 100 | await smsLoginApi(smsVO.loginSms) |
| 103 | .then(async (res) => { | 101 | .then(async (res) => { |
| 104 | setToken(res?.token) | 102 | setToken(res?.token) |
| 105 | - const userInfo = await getInfoApi() | ||
| 106 | - await userStore.setUserInfoAction(userInfo) | ||
| 107 | - getRoutes() | 103 | + if (!redirect.value) { |
| 104 | + redirect.value = '/' | ||
| 105 | + } | ||
| 106 | + push({ path: redirect.value || permissionStore.addRouters[0].path }) | ||
| 108 | }) | 107 | }) |
| 109 | .catch(() => {}) | 108 | .catch(() => {}) |
| 110 | .finally(() => { | 109 | .finally(() => { |
| 111 | loginLoading.value = false | 110 | loginLoading.value = false |
| 112 | }) | 111 | }) |
| 113 | } | 112 | } |
| 114 | -// 获取路由 | ||
| 115 | -const getRoutes = async () => { | ||
| 116 | - // 后端过滤菜单 | ||
| 117 | - await permissionStore.generateRoutes() | ||
| 118 | - permissionStore.getAddRouters.forEach((route) => { | ||
| 119 | - addRoute(route as RouteRecordRaw) // 动态添加可访问路由表 | ||
| 120 | - }) | ||
| 121 | - push({ path: redirect.value || permissionStore.addRouters[0].path }) | ||
| 122 | -} | ||
| 123 | </script> | 113 | </script> |
| 124 | <template> | 114 | <template> |
| 125 | <el-form | 115 | <el-form |
yudao-ui-admin-vue3/src/views/infra/codegen/components/Preview.vue
| @@ -135,7 +135,7 @@ defineExpose({ | @@ -135,7 +135,7 @@ defineExpose({ | ||
| 135 | :name="item.filePath" | 135 | :name="item.filePath" |
| 136 | :key="item.filePath" | 136 | :key="item.filePath" |
| 137 | > | 137 | > |
| 138 | - <el-button text style="float: right" @click="copy(item.code)"> | 138 | + <el-button link style="float: right" @click="copy(item.code)"> |
| 139 | {{ t('common.copy') }} | 139 | {{ t('common.copy') }} |
| 140 | </el-button> | 140 | </el-button> |
| 141 | <pre>{{ item.code }}</pre> | 141 | <pre>{{ item.code }}</pre> |
yudao-ui-admin-vue3/src/views/infra/fileList/index.vue
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | -import { ref } from 'vue' | 2 | +import { ref, unref } from 'vue' |
| 3 | import dayjs from 'dayjs' | 3 | import dayjs from 'dayjs' |
| 4 | import { ElMessage, ElUpload, UploadInstance, UploadRawFile, ElImage } from 'element-plus' | 4 | import { ElMessage, ElUpload, UploadInstance, UploadRawFile, ElImage } from 'element-plus' |
| 5 | import { useTable } from '@/hooks/web/useTable' | 5 | import { useTable } from '@/hooks/web/useTable' |
| @@ -8,6 +8,7 @@ import type { FileVO } from '@/api/infra/fileList/types' | @@ -8,6 +8,7 @@ import type { FileVO } from '@/api/infra/fileList/types' | ||
| 8 | import { allSchemas } from './fileList.data' | 8 | import { allSchemas } from './fileList.data' |
| 9 | import * as FileApi from '@/api/infra/fileList' | 9 | import * as FileApi from '@/api/infra/fileList' |
| 10 | import { getAccessToken, getTenantId } from '@/utils/auth' | 10 | import { getAccessToken, getTenantId } from '@/utils/auth' |
| 11 | +import { useClipboard } from '@vueuse/core' | ||
| 11 | 12 | ||
| 12 | const { t } = useI18n() // 国际化 | 13 | const { t } = useI18n() // 国际化 |
| 13 | 14 | ||
| @@ -76,6 +77,18 @@ const handleDetail = (row: FileVO) => { | @@ -76,6 +77,18 @@ const handleDetail = (row: FileVO) => { | ||
| 76 | dialogTitle.value = t('action.detail') | 77 | dialogTitle.value = t('action.detail') |
| 77 | dialogVisible.value = true | 78 | dialogVisible.value = true |
| 78 | } | 79 | } |
| 80 | +// ========== 复制相关 ========== | ||
| 81 | +const handleCopy = async (text: string) => { | ||
| 82 | + const { copy, copied, isSupported } = useClipboard({ source: text }) | ||
| 83 | + if (!isSupported) { | ||
| 84 | + ElMessage.error(t('common.copyError')) | ||
| 85 | + } else { | ||
| 86 | + await copy() | ||
| 87 | + if (unref(copied)) { | ||
| 88 | + ElMessage.success(t('common.copySuccess')) | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | +} | ||
| 79 | // ========== 初始化 ========== | 92 | // ========== 初始化 ========== |
| 80 | getList() | 93 | getList() |
| 81 | </script> | 94 | </script> |
| @@ -117,6 +130,9 @@ getList() | @@ -117,6 +130,9 @@ getList() | ||
| 117 | <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> | 130 | <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span> |
| 118 | </template> | 131 | </template> |
| 119 | <template #action="{ row }"> | 132 | <template #action="{ row }"> |
| 133 | + <el-button link type="primary" @click="handleCopy(row.url)"> | ||
| 134 | + <Icon icon="ep:copy-document" class="mr-1px" /> {{ t('common.copy') }} | ||
| 135 | + </el-button> | ||
| 120 | <el-button link type="primary" @click="handleDetail(row)"> | 136 | <el-button link type="primary" @click="handleDetail(row)"> |
| 121 | <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }} | 137 | <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }} |
| 122 | </el-button> | 138 | </el-button> |