修改一些内容

This commit is contained in:
洛洛希雅Lolosia 2023-02-22 11:21:49 +08:00
parent 873d54056d
commit 026940360d
14 changed files with 41775 additions and 43 deletions

View File

@ -1,9 +1,9 @@
#The defined variable must start with VITE_APP_
VITE_APP_ENV = 'dev'
VITE_APP_BASE_URL = 'https://github.jzfai.top/micro-service-api'
VITE_APP_BASE_URL = 'https://localhost:7001'
#image or oss address
VITE_APP_IMAGE_URL = 'https://github.jzfai.top/gofast-image'
VITE_APP_IMAGE_URL = 'https://localhost:7001/gofast-image'
#proxy, use this to test proxy
#VITE_APP_BASE_URL = '/api'

View File

@ -1,7 +1,6 @@
{
"globals": {
"EffectScope": true,
"axiosReq": true,
"bus": true,
"buttonCodes": true,
"casHandleChange": true,
@ -34,6 +33,8 @@
"getCurrentScope": true,
"getLangInstance": true,
"getQueryParam": true,
"getRouterList": true,
"getUserInfo": true,
"h": true,
"inject": true,
"isExternal": true,
@ -43,8 +44,8 @@
"isRef": true,
"lang": true,
"langTitle": true,
"loginOutReq": true,
"loginReq": true,
"login": true,
"logout": true,
"longpress": true,
"markRaw": true,
"mockAxiosReq": true,
@ -70,6 +71,7 @@
"reactive": true,
"readonly": true,
"ref": true,
"request": true,
"resetRouter": true,
"resetState": true,
"resizeHandler": true,
@ -105,7 +107,7 @@
"useSlots": true,
"useTable": true,
"useTagsViewStore": true,
"userInfoReq": true,
"userRouteStore": true,
"watch": true,
"watchEffect": true,
"watchPostEffect": true,

41705
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -54,8 +54,8 @@
"@types/mockjs": "1.0.6",
"@types/node": "^17.0.35",
"@types/path-browserify": "^1.0.0",
"@typescript-eslint/eslint-plugin": "5.30.0",
"@typescript-eslint/parser": "5.30.0",
"@typescript-eslint/eslint-plugin": "5.53.0",
"@typescript-eslint/parser": "5.53.0",
"@vitejs/plugin-legacy": "^2.2.0",
"@vitejs/plugin-vue": "^2.3.3",
"@vitejs/plugin-vue-jsx": "^2.0.1",
@ -123,7 +123,6 @@
"not op_mini all"
],
"engines": {
"node": ">= 16 <18",
"pnpm": ">= 6 <8"
"node": ">= 16"
}
}

9
src/api/router.ts Normal file
View File

@ -0,0 +1,9 @@
import request from '@/utils/request'
export function getRouterList(data) {
return request({
url: '/menu/navigate',
method: 'post',
data,
})
}

View File

@ -1,31 +1,27 @@
//获取用户信息
import axiosReq from '@/utils/axios-req'
export const userInfoReq = (): Promise<any> => {
return new Promise((resolve) => {
const reqConfig = {
url: '/basis-func/user/getUserInfo',
params: { plateFormId: 2 },
method: 'post'
}
axiosReq(reqConfig).then(({ data }) => {
resolve(data)
})
})
import request from '@/utils/request'
export async function getUserInfo(): Promise<any> {
const reqConfig = {
url: '/userInfo',
params: { plateFormId: 2 },
method: 'post'
}
return request(reqConfig).then((it) => it.data)
}
//登录
export const loginReq = (subForm) => {
return axiosReq({
url: '/basis-func/user/loginValid',
export async function login(subForm) {
return request({
url: '/login',
params: subForm,
method: 'post'
})
}
//退出登录
export const loginOutReq = () => {
return axiosReq({
url: '/basis-func/user/loginValid',
export async function logout() {
return request({
url: '/logout',
method: 'post'
})
}

View File

@ -3,10 +3,10 @@ import { jsErrorCollection } from 'js-error-collection'
import pack from '../../package.json'
import settings from '@/settings'
import bus from '@/utils/bus'
import axiosReq from '@/utils/axios-req'
import request from '@/utils/request'
const reqUrl = '/integration-front/errorCollection/insert'
const errorLogReq = (errLog: string) => {
axiosReq({
request({
url: reqUrl,
data: {
pageUrl: window.location.href,

View File

@ -1,7 +1,7 @@
import router from '@/router'
import { filterAsyncRouter, progressClose, progressStart } from '@/hooks/use-permission'
import { useBasicStore } from '@/store/basic'
import { userInfoReq } from '@/api/user'
import { getUserInfo } from '@/api/user'
import { langTitle } from '@/hooks/use-common'
//路由进入前拦截
@ -19,7 +19,7 @@ router.beforeEach(async (to) => {
//2.判断是否获取用户信息
if (!basicStore.getUserInfo) {
try {
const userData = await userInfoReq()
const userData = await getUserInfo()
//3.动态路由权限筛选
filterAsyncRouter(userData)
//4.保存用户信息到store

19
src/store/routes.ts Normal file
View File

@ -0,0 +1,19 @@
import { defineStore } from 'pinia'
export const userRouteStore = defineStore('route', {
state() {
return {
routes: [],
accessRoutes: [],
partialRoutes: []
}
},
getters: {
routes: (state) => state.routes,
accessRoutes: (state) => state.accessRoutes,
partialRoutes: (state) => state.partialRoutes
},
actions: {
setRoutes() {}
}
})

View File

@ -58,7 +58,7 @@ service.interceptors.response.use(
}
)
//导出service实例给页面调用 , config->页面的配置
export default function axiosReq(config) {
export default function request(config) {
return service({
baseURL: import.meta.env.VITE_APP_BASE_URL,
timeout: 8000,

View File

@ -55,7 +55,7 @@ import { onMounted, reactive, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useBasicStore } from '@/store/basic'
import { elMessage, useElement } from '@/hooks/use-element'
import { loginReq } from '@/api/user'
import { login } from '@/api/user'
/* listen router change and set the query */
const { settings } = useBasicStore()
@ -108,7 +108,7 @@ const router = useRouter()
const basicStore = useBasicStore()
const loginFunc = () => {
loginReq(subForm)
login(subForm)
.then(({ data }) => {
elMessage('登录成功')
basicStore.setToken(data?.jwtToken)

View File

@ -44,7 +44,7 @@ import { onMounted, reactive, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useBasicStore } from '@/store/basic'
import { elMessage, useElement } from '@/hooks/use-element'
import { loginReq } from '@/api/user'
import { login } from '@/api/user'
/* listen router change and set the query */
const { settings } = useBasicStore()
@ -97,7 +97,7 @@ const router = useRouter()
const basicStore = useBasicStore()
const loginFunc = () => {
loginReq(subForm)
login(subForm)
.then(({ data }) => {
elMessage('登录成功')
basicStore.setToken(data?.jwtToken)

View File

@ -44,7 +44,7 @@ import { reactive, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useBasicStore } from '@/store/basic'
import { elMessage, useElement } from '@/hooks/use-element'
import { loginReq } from '@/api/user'
import { login } from '@/api/user'
/* listen router change and set the query */
const { settings } = useBasicStore()
//element valid
@ -96,7 +96,7 @@ const router = useRouter()
const basicStore = useBasicStore()
const loginFunc = () => {
loginReq(subForm)
login(subForm)
.then(({ data }) => {
elMessage('登录成功')
basicStore.setToken(data?.jwtToken)

View File

@ -2,7 +2,6 @@
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const axiosReq: typeof import('../src/utils/axios-req')['default']
const bus: typeof import('../src/utils/bus')['default']
const buttonCodes: typeof import('../src/directives/button-codes')['default']
const casHandleChange: typeof import('../src/hooks/use-element')['casHandleChange']
@ -35,6 +34,8 @@ declare global {
const getCurrentScope: typeof import('vue')['getCurrentScope']
const getLangInstance: typeof import('../src/hooks/use-common')['getLangInstance']
const getQueryParam: typeof import('../src/hooks/use-self-router')['getQueryParam']
const getRouterList: typeof import('../src/api/router')['getRouterList']
const getUserInfo: typeof import('../src/api/user')['getUserInfo']
const h: typeof import('vue')['h']
const inject: typeof import('vue')['inject']
const isExternal: typeof import('../src/hooks/use-layout')['isExternal']
@ -44,8 +45,8 @@ declare global {
const isRef: typeof import('vue')['isRef']
const lang: typeof import('../src/directives/lang')['default']
const langTitle: typeof import('../src/hooks/use-common')['langTitle']
const loginOutReq: typeof import('../src/api/user')['loginOutReq']
const loginReq: typeof import('../src/api/user')['loginReq']
const login: typeof import('../src/api/user')['login']
const logout: typeof import('../src/api/user')['logout']
const longpress: typeof import('../src/directives/example/longpress.js')['default']
const markRaw: typeof import('vue')['markRaw']
const mockAxiosReq: typeof import('../src/utils/mock-axios-req')['default']
@ -71,6 +72,7 @@ declare global {
const reactive: typeof import('vue')['reactive']
const readonly: typeof import('vue')['readonly']
const ref: typeof import('vue')['ref']
const request: typeof import('../src/utils/request')['default']
const resetRouter: typeof import('../src/hooks/use-permission')['resetRouter']
const resetState: typeof import('../src/hooks/use-permission')['resetState']
const resizeHandler: typeof import('../src/hooks/use-layout')['resizeHandler']
@ -106,7 +108,7 @@ declare global {
const useSlots: typeof import('vue')['useSlots']
const useTable: typeof import('../src/hooks/use-table')['useTable']
const useTagsViewStore: typeof import('../src/store/tags-view')['useTagsViewStore']
const userInfoReq: typeof import('../src/api/user')['userInfoReq']
const userRouteStore: typeof import('../src/store/routes')['userRouteStore']
const watch: typeof import('vue')['watch']
const watchEffect: typeof import('vue')['watchEffect']
const watchPostEffect: typeof import('vue')['watchPostEffect']