提交 d02f35ab 编写于 作者: X xjh22222228

fix: copy failed

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