fix: base 修改router相关内容
This commit is contained in:
parent
a3cc4f6d74
commit
8b791fb222
|
|
@ -1,7 +1,7 @@
|
|||
import axios from "axios";
|
||||
import { authToken } from "@/store/index.js"
|
||||
import { MessagePlugin } from "tdesign-vue-next"
|
||||
import { useRouter } from 'vue-router';
|
||||
import router from "@/router/index.js"
|
||||
|
||||
function get_api_url() {
|
||||
if (import.meta.env.MODE === 'development' || (import.meta.env.MODE === 'production' && window.location.host.indexOf('localhost') > -1)) {
|
||||
|
|
@ -39,15 +39,18 @@ instance.interceptors.response.use(
|
|||
},
|
||||
error => {
|
||||
let err_msg = "请求错误";
|
||||
console.log(error)
|
||||
if (error.response) {
|
||||
switch (error.response.status) {
|
||||
const status = error.response.status;
|
||||
const url = error.config?.url || '';
|
||||
switch (status) {
|
||||
case 401:
|
||||
if (authToken.access) { authToken.access = null }
|
||||
if (authToken.refresh) { authToken.refresh = null }
|
||||
if (error.config.url.indexOf('/login') == -1) {
|
||||
const router = useRouter();
|
||||
router.replace("/login")
|
||||
if (!url.includes('/login')) {
|
||||
// 避免重复跳转
|
||||
if (!window.location.pathname.includes('/login')) {
|
||||
router.replace('/login');
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -40,12 +40,11 @@
|
|||
</template>
|
||||
<script setup>
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { useRouter, useRoute } from 'vue-router';
|
||||
import router from '@/router'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { authToken, userInfo, systemInfo } from '@/store/index.js'
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const route = useRoute()
|
||||
const menuRoutes = computed(() => {
|
||||
const layoutRoute = router.getRoutes().find(r => r.name === 'Layout')
|
||||
return layoutRoute?.children[0]?.children || []
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@
|
|||
</template>
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import router from '@/router';
|
||||
import { authToken, systemInfo, userInfo } from '@/store/index.js'
|
||||
import { MessagePlugin } from "tdesign-vue-next"
|
||||
import http from "@/api/request.js";
|
||||
const router = useRouter();
|
||||
|
||||
const formData = ref({
|
||||
username: "",
|
||||
password: "",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { reactive, watch } from "vue";
|
||||
|
||||
export const systemInfo = reactive(JSON.parse(localStorage.getItem("systemInfo")) || {
|
||||
base_name: "系统名称"
|
||||
// base_name: "系统名称"
|
||||
base_name: "双碳金融系统"
|
||||
})
|
||||
|
||||
watch(systemInfo, (newVal) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue