Skip to content

Commit

Permalink
Merge branch 'master' into resource-panel-dock
Browse files Browse the repository at this point in the history
  • Loading branch information
kanyxmo committed Jan 9, 2025
2 parents 7a64727 + e3981ef commit 42ff353
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
13 changes: 10 additions & 3 deletions web/src/directives/copy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>) {
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
Expand Down
14 changes: 8 additions & 6 deletions web/src/utils/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ http.interceptors.request.use(
},
)

let isLogout = false

http.interceptors.response.use(
async (response: AxiosResponse): Promise<any> => {
isLoading.value = false
Expand All @@ -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
Expand Down

0 comments on commit 42ff353

Please sign in to comment.