diff --git a/composer.json b/composer.json index b5d0c5ce..b93b1b14 100644 --- a/composer.json +++ b/composer.json @@ -75,7 +75,7 @@ "hyperf/watcher": "3.1.*", "mockery/mockery": "^1.0", "phpstan/phpstan": "^1.10", - "swoole/ide-helper": "^5.0", + "swoole/ide-helper": "^6.0", "zircote/swagger-php": "4.10.6" }, "suggest": { diff --git a/web/src/directives/copy/index.ts b/web/src/directives/copy/index.ts index 0312258b..4f7b1ac7 100644 --- a/web/src/directives/copy/index.ts +++ b/web/src/directives/copy/index.ts @@ -14,13 +14,20 @@ import Message from 'vue-m-message' export interface CopyElement extends HTMLElement { copyValue: string } - +/** + * eg. + * 1、 v-copy="'copyContent'" // 默认是dblclick,localhost及https复制才会生效 + * 2、 v-copy:dblclick.legacy="'copyContent'" // 兼容模式,所有浏览器都生效 + */ export const copy = { mounted(el: CopyElement, binding: DirectiveBinding) { - const { isSupported, copy } = useClipboard() - if (!isSupported.value) { + const legacy = binding.modifiers?.legacy === true + const { isSupported } = useClipboard() + const { copy } = useClipboard({ legacy }) + if (!isSupported.value && !legacy) { throw new Error('[Directive: copy]: Your browser does not support Clipboard API') } + const { value } = binding if (value) { el.copyValue = value diff --git a/web/src/utils/http.ts b/web/src/utils/http.ts index f81dbea2..7f8596a5 100644 --- a/web/src/utils/http.ts +++ b/web/src/utils/http.ts @@ -52,6 +52,8 @@ http.interceptors.request.use( }, ) +let isLogout = false + http.interceptors.response.use( async (response: AxiosResponse): Promise => { isLoading.value = false @@ -72,14 +74,14 @@ http.interceptors.response.use( else { switch (response?.data?.code) { case ResultCode.UNAUTHORIZED: { - const logout = useDebounceFn( - async () => { + const logout = async () => { + if (isLogout === false) { + isLogout = true + setTimeout(() => isLogout = false, 5000) Message.error('登录状态已过期,需要重新登录', { zIndex: 9999 }) await useUserStore().logout() - }, - 3000, - { maxWait: 5000 }, - ) + } + } // 检查token是否需要刷新 if (userStore.isLogin && !isRefreshToken.value) { isRefreshToken.value = true