File tree Expand file tree Collapse file tree 3 files changed +37
-12
lines changed Expand file tree Collapse file tree 3 files changed +37
-12
lines changed Original file line number Diff line number Diff line change @@ -7,12 +7,14 @@ import Input from './components/Input'
7
7
import { FilterContext , FilterType } from './Context'
8
8
import qrCode from './qr-code.png'
9
9
import { SHARE_TARGET_PICKER_FIXED_ARGUMENT_LIST } from './constants'
10
+ import { FilterTypes } from './FilterTypes'
10
11
11
12
type Props = {
12
- filter : FilterType ;
13
- } ;
13
+ appUrl : string
14
+ filter : FilterType
15
+ }
14
16
15
- function App ( { filter } : Props ) {
17
+ function App ( { appUrl , filter } : Props ) {
16
18
let isLoggedIn = false
17
19
try {
18
20
isLoggedIn = liff . isLoggedIn ( )
@@ -24,10 +26,7 @@ function App({ filter }: Props) {
24
26
< Header />
25
27
< div className = { styles . container } >
26
28
< div className = { styles . liffIdBox } >
27
- < Input
28
- readonly
29
- value = { `LIFF URL: https://liff.line.me/${ import . meta. env . VITE_LIFF_ID . toString ( ) } ` }
30
- />
29
+ < Input readonly value = { `URL: ${ appUrl } ` } />
31
30
< img src = { qrCode } className = { styles . qrCode } />
32
31
</ div >
33
32
< h1 > Client APIs</ h1 >
Original file line number Diff line number Diff line change 1
1
export const FilterTypes = {
2
2
LIFF : 'LIFF' ,
3
- MINI : 'MINI'
3
+ MINI : 'MINI' ,
4
+ MINI_PREVIEW : 'MINI_PREVIEW'
4
5
} as const
Original file line number Diff line number Diff line change 1
1
import liff from '@line/liff'
2
2
import React from 'react'
3
3
import ReactDOM from 'react-dom'
4
+ import { LiffCommonProfilePlugin } from '@line/liff-common-profile-plugin'
4
5
import './main.css'
5
6
import App from './App'
6
7
import { FilterTypes } from './FilterTypes'
7
8
8
9
const isMINI = new URLSearchParams ( location . search ) . has ( 'mini' )
9
- const filter = isMINI ? FilterTypes . MINI : FilterTypes . LIFF
10
- const liffId = isMINI ? import . meta. env . VITE_LIFF_ID_MINI : import . meta. env . VITE_LIFF_ID
10
+ const isPreviewMINI = new URLSearchParams ( location . search ) . has ( 'mini_preview' )
11
+
12
+ const filter = isPreviewMINI
13
+ ? FilterTypes . MINI_PREVIEW
14
+ : isMINI
15
+ ? FilterTypes . MINI
16
+ : FilterTypes . LIFF
17
+
18
+ const appId = {
19
+ [ FilterTypes . LIFF ] : import . meta. env . VITE_LIFF_ID ,
20
+ [ FilterTypes . MINI ] : import . meta. env . VITE_LIFF_ID_MINI ,
21
+ [ FilterTypes . MINI_PREVIEW ] : import . meta. env . VITE_LIFF_ID_MINI_PREVIEW
22
+ } [ filter ]
23
+
24
+ const appUrl =
25
+ filter === FilterTypes . LIFF
26
+ ? `https://liff.line.me/${ appId } `
27
+ : `https://miniapp.line.me/${ appId } `
28
+
29
+ const injectPlugins = ( ) => {
30
+ liff . use ( new LiffCommonProfilePlugin ( ) )
31
+ }
32
+
33
+ if ( filter === FilterTypes . MINI || filter === FilterTypes . MINI_PREVIEW ) {
34
+ injectPlugins ( )
35
+ }
11
36
12
37
liff
13
- . init ( { liffId } )
38
+ . init ( { liffId : appId } )
14
39
. then ( ( ) => {
15
40
ReactDOM . render (
16
41
< React . StrictMode >
17
- < App filter = { filter } />
42
+ < App appUrl = { appUrl } filter = { filter } />
18
43
</ React . StrictMode > ,
19
44
document . getElementById ( 'root' )
20
45
)
You can’t perform that action at this time.
0 commit comments