open link

This commit is contained in:
dangdinh 2023-02-17 14:25:44 +07:00
commit fad8f9be18
12 changed files with 300 additions and 0 deletions

16
.editorconfig Executable file
View File

@ -0,0 +1,16 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab

20
.gitignore vendored Normal file
View File

@ -0,0 +1,20 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/npm-debug.log*
/yarn-error.log
/yarn.lock
/package-lock.json
# production
/dist
# misc
.DS_Store
# umi
/src/.umi
/src/.umi-production
/src/.umi-test
/.env.local

8
.prettierignore Normal file
View File

@ -0,0 +1,8 @@
**/*.md
**/*.svg
**/*.ejs
**/*.html
package.json
.umi
.umi-production
.umi-test

11
.prettierrc Normal file
View File

@ -0,0 +1,11 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80,
"overrides": [
{
"files": ".prettierrc",
"options": { "parser": "json" }
}
]
}

12
.umirc.ts Normal file
View File

@ -0,0 +1,12 @@
import { defineConfig } from 'umi';
export default defineConfig({
nodeModulesTransform: {
type: 'none',
},
routes: [
{ path: '/', component: '@/pages/index' },
{ path: '/action', component: '@/pages/index' },
],
fastRefresh: {},
});

15
README.md Normal file
View File

@ -0,0 +1,15 @@
# umi project
## Getting Started
Install dependencies,
```bash
$ yarn
```
Start the dev server,
```bash
$ yarn start
```

0
mock/.gitkeep Normal file
View File

40
package.json Normal file
View File

@ -0,0 +1,40 @@
{
"private": true,
"scripts": {
"start": "umi dev",
"build": "umi build",
"postinstall": "umi generate tmp",
"prettier": "prettier --write '**/*.{js,jsx,tsx,ts,less,md,json}'",
"test": "umi-test",
"test:coverage": "umi-test --coverage"
},
"gitHooks": {
"pre-commit": "lint-staged"
},
"lint-staged": {
"*.{js,jsx,less,md,json}": [
"prettier --write"
],
"*.ts?(x)": [
"prettier --parser=typescript --write"
]
},
"dependencies": {
"@ant-design/pro-layout": "^6.5.0",
"query-string": "^8.1.0",
"react": "17.x",
"react-device-detect": "^2.2.3",
"react-dom": "17.x",
"umi": "^3.5.37"
},
"devDependencies": {
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@umijs/preset-react": "1.x",
"@umijs/test": "^3.5.37",
"lint-staged": "^10.0.7",
"prettier": "^2.2.0",
"typescript": "^4.1.2",
"yorkie": "^2.0.0"
}
}

68
src/pages/index.css Normal file
View File

@ -0,0 +1,68 @@
@import 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css';
@import 'https://fonts.googleapis.com/css?family=Open+Sans';
* {
font-family: 'Open Sans', 'sans-serif';
}
html,
body {
overflow : hidden;
background-color: #c36;
}
ul {
width : 100%;
text-align: center;
margin : 0;
padding : 0;
position : absolute;
top : 50%;
transform : translateY(-50%);
}
li {
display: inline-block;
margin : 10px;
}
.download {
width : 200px;
height : 75px;
background : black;
float : left;
border-radius: 5px;
position : relative;
color : #fff;
cursor : pointer;
border : 1px solid #fff;
}
.download>.fa {
color : #fff;
position : absolute;
top : 50%;
left : 15px;
transform: translateY(-50%);
}
.df,
.dfn {
position: absolute;
left : 70px;
}
.df {
top : 20px;
font-size: 0.68em;
}
.dfn {
top : 33px;
font-size: 1.08em;
}
.download:hover {
-webkit-filter: invert(100%);
filter : invert(100%);
}

63
src/pages/index.tsx Normal file
View File

@ -0,0 +1,63 @@
import { useEffect } from 'react';
import { isAndroid, isIOS } from 'react-device-detect';
import { useLocation } from 'umi';
import './index.css';
export default function DeepLink() {
const { search, query } = useLocation() as any;
const deeplinkDomain = /(\/(deeplink|dl)\.)/g;
const isDeeplinkDomain = deeplinkDomain.test(window.location.origin);
useEffect(() => {
if (isDeeplinkDomain) {
if (isAndroid) {
window.location.replace(`selly://ACTION${search}`);
return;
}
if (isIOS) {
window.location.replace(`selly://ACTION${search}`);
setTimeout(
() =>
window.location.replace(
`https://apps.apple.com/vn/app/selly-dễ-dàng-bán-hàng/id1554981586`,
),
3000,
);
return;
}
return window.location.replace(query?.redirect || 'https://selly.vn');
}
}, []);
return (
<ul>
<li>
<div
className="download android"
onClick={() => {
window.location.replace(
'https://play.google.com/store/apps/details?id=vn.selly',
);
}}
>
<i className="fa fa fa-android fa-3x"></i>
<span className="df">Download from</span>
<span className="dfn">Google Play</span>
</div>
</li>
<li>
<div
className="download apple"
onClick={() => {
window.location.replace(
'https://apps.apple.com/vn/app/selly-dễ-dàng-bán-hàng/id1554981586',
);
}}
>
<i className="fa fa fa-apple fa-3x"></i>
<span className="df">Download from</span>
<span className="dfn">App Store</span>
</div>
</li>
</ul>
);
}

37
tsconfig.json Normal file
View File

@ -0,0 +1,37 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"importHelpers": true,
"jsx": "react-jsx",
"esModuleInterop": true,
"sourceMap": true,
"baseUrl": "./",
"strict": true,
"paths": {
"@/*": ["src/*"],
"@@/*": ["src/.umi/*"]
},
"allowSyntheticDefaultImports": true
},
"include": [
"mock/**/*",
"src/**/*",
"config/**/*",
".umirc.ts",
"typings.d.ts"
],
"exclude": [
"node_modules",
"lib",
"es",
"dist",
"typings",
"**/__test__",
"test",
"docs",
"tests"
]
}

10
typings.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
declare module '*.css';
declare module '*.less';
declare module '*.png';
declare module '*.svg' {
export function ReactComponent(
props: React.SVGProps<SVGSVGElement>,
): React.ReactElement;
const url: string;
export default url;
}