提交 d02f35ab 编写于 作者: X xjh22222228

fix: copy failed

上级 6d07f071
// Copyright @ 2018-2021 xiejiahe. All rights reserved. MIT license.
// See https://github.com/xjh22222228/nav
import { Component, OnInit, Input, ChangeDetectionStrategy } from '@angular/core'
import { Component, OnInit, Input } from '@angular/core'
import { NzMessageService } from 'ng-zorro-antd/message'
import { getToken } from '../../utils/user'
import { setWebsiteList, copyText, deleteByWeb, getTextContent, updateByWeb } from '../../utils'
......@@ -15,7 +15,6 @@ const tagMap: ITagProp = (__tag as any).default
selector: 'app-card',
templateUrl: './index.component.html',
styleUrls: ['./index.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CardComponent implements OnInit {
@Input() dataSource: INavFourProp
......
// Copyright @ 2018-2021 xiejiahe. All rights reserved. MIT license.
import axios, { AxiosError } from 'axios'
import axios from 'axios'
import { getToken } from '../utils/user'
function handleError(error: AxiosError) {
}
const httpInstance = axios.create({
timeout: 60000,
timeout: 60000 * 3,
baseURL: 'https://api.github.com'
})
const token = getToken()
......@@ -22,7 +19,6 @@ httpInstance.interceptors.request.use(function (config) {
return config
}, function (error) {
handleError(error)
return Promise.reject(error)
})
......@@ -31,7 +27,6 @@ httpInstance.interceptors.response.use(function (res) {
return res
}, function (error) {
handleError(error)
return Promise.reject(error)
})
......
......@@ -320,9 +320,9 @@ export async function getLogoUrl(url: string): Promise<boolean|string> {
}
}
export function copyText(el: any, text: string): Promise<boolean> {
const target = el.target
const ranId = 'copy-' + randomInt(99999999)
export function copyText(el: Event, text: string): Promise<boolean> {
const target = el.target as Element
const ranId = `copy-${Date.now()}`
target.id = ranId
target.setAttribute('data-clipboard-text', text)
......@@ -330,13 +330,11 @@ export function copyText(el: any, text: string): Promise<boolean> {
const clipboard = new Clipboard(`#${ranId}`)
clipboard.on('success', function() {
clipboard?.destroy?.()
target.removeAttribute('id')
resolve(true)
});
clipboard.on('error', function() {
clipboard?.destroy?.()
target.removeAttribute('id')
resolve(false)
});
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册