Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
c22de5c3
Commit
c22de5c3
authored
Jan 11, 2021
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: useI18n type
parent
3509ebec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
useI18n.ts
src/hooks/web/useI18n.ts
+18
-3
index.vue
src/views/demo/feat/img-preview/index.vue
+3
-2
No files found.
src/hooks/web/useI18n.ts
View file @
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
View file @
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
]
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment