Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gitcode_dev
开源百科
提交
a2ce5cce
开
开源百科
项目概览
gitcode_dev
/
开源百科
通知
253
Star
3
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
17
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
开
开源百科
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
17
Issue
17
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a2ce5cce
编写于
1月 18, 2021
作者:
X
xjh22222228
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: get icon url
上级
fc2ad393
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
55 addition
and
23 deletion
+55
-23
src/components/create/create.component.html
src/components/create/create.component.html
+1
-1
src/components/create/create.component.ts
src/components/create/create.component.ts
+4
-0
src/components/dropdown/dropdown.component.html
src/components/dropdown/dropdown.component.html
+8
-2
src/components/dropdown/dropdown.component.ts
src/components/dropdown/dropdown.component.ts
+12
-1
src/components/fixbar/index.component.ts
src/components/fixbar/index.component.ts
+1
-0
src/utils/index.ts
src/utils/index.ts
+29
-19
未找到文件。
src/components/create/create.component.html
浏览文件 @
a2ce5cce
...
...
@@ -91,7 +91,7 @@
<nz-form-label
[nzSpan]=
"4"
>
图标地址
</nz-form-label>
<nz-form-control
[nzSpan]=
"20"
>
<nz-input-group
[nzPrefix]=
"prefixIcon"
>
<input
formControlName=
"icon"
nz-input
placeholder=
"https://example.com/favicon.png"
(blur)=
"on
Url
Blur($event)"
/>
<input
formControlName=
"icon"
nz-input
placeholder=
"https://example.com/favicon.png"
(blur)=
"on
Icon
Blur($event)"
/>
</nz-input-group>
<ng-template
#prefixIcon
>
...
...
src/components/create/create.component.ts
浏览文件 @
a2ce5cce
...
...
@@ -69,6 +69,10 @@ export class CreateComponent implements OnInit {
this
.
validateForm
.
get
(
'
icon
'
)
!
.
setValue
(
res
||
''
)
}
onIconBlur
(
e
)
{
this
.
iconUrl
=
e
.
target
.
value
}
hanldeOneSelect
(
value
)
{
if
(
!
value
)
return
...
...
src/components/dropdown/dropdown.component.html
浏览文件 @
a2ce5cce
...
...
@@ -42,14 +42,20 @@
<nz-form-item
*ngIf=
"getEditType() === EditType.isWebsite"
>
<nz-form-label
[nzSpan]=
"4"
nzRequired
>
网站链接
</nz-form-label>
<nz-form-control
[nzSpan]=
"20"
>
<input
formControlName=
"url"
nz-input
placeholder=
"https://nav3.cn"
/>
<input
formControlName=
"url"
nz-input
placeholder=
"https://nav3.cn"
(blur)=
"onUrlBlur($event)"
/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label
[nzSpan]=
"4"
>
图标地址
</nz-form-label>
<nz-form-control
[nzSpan]=
"20"
>
<input
formControlName=
"icon"
nz-input
placeholder=
"https://example.com/favicon.png"
/>
<nz-input-group
[nzPrefix]=
"prefixIcon"
>
<input
formControlName=
"icon"
nz-input
placeholder=
"https://example.com/favicon.png"
(blur)=
"onIconBlur($event)"
/>
</nz-input-group>
<ng-template
#prefixIcon
>
<app-logo
[src]=
"iconUrl"
[size]=
"25"
*ngIf=
"iconUrl"
></app-logo>
</ng-template>
</nz-form-control>
</nz-form-item>
...
...
src/components/dropdown/dropdown.component.ts
浏览文件 @
a2ce5cce
...
...
@@ -3,7 +3,7 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'
import
{
NzMessageService
}
from
'
ng-zorro-antd/message
'
import
{
NzNotificationService
}
from
'
ng-zorro-antd/notification
'
import
{
getToken
}
from
'
../../utils/user
'
import
{
setWebsiteList
,
queryString
}
from
'
../../utils
'
import
{
setWebsiteList
,
queryString
,
getLogoUrl
}
from
'
../../utils
'
import
{
websiteList
,
isEditing
}
from
'
../../store
'
import
{
Router
}
from
'
@angular/router
'
import
{
setAnnotate
}
from
'
../../utils/ripple
'
...
...
@@ -34,6 +34,7 @@ export class DropdownComponent implements OnInit {
isEditing
=
isEditing
showModal
=
false
EditType
=
EditType
iconUrl
=
''
constructor
(
private
fb
:
FormBuilder
,
...
...
@@ -54,6 +55,16 @@ export class DropdownComponent implements OnInit {
});
}
async
onUrlBlur
(
e
)
{
const
res
=
await
getLogoUrl
(
e
.
target
?.
value
)
this
.
iconUrl
=
(
res
||
''
)
as
string
this
.
validateForm
.
get
(
'
icon
'
)
!
.
setValue
(
res
||
''
)
}
onIconBlur
(
e
)
{
this
.
iconUrl
=
e
.
target
.
value
}
hasKeyword
()
{
return
!!
queryString
().
q
}
...
...
src/components/fixbar/index.component.ts
浏览文件 @
a2ce5cce
...
...
@@ -64,6 +64,7 @@ export class FixbarComponent {
const
date
=
document
.
getElementById
(
'
BUILD-DATE-NAV
'
)?.
dataset
?.
date
this
.
modal
.
info
({
nzWidth
:
500
,
nzTitle
:
'
以下信息只有您能查看,请放心!
'
,
nzOkText
:
'
知道了
'
,
nzContent
:
`
...
...
src/utils/index.ts
浏览文件 @
a2ce5cce
...
...
@@ -259,29 +259,39 @@ export function isDark(): boolean {
export
async
function
getLogoUrl
(
url
:
string
):
Promise
<
boolean
|
string
>
{
try
{
// const c = ['/favicon.ico', '/favicon.png', '/logo.png', '/favicon.svg', '/favicon.jp
g']
const
c
=
[
'
/favicon.png
'
,
'
/favicon.svg
'
,
'
/favicon.jpg
'
,
'
/favicon.ico
'
,
'
/logo.pn
g
'
]
const
{
origin
}
=
new
URL
(
url
)
const
iconUrl
=
origin
+
'
/favicon.ico
'
return
new
Promise
(
resolve
=>
{
try
{
const
img
=
document
.
createElement
(
'
img
'
)
img
.
src
=
iconUrl
img
.
style
.
display
=
'
none
'
img
.
onload
=
()
=>
{
img
.
parentNode
.
removeChild
(
img
)
resolve
(
iconUrl
)
}
img
.
onerror
=
()
=>
{
img
.
parentNode
.
removeChild
(
img
)
const
promises
=
c
.
map
(
url
=>
{
const
iconUrl
=
origin
+
url
return
new
Promise
(
resolve
=>
{
try
{
const
img
=
document
.
createElement
(
'
img
'
)
img
.
src
=
iconUrl
img
.
style
.
display
=
'
none
'
img
.
onload
=
()
=>
{
img
.
parentNode
.
removeChild
(
img
)
resolve
(
iconUrl
)
}
img
.
onerror
=
()
=>
{
img
.
parentNode
.
removeChild
(
img
)
resolve
(
false
)
}
document
.
body
.
append
(
img
)
}
catch
(
error
)
{
resolve
(
false
)
}
document
.
body
.
append
(
img
)
}
catch
(
error
)
{
resolve
(
false
)
}
})
})
const
all
=
await
Promise
.
all
<
any
>
(
promises
)
for
(
let
i
=
0
;
i
<
all
.
length
;
i
++
)
{
if
(
all
[
i
])
{
return
all
[
i
]
}
}
}
catch
{
return
false
return
null
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录