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