修改一些内容

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_ #The defined variable must start with VITE_APP_
VITE_APP_ENV = 'dev' 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 #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 #proxy, use this to test proxy
#VITE_APP_BASE_URL = '/api' #VITE_APP_BASE_URL = '/api'

View File

@ -1,7 +1,6 @@
{ {
"globals": { "globals": {
"EffectScope": true, "EffectScope": true,
"axiosReq": true,
"bus": true, "bus": true,
"buttonCodes": true, "buttonCodes": true,
"casHandleChange": true, "casHandleChange": true,
@ -34,6 +33,8 @@
"getCurrentScope": true, "getCurrentScope": true,
"getLangInstance": true, "getLangInstance": true,
"getQueryParam": true, "getQueryParam": true,
"getRouterList": true,
"getUserInfo": true,
"h": true, "h": true,
"inject": true, "inject": true,
"isExternal": true, "isExternal": true,
@ -43,8 +44,8 @@
"isRef": true, "isRef": true,
"lang": true, "lang": true,
"langTitle": true, "langTitle": true,
"loginOutReq": true, "login": true,
"loginReq": true, "logout": true,
"longpress": true, "longpress": true,
"markRaw": true, "markRaw": true,
"mockAxiosReq": true, "mockAxiosReq": true,
@ -70,6 +71,7 @@
"reactive": true, "reactive": true,
"readonly": true, "readonly": true,
"ref": true, "ref": true,
"request": true,
"resetRouter": true, "resetRouter": true,
"resetState": true, "resetState": true,
"resizeHandler": true, "resizeHandler": true,
@ -105,7 +107,7 @@
"useSlots": true, "useSlots": true,
"useTable": true, "useTable": true,
"useTagsViewStore": true, "useTagsViewStore": true,
"userInfoReq": true, "userRouteStore": true,
"watch": true, "watch": true,
"watchEffect": true, "watchEffect": true,
"watchPostEffect": 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/mockjs": "1.0.6",
"@types/node": "^17.0.35", "@types/node": "^17.0.35",
"@types/path-browserify": "^1.0.0", "@types/path-browserify": "^1.0.0",
"@typescript-eslint/eslint-plugin": "5.30.0", "@typescript-eslint/eslint-plugin": "5.53.0",
"@typescript-eslint/parser": "5.30.0", "@typescript-eslint/parser": "5.53.0",
"@vitejs/plugin-legacy": "^2.2.0", "@vitejs/plugin-legacy": "^2.2.0",
"@vitejs/plugin-vue": "^2.3.3", "@vitejs/plugin-vue": "^2.3.3",
"@vitejs/plugin-vue-jsx": "^2.0.1", "@vitejs/plugin-vue-jsx": "^2.0.1",
@ -123,7 +123,6 @@
"not op_mini all" "not op_mini all"
], ],
"engines": { "engines": {
"node": ">= 16 <18", "node": ">= 16"
"pnpm": ">= 6 <8"
} }
} }

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' import request from '@/utils/request'
export const userInfoReq = (): Promise<any> => { export async function getUserInfo(): Promise<any> {
return new Promise((resolve) => {
const reqConfig = { const reqConfig = {
url: '/basis-func/user/getUserInfo', url: '/userInfo',
params: { plateFormId: 2 }, params: { plateFormId: 2 },
method: 'post' method: 'post'
} }
axiosReq(reqConfig).then(({ data }) => { return request(reqConfig).then((it) => it.data)
resolve(data)
})
})
} }
//登录 //登录
export const loginReq = (subForm) => { export async function login(subForm) {
return axiosReq({ return request({
url: '/basis-func/user/loginValid', url: '/login',
params: subForm, params: subForm,
method: 'post' method: 'post'
}) })
} }
//退出登录 //退出登录
export const loginOutReq = () => { export async function logout() {
return axiosReq({ return request({
url: '/basis-func/user/loginValid', url: '/logout',
method: 'post' method: 'post'
}) })
} }

View File

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

View File

@ -1,7 +1,7 @@
import router from '@/router' import router from '@/router'
import { filterAsyncRouter, progressClose, progressStart } from '@/hooks/use-permission' import { filterAsyncRouter, progressClose, progressStart } from '@/hooks/use-permission'
import { useBasicStore } from '@/store/basic' import { useBasicStore } from '@/store/basic'
import { userInfoReq } from '@/api/user' import { getUserInfo } from '@/api/user'
import { langTitle } from '@/hooks/use-common' import { langTitle } from '@/hooks/use-common'
//路由进入前拦截 //路由进入前拦截
@ -19,7 +19,7 @@ router.beforeEach(async (to) => {
//2.判断是否获取用户信息 //2.判断是否获取用户信息
if (!basicStore.getUserInfo) { if (!basicStore.getUserInfo) {
try { try {
const userData = await userInfoReq() const userData = await getUserInfo()
//3.动态路由权限筛选 //3.动态路由权限筛选
filterAsyncRouter(userData) filterAsyncRouter(userData)
//4.保存用户信息到store //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->页面的配置 //导出service实例给页面调用 , config->页面的配置
export default function axiosReq(config) { export default function request(config) {
return service({ return service({
baseURL: import.meta.env.VITE_APP_BASE_URL, baseURL: import.meta.env.VITE_APP_BASE_URL,
timeout: 8000, timeout: 8000,

View File

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

View File

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

View File

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

View File

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