Commit 09f5da9d5d0dd7369f8764d78b10448c126621f1
Merge branch 'dev' of http://bj.gitlab.cnlive.com/cnlive_project/cnlive-community-web-vue into dev
Showing
9 changed files
with
59 additions
and
31 deletions
src/api/request.ts
| @@ -8,7 +8,6 @@ let url: any = import.meta.env | @@ -8,7 +8,6 @@ let url: any = import.meta.env | ||
| 8 | let instance = axios.create({ | 8 | let instance = axios.create({ |
| 9 | baseURL: url.VITE_BASE_URL, | 9 | baseURL: url.VITE_BASE_URL, |
| 10 | withCredentials: true, | 10 | withCredentials: true, |
| 11 | - // timeout: 10 | ||
| 12 | timeout: 10000 | 11 | timeout: 10000 |
| 13 | }) | 12 | }) |
| 14 | 13 | ||
| @@ -51,7 +50,17 @@ instance.interceptors.response.use( | @@ -51,7 +50,17 @@ instance.interceptors.response.use( | ||
| 51 | } | 50 | } |
| 52 | }, | 51 | }, |
| 53 | error => { | 52 | error => { |
| 54 | - return Promise.reject(error) | 53 | + let msg |
| 54 | + if (error.message.indexOf('exceeded') >= 0) { | ||
| 55 | + msg = '请求超时' | ||
| 56 | + ElMessage.error(msg); | ||
| 57 | + } else if (error.message.indexOf('401') >= 0) { | ||
| 58 | + return false | ||
| 59 | + } else { | ||
| 60 | + msg = error?.message ?? 'Error' | ||
| 61 | + ElMessage.error(msg); | ||
| 62 | + return Promise.reject(error) | ||
| 63 | + } | ||
| 55 | } | 64 | } |
| 56 | ) | 65 | ) |
| 57 | 66 |
src/components/Uploader/index.vue
| @@ -88,6 +88,14 @@ const beforeAvatarUpload = (file: ElFile) => { | @@ -88,6 +88,14 @@ const beforeAvatarUpload = (file: ElFile) => { | ||
| 88 | } | 88 | } |
| 89 | return isFormatAllowed && isSizeAllowed; | 89 | return isFormatAllowed && isSizeAllowed; |
| 90 | }; | 90 | }; |
| 91 | +/** | ||
| 92 | + * 上传文件失败回调 | ||
| 93 | + * @param { ElUploadProgressEvent } 回调返回对象 | ||
| 94 | + */ | ||
| 95 | +const handlError = (err: ElUploadProgressEvent) => { | ||
| 96 | + console.log(err); | ||
| 97 | + ElMessage.error("上传失败,请重试"); | ||
| 98 | +}; | ||
| 91 | const emit = defineEmits<{ | 99 | const emit = defineEmits<{ |
| 92 | (e: "imageChange", url: string, tagName: string): void; | 100 | (e: "imageChange", url: string, tagName: string): void; |
| 93 | }>(); | 101 | }>(); |
| @@ -103,6 +111,7 @@ const emit = defineEmits<{ | @@ -103,6 +111,7 @@ const emit = defineEmits<{ | ||
| 103 | :headers="uploadSettings.headers" | 111 | :headers="uploadSettings.headers" |
| 104 | name="multipartFile" | 112 | name="multipartFile" |
| 105 | :on-success="handleAvatarSuccess" | 113 | :on-success="handleAvatarSuccess" |
| 114 | + :on-error="handlError" | ||
| 106 | :before-upload="beforeAvatarUpload" | 115 | :before-upload="beforeAvatarUpload" |
| 107 | > | 116 | > |
| 108 | <img | 117 | <img |
src/utils/progress.ts
| 1 | -import NProgress from 'nprogress' | ||
| 2 | -import 'nprogress/nprogress.css' | ||
| 3 | -import router from '@/router/index' | 1 | +import NProgress from 'nprogress'; |
| 2 | +import 'nprogress/nprogress.css'; | ||
| 3 | +import router from '@/router/index'; | ||
| 4 | +import * as store from "@/pinia/index"; | ||
| 4 | 5 | ||
| 5 | -NProgress.configure({ showSpinner: false }) | 6 | +NProgress.configure({ showSpinner: false }); |
| 6 | 7 | ||
| 7 | router.beforeEach((to: any, from: any, next: any) => { | 8 | router.beforeEach((to: any, from: any, next: any) => { |
| 8 | - // if (to.matched.length == 0) { router.push(to.path); } | ||
| 9 | - NProgress.start() | ||
| 10 | - const hasToken = true | ||
| 11 | - const whiteList = ['/login'] | 9 | + NProgress.start(); |
| 10 | + const hasToken = store.family.loginStore().token; | ||
| 11 | + const whiteList = ['/login']; | ||
| 12 | 12 | ||
| 13 | - // TIP 页面标题设置 | ||
| 14 | - globalThis.document.title = to.meta.title? to.meta.title: import.meta.env.VITE_APP_TITLE | 13 | + // 页面标题设置 |
| 14 | + globalThis.document.title = to.meta.title? to.meta.title: import.meta.env.VITE_APP_TITLE; | ||
| 15 | 15 | ||
| 16 | if (hasToken) { | 16 | if (hasToken) { |
| 17 | - console.log('has') | ||
| 18 | if (to.path === '/login') { | 17 | if (to.path === '/login') { |
| 19 | - // next({ path: '/about' }) | ||
| 20 | - next() | 18 | + next({ path: '/dashboard' }) |
| 21 | NProgress.done() | 19 | NProgress.done() |
| 22 | } else { | 20 | } else { |
| 23 | next() | 21 | next() |
| 24 | NProgress.done() | 22 | NProgress.done() |
| 25 | } | 23 | } |
| 26 | } else { | 24 | } else { |
| 27 | - console.log('hasnot') | ||
| 28 | if (whiteList.indexOf(to.path) !== -1) { | 25 | if (whiteList.indexOf(to.path) !== -1) { |
| 29 | next() | 26 | next() |
| 30 | } else { | 27 | } else { |
src/views/notify/edit.vue
| @@ -182,7 +182,7 @@ onMounted(() => { | @@ -182,7 +182,7 @@ onMounted(() => { | ||
| 182 | <el-input | 182 | <el-input |
| 183 | type="textarea" | 183 | type="textarea" |
| 184 | v-model.trim="form.data.content" | 184 | v-model.trim="form.data.content" |
| 185 | - placeholder="富文本组件整理中,后续会替换,先用文本框走流程" | 185 | + placeholder="请填写公告内容" |
| 186 | maxlength="1500" | 186 | maxlength="1500" |
| 187 | show-word-limit | 187 | show-word-limit |
| 188 | /> | 188 | /> |
src/views/permission/edit.vue
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; | 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; |
| 3 | import { permissionSave } from "@/api/user/permission"; | 3 | import { permissionSave } from "@/api/user/permission"; |
| 4 | import { useRoute } from "vue-router"; | 4 | import { useRoute } from "vue-router"; |
| 5 | +import { back } from "@/utils/tool"; | ||
| 5 | import type { ElForm } from "element-plus"; | 6 | import type { ElForm } from "element-plus"; |
| 6 | let instance: ComponentInternalInstance | null = getCurrentInstance(); | 7 | let instance: ComponentInternalInstance | null = getCurrentInstance(); |
| 7 | let tempPriority = ref(0); | 8 | let tempPriority = ref(0); |
| @@ -175,6 +176,7 @@ onMounted(() => { | @@ -175,6 +176,7 @@ onMounted(() => { | ||
| 175 | <el-button type="primary" @click="submitForm(ruleFormRef)" | 176 | <el-button type="primary" @click="submitForm(ruleFormRef)" |
| 176 | >提交</el-button | 177 | >提交</el-button |
| 177 | > | 178 | > |
| 179 | + <el-button type="info" @click="back">返回</el-button> | ||
| 178 | </el-form-item> | 180 | </el-form-item> |
| 179 | </el-form> | 181 | </el-form> |
| 180 | </el-card> | 182 | </el-card> |
src/views/role/edit.vue
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; | 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; |
| 3 | import { roleSave } from "@/api/user/role"; | 3 | import { roleSave } from "@/api/user/role"; |
| 4 | import { useRoute } from "vue-router"; | 4 | import { useRoute } from "vue-router"; |
| 5 | +import { back } from "@/utils/tool"; | ||
| 5 | import type { ElForm } from "element-plus"; | 6 | import type { ElForm } from "element-plus"; |
| 6 | const { | 7 | const { |
| 7 | appContext: { | 8 | appContext: { |
| @@ -105,6 +106,9 @@ onMounted(() => { | @@ -105,6 +106,9 @@ onMounted(() => { | ||
| 105 | v-show="form.dataType === 'add'" | 106 | v-show="form.dataType === 'add'" |
| 106 | >取消</el-button | 107 | >取消</el-button |
| 107 | > | 108 | > |
| 109 | + <el-button type="info" @click="back" | ||
| 110 | + >返回</el-button | ||
| 111 | + > | ||
| 108 | </el-form-item> | 112 | </el-form-item> |
| 109 | </el-form> | 113 | </el-form> |
| 110 | </el-card> | 114 | </el-card> |
src/views/role/permission.vue
| @@ -2,9 +2,10 @@ | @@ -2,9 +2,10 @@ | ||
| 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; | 2 | import { reactive, ref, getCurrentInstance, onMounted } from "vue"; |
| 3 | import { rolePermissionSave, rolePermission } from "@/api/user/role"; | 3 | import { rolePermissionSave, rolePermission } from "@/api/user/role"; |
| 4 | import { useRoute } from "vue-router"; | 4 | import { useRoute } from "vue-router"; |
| 5 | -import type Node from 'element-plus/es/components/tree/src/model/node' | 5 | +import { back } from "@/utils/tool"; |
| 6 | +import type Node from "element-plus/es/components/tree/src/model/node"; | ||
| 6 | import type { ElForm } from "element-plus"; | 7 | import type { ElForm } from "element-plus"; |
| 7 | -import type { ElTree } from 'element-plus' | 8 | +import type { ElTree } from "element-plus"; |
| 8 | const { | 9 | const { |
| 9 | appContext: { | 10 | appContext: { |
| 10 | config: { globalProperties }, | 11 | config: { globalProperties }, |
| @@ -17,17 +18,17 @@ let form = reactive({ | @@ -17,17 +18,17 @@ let form = reactive({ | ||
| 17 | }, | 18 | }, |
| 18 | permissions: [], | 19 | permissions: [], |
| 19 | defaultPermissions: [], | 20 | defaultPermissions: [], |
| 20 | - collections: [] | 21 | + collections: [], |
| 21 | }); | 22 | }); |
| 22 | const ruleFormRef = ref<InstanceType<typeof ElForm>>(); | 23 | const ruleFormRef = ref<InstanceType<typeof ElForm>>(); |
| 23 | -const addTreeTest = ref<InstanceType<typeof ElTree>>() | 24 | +const addTreeTest = ref<InstanceType<typeof ElTree>>(); |
| 24 | /** | 25 | /** |
| 25 | * 表单重置 | 26 | * 表单重置 |
| 26 | */ | 27 | */ |
| 27 | const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { | 28 | const resetForm = (formEl: InstanceType<typeof ElForm> | undefined) => { |
| 28 | if (!formEl) return; | 29 | if (!formEl) return; |
| 29 | - form.defaultPermissions = [] | ||
| 30 | - addTreeTest.value!.setCheckedNodes([]) | 30 | + form.defaultPermissions = []; |
| 31 | + addTreeTest.value!.setCheckedNodes([]); | ||
| 31 | formEl.resetFields(); | 32 | formEl.resetFields(); |
| 32 | }; | 33 | }; |
| 33 | /** | 34 | /** |
| @@ -61,14 +62,14 @@ const getPermissions = async (roleId = useRoute().query.roleId) => { | @@ -61,14 +62,14 @@ const getPermissions = async (roleId = useRoute().query.roleId) => { | ||
| 61 | try { | 62 | try { |
| 62 | let res = await rolePermission({ roleId: roleId }); | 63 | let res = await rolePermission({ roleId: roleId }); |
| 63 | form.permissions = res?.data?.data; | 64 | form.permissions = res?.data?.data; |
| 64 | - form.defaultPermissions = getCheckedPermissions(res?.data?.data) | 65 | + form.defaultPermissions = getCheckedPermissions(res?.data?.data); |
| 65 | } catch (e) { | 66 | } catch (e) { |
| 66 | console.log(e); | 67 | console.log(e); |
| 67 | } | 68 | } |
| 68 | }; | 69 | }; |
| 69 | interface Tree { | 70 | interface Tree { |
| 70 | - label: string | ||
| 71 | - children?: Tree[] | 71 | + label: string; |
| 72 | + children?: Tree[]; | ||
| 72 | } | 73 | } |
| 73 | /** | 74 | /** |
| 74 | * 树组件自定义属性 | 75 | * 树组件自定义属性 |
| @@ -80,7 +81,7 @@ const defaultProps: Tree = { | @@ -80,7 +81,7 @@ const defaultProps: Tree = { | ||
| 80 | /** | 81 | /** |
| 81 | * 选中树节点回显 | 82 | * 选中树节点回显 |
| 82 | * @param {array} menuArray 树数组 | 83 | * @param {array} menuArray 树数组 |
| 83 | - * @returns {array} | 84 | + * @returns {array} |
| 84 | */ | 85 | */ |
| 85 | const getCheckedPermissions = (menuArray: Tree[]) => { | 86 | const getCheckedPermissions = (menuArray: Tree[]) => { |
| 86 | if (menuArray) { | 87 | if (menuArray) { |
| @@ -151,11 +152,10 @@ onMounted(() => { | @@ -151,11 +152,10 @@ onMounted(() => { | ||
| 151 | <el-button type="primary" @click="submitForm(ruleFormRef)" | 152 | <el-button type="primary" @click="submitForm(ruleFormRef)" |
| 152 | >提交</el-button | 153 | >提交</el-button |
| 153 | > | 154 | > |
| 154 | - <el-button | ||
| 155 | - type="info" | ||
| 156 | - @click="resetForm(ruleFormRef)" | 155 | + <el-button type="info" @click="resetForm(ruleFormRef)" |
| 157 | >置空</el-button | 156 | >置空</el-button |
| 158 | > | 157 | > |
| 158 | + <el-button type="info" @click="back">返回</el-button> | ||
| 159 | </el-form-item> | 159 | </el-form-item> |
| 160 | </el-form> | 160 | </el-form> |
| 161 | </el-card> | 161 | </el-card> |
src/views/role/user.vue
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | import { reactive, onMounted } from "vue"; | 2 | import { reactive, onMounted } from "vue"; |
| 3 | import { useRoute } from 'vue-router'; | 3 | import { useRoute } from 'vue-router'; |
| 4 | import { roleUser } from "@/api/user/role"; | 4 | import { roleUser } from "@/api/user/role"; |
| 5 | +import { back } from '@/utils/tool'; | ||
| 5 | import Pagination from "@/components/Pagination/index.vue"; | 6 | import Pagination from "@/components/Pagination/index.vue"; |
| 6 | interface Form { | 7 | interface Form { |
| 7 | page: number; | 8 | page: number; |
| @@ -70,6 +71,9 @@ onMounted(() => { | @@ -70,6 +71,9 @@ onMounted(() => { | ||
| 70 | <template> | 71 | <template> |
| 71 | <div class="page-container"> | 72 | <div class="page-container"> |
| 72 | <h1>角色用户</h1> | 73 | <h1>角色用户</h1> |
| 74 | + <el-row style="padding-bottom: 20px"> | ||
| 75 | + <el-button type="info" @click="back">返回</el-button> | ||
| 76 | + </el-row> | ||
| 73 | <el-table | 77 | <el-table |
| 74 | :data="data.list" | 78 | :data="data.list" |
| 75 | style="width: 100%" | 79 | style="width: 100%" |
src/views/user/role.vue
| 1 | <script setup lang="ts"> | 1 | <script setup lang="ts"> |
| 2 | import { reactive, ref, onMounted } from "vue"; | 2 | import { reactive, ref, onMounted } from "vue"; |
| 3 | import { userRoles } from "@/api/user/user"; | 3 | import { userRoles } from "@/api/user/user"; |
| 4 | -import { parseTime } from "@/utils/tool"; | 4 | +import { parseTime, back } from "@/utils/tool"; |
| 5 | import { useRoute } from "vue-router"; | 5 | import { useRoute } from "vue-router"; |
| 6 | interface Form { | 6 | interface Form { |
| 7 | page: number; | 7 | page: number; |
| @@ -49,6 +49,9 @@ onMounted(() => { | @@ -49,6 +49,9 @@ onMounted(() => { | ||
| 49 | <template> | 49 | <template> |
| 50 | <div class="page-container"> | 50 | <div class="page-container"> |
| 51 | <h1>用户角色</h1> | 51 | <h1>用户角色</h1> |
| 52 | + <el-row style="padding-bottom: 20px"> | ||
| 53 | + <el-button type="info" @click="back">返回</el-button> | ||
| 54 | + </el-row> | ||
| 52 | <el-table | 55 | <el-table |
| 53 | :data="data.list" | 56 | :data="data.list" |
| 54 | style="width: 100%" | 57 | style="width: 100%" |