Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
c22de5c3
提交
c22de5c3
authored
1月 11, 2021
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: useI18n type
上级
3509ebec
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
21 行增加
和
5 行删除
+21
-5
useI18n.ts
src/hooks/web/useI18n.ts
+18
-3
index.vue
src/views/demo/feat/img-preview/index.vue
+3
-2
没有找到文件。
src/hooks/web/useI18n.ts
浏览文件 @
c22de5c3
import
{
i18n
}
from
'/@/locales/setupI18n'
;
import
{
i18n
}
from
'/@/locales/setupI18n'
;
export
function
useI18n
(
namespace
?:
string
)
{
type
I18nGlobalTranslation
=
{
(
key
:
string
):
string
;
(
key
:
string
,
locale
:
string
):
string
;
(
key
:
string
,
locale
:
string
,
list
:
unknown
[]):
string
;
(
key
:
string
,
locale
:
string
,
named
:
Record
<
string
,
unknown
>
):
string
;
(
key
:
string
,
list
:
unknown
[]):
string
;
(
key
:
string
,
named
:
Record
<
string
,
unknown
>
):
string
;
};
type
I18nTranslationRestParameters
=
[
string
,
any
];
export
function
useI18n
(
namespace
?:
string
):
{
t
:
I18nGlobalTranslation
;
}
{
function
getKey
(
key
:
string
)
{
function
getKey
(
key
:
string
)
{
if
(
!
namespace
)
{
if
(
!
namespace
)
{
return
key
;
return
key
;
...
@@ -22,9 +37,9 @@ export function useI18n(namespace?: string) {
...
@@ -22,9 +37,9 @@ export function useI18n(namespace?: string) {
const
{
t
,
...
methods
}
=
i18n
.
global
;
const
{
t
,
...
methods
}
=
i18n
.
global
;
const
tFn
:
typeof
t
=
(
key
:
string
,
...
arg
:
any
)
=>
{
const
tFn
:
I18nGlobalTranslation
=
(
key
:
string
,
...
arg
:
any
[]
)
=>
{
if
(
!
key
)
return
''
;
if
(
!
key
)
return
''
;
return
t
(
getKey
(
key
),
...(
arg
as
Parameters
<
typeof
t
>
));
return
t
(
getKey
(
key
),
...(
arg
as
I18nTranslationRestParameters
));
};
};
return
{
return
{
...
methods
,
...
methods
,
...
...
src/views/demo/feat/img-preview/index.vue
浏览文件 @
c22de5c3
<
template
>
<
template
>
<PageWrapper
title=
"图片预览示例"
>
<PageWrapper
title=
"图片预览示例"
>
<ImagePreview
:imageList=
"imgList"
/>
<Alert
message=
"有预览图"
type=
"info"
/>
<Alert
message=
"有预览图"
type=
"info"
/>
<div
class=
"flex justify-center mt-4"
>
<div
class=
"flex justify-center mt-4"
>
<img
:src=
"img"
v-for=
"img in imgList"
:key=
"img"
class=
"mr-2"
@
click=
"handleClick(img)"
/>
<img
:src=
"img"
v-for=
"img in imgList"
:key=
"img"
class=
"mr-2"
@
click=
"handleClick(img)"
/>
...
@@ -11,7 +12,7 @@
...
@@ -11,7 +12,7 @@
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'vue'
;
import
{
defineComponent
}
from
'vue'
;
import
{
Alert
}
from
'ant-design-vue'
;
import
{
Alert
}
from
'ant-design-vue'
;
import
{
createImgPreview
}
from
'/@/components/Preview/index'
;
import
{
createImgPreview
,
ImagePreview
}
from
'/@/components/Preview/index'
;
import
{
PageWrapper
}
from
'/@/components/Page'
;
import
{
PageWrapper
}
from
'/@/components/Page'
;
const
imgList
:
string
[]
=
[
const
imgList
:
string
[]
=
[
...
@@ -20,7 +21,7 @@
...
@@ -20,7 +21,7 @@
'https://picsum.photos/id/68/346/216'
,
'https://picsum.photos/id/68/346/216'
,
];
];
export
default
defineComponent
({
export
default
defineComponent
({
components
:
{
Alert
,
PageWrapper
},
components
:
{
Alert
,
PageWrapper
,
ImagePreview
},
setup
()
{
setup
()
{
function
handleClick
(
img
:
string
)
{
function
handleClick
(
img
:
string
)
{
createImgPreview
({
imageList
:
[
img
]
});
createImgPreview
({
imageList
:
[
img
]
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论