build生产版本时修正了若干错误
This commit is contained in:
parent
8044420604
commit
afbe058111
@ -1,5 +1,5 @@
|
|||||||
import apiClient from './axiosInstance';
|
import apiClient from './axiosInstance';
|
||||||
import type { TokenResponse, HTTPValidationError } from './types';
|
import type { TokenResponse } from './types';
|
||||||
|
|
||||||
const API_BASE_URL = '/auth';
|
const API_BASE_URL = '/auth';
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import type { UserResponse, UserCreate } from '@/api/types'
|
import type { UserResponse, UserCreate } from '@/api/types'
|
||||||
import { userService } from '@/api/userService'
|
import { userService } from '@/api/userService'
|
||||||
|
@ -21,12 +21,12 @@ app.use(ElementPlus)
|
|||||||
const store = userStore()
|
const store = userStore()
|
||||||
|
|
||||||
// 使用插件进行持久化,监听 store 变化并保存到本地存储
|
// 使用插件进行持久化,监听 store 变化并保存到本地存储
|
||||||
store.$subscribe((mutation, state) => {
|
store.$subscribe((_, state) => {
|
||||||
localStorage.setItem('authStore', JSON.stringify(state));
|
localStorage.setItem('authStore', JSON.stringify(state));
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听 action 执行,登录和刷新令牌后保存状态到本地存储
|
// 监听 action 执行,登录和刷新令牌后保存状态到本地存储
|
||||||
store.$onAction(({ name, store, args, after, onError }) => {
|
store.$onAction(({ name, store, after }) => {
|
||||||
if (name === 'login' || name === 'refreshTokenMethod') {
|
if (name === 'login' || name === 'refreshTokenMethod') {
|
||||||
after(() => {
|
after(() => {
|
||||||
localStorage.setItem('authStore', JSON.stringify(store.$state));
|
localStorage.setItem('authStore', JSON.stringify(store.$state));
|
||||||
|
@ -24,7 +24,7 @@ const router = createRouter({
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, _, next) => {
|
||||||
//const userStore = useUserStore()
|
//const userStore = useUserStore()
|
||||||
|
|
||||||
// 如果路由需要认证但用户未登录
|
// 如果路由需要认证但用户未登录
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import type { Ref } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { userStore } from '@/store/userStore'
|
import { userStore } from '@/store/userStore'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
|
@ -40,12 +40,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
||||||
import { userStore as store } from '@/store/userStore'
|
import { userStore as store } from '@/store/userStore'
|
||||||
import { userService } from '@/api/userService'
|
|
||||||
import type { UserResponse } from '@/api/types'
|
|
||||||
import UserTable from '@/components/UserTable.vue'
|
import UserTable from '@/components/UserTable.vue'
|
||||||
import EditUserDialog from '@/components/EditUserDialog.vue'
|
import EditUserDialog from '@/components/EditUserDialog.vue'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user