code review:双 token 实现。

This commit is contained in:
YunaiV 2024-10-14 20:16:48 +08:00
parent 81596b568a
commit b5ab025fc2
16 changed files with 26 additions and 22 deletions

2
env/.env vendored
View File

@ -1,4 +1,4 @@
VITE_APP_TITLE = 'ruoyi-vue-pro'
VITE_APP_TITLE = '芋道管理系统'
VITE_APP_PORT = 9000
VITE_UNI_APPID = 'H57F2ACE4'

View File

@ -6,11 +6,11 @@
*
* update 2024-10-09
*
* userStore
*
* userStore
*
*
* router块中设置
*
* router
*
* <route lang="json5">
{
layout: 'tabbar',
@ -60,10 +60,10 @@ const navigateToInterceptor = {
return option
}
// 下面的逻辑跟PC端差不多
// 下面的逻辑跟 PC 端差不多
if (getAccessToken()) {
if (path === '/pages/login/index') {
// 这里写死,避免在login页面中设置了needLogin导致死循环
// 这里写死,避免在 login 页面中设置了 needLogin导致死循环
return option
} else {
// todo 获取字典数据并保存到本地

View File

@ -1,5 +1,5 @@
{
"name": "ruoyi-vue-pro",
"name": "芋道管理系统",
"appid": "H57F2ACE4",
"description": "",
"versionName": "1.0.0",

View File

@ -1,3 +1,4 @@
<!-- 协作界面用于 bpm 工作流 -->
<route lang="json5" type="page">
{
layout: 'tabbar',

View File

@ -1,4 +1,4 @@
<!-- 通讯录item -->
<!-- 通讯录 item -->
<template>
<view class="flex justify-between w-full">
<!-- 头像 -->
@ -13,7 +13,7 @@
<view
class="h-100rpx grow-1 flex flex-col justify-center border-solid border-b-[0.5px] border-x-0 border-t-0 border-[#E3E2E2]"
>
<!-- 如果是个人 s -->
<!-- 如果是个人 -->
<view v-if="props.item.isLeaf">
<view class="text-24rpx">{{ props.item.name }}</view>
<view class="text-22rpx">

View File

@ -1,3 +1,4 @@
<!-- 通讯录界面用于 im 聊天 -->
<route lang="json5" type="page">
{
layout: 'tabbar',

View File

@ -73,7 +73,7 @@ import { login, getTenantIdByName } from '@/service/login/LoginAPI'
import { useUserStore } from '@/store'
import * as authUtil from '@/utils/auth'
//
// TODO @ Qiksy // useToast()
const toast = useToast()
const focusInput = ref('')
@ -102,7 +102,7 @@ const loginData = reactive({
},
})
// ID
// ID // TODO @ Qiksy /** ID */
const getTenantId = async () => {
if (loginData.tenantEnable === 'true') {
const res = (await getTenantIdByName(loginData.loginForm.tenantName)) as string

View File

@ -14,6 +14,7 @@
<view><text class="text-[64rpx] font-700">你好</text></view>
<view class="mt-[36rpx]"><text class="text-[36rpx]">欢迎登录芋道快速开发平台</text></view>
</view>
<!-- TODO @芋艿后续把静态资源放到 CDN -->
<image
class="absolute w-full top-0 -z-1"
src="/static/images/login-bg.png"

View File

@ -1,5 +1,4 @@
<!-- 消息列表组件 -->
<template>
<view class="w-full flex justify-between">
<view class="w-100rpx h-100rpx flex items-center justify-center">

View File

@ -1,3 +1,4 @@
<!-- 消息界面用于 im 聊天 -->
<route lang="json5" type="page">
{
layout: 'tabbar',

View File

@ -1,5 +1,4 @@
<!-- 工作台图标 -->
<template>
<view class="flex flex-col items-center gap-1" @click="handleClick">
<view class="bg-blue-500 rounded-5px w-80rpx h-80rpx flex flex-col items-center justify-center">

View File

@ -1,3 +1,4 @@
<!-- 工作台界面用于各种 crud 管理操作 -->
<route lang="json5" type="home">
{
layout: 'tabbar',

View File

@ -5,8 +5,8 @@ type UserVO = {
deptId: number
}
// USER 缓存
type UserInfoVO = {
// USER 缓存
permissions: string[]
roles: string[]
isSetUser: boolean

View File

@ -1,5 +1,6 @@
/**
*
*
* @param content
*/
export function showConfirm(content: string) {
@ -18,6 +19,7 @@ export function showConfirm(content: string) {
/**
*
*
* @param content
*/
export function toast(content: string) {

View File

@ -6,11 +6,10 @@ import { getEvnBaseUrl } from '@/utils'
import errorCode from './errorCode'
/*
token刷新说明
1. token和tenantId都是在拦截器中赋值
2. http statusCode
使token是否过期需要重新获取
3. success中rescode是401token过期
token
1. token tenantId
2. http statusCode使token是否过期需要重新获取
3. success res code 401 access token
*/
// 是否正在刷新中
@ -115,7 +114,7 @@ export const http = <T>(options: CustomRequestOptions) => {
reject(errorCode['500'])
} else if (code !== 0) {
// 其他的错误
// psruoyi-vue-pro 的success 的code默认是0而不是200
// psyudao 的 success 的 code默认是 0 而不是 200
toast(msg)
reject(code)
}

View File

@ -131,7 +131,7 @@ export const getEvnBaseUrl = () => {
const {
miniProgram: { envVersion },
} = uni.getAccountInfoSync()
// 开发、体验、正式版 三种不同的小程序都可以配置不同的后端url
// 开发、体验、正式版 三种不同的小程序都可以配置不同的后端 url
switch (envVersion) {
case 'develop':
baseUrl = 'http://localhost:48080/admin-api'