This repository has been archived by the owner on Nov 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #657 from ice-lab/release-next
Release-rc.6
- Loading branch information
Showing
168 changed files
with
2,529 additions
and
697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,6 @@ export function getConfig(): RouteConfig { | |
scripts: [{ | ||
src: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/lodash.min.js', | ||
}], | ||
auth: ['admin'], | ||
}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
@import '@ice/miniapp-html-styles/html'; | ||
|
||
.global { | ||
font-size: 14px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { defineConfig } from '@ice/app'; | ||
import auth from '@ice/plugin-auth'; | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
auth(), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "with-auth", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"start": "ice start", | ||
"build": "ice build" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@ice/runtime": "workspace:*", | ||
"react": "^18.0.0", | ||
"react-dom": "^18.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ice/app": "workspace:*", | ||
"@ice/plugin-auth": "workspace:*", | ||
"@types/react": "^18.0.0", | ||
"@types/react-dom": "^18.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { defineAppConfig, Link } from 'ice'; | ||
import type { GetAppData } from 'ice'; | ||
import { defineAuthConfig } from '@ice/plugin-auth/esm/types'; | ||
|
||
export default defineAppConfig({}); | ||
|
||
export const auth = defineAuthConfig((data) => { | ||
// fetch auth data | ||
return { | ||
initialAuth: { | ||
admin: data?.auth?.admin, | ||
}, | ||
NoAuthFallback: () => { | ||
return ( | ||
<> | ||
<div id="no-auth">无权限访问</div> | ||
<Link to="/">Home</Link> | ||
</> | ||
); | ||
}, | ||
}; | ||
}); | ||
|
||
export const getAppData: GetAppData = () => { | ||
return new Promise((resolve) => { | ||
resolve({ | ||
auth: { | ||
admin: true, | ||
}, | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useAuth } from 'ice'; | ||
|
||
function CustomAuth({ children, authKey, fallback }) { | ||
const [auth] = useAuth(); | ||
// 判断是否有权限 | ||
const hasAuth = auth[authKey]; | ||
// 有权限时直接渲染内容 | ||
if (hasAuth) { | ||
return children; | ||
} else { | ||
// 无权限时显示指定 UI | ||
return fallback || (<>No Auth</>); | ||
} | ||
} | ||
|
||
export default CustomAuth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Meta, Title, Links, Main, Scripts } from 'ice'; | ||
|
||
function Document() { | ||
return ( | ||
<html> | ||
<head> | ||
<meta charSet="utf-8" /> | ||
<meta name="description" content="with-auth" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<Meta /> | ||
<Title /> | ||
<Links /> | ||
</head> | ||
<body> | ||
<Main /> | ||
<Scripts /> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
export default Document; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { defineGetConfig, Link } from 'ice'; | ||
|
||
export default function Blog() { | ||
return ( | ||
<> | ||
<h1>Blog</h1> | ||
<Link to="/">Index</Link> | ||
</> | ||
); | ||
} | ||
|
||
export const getConfig = defineGetConfig(() => { | ||
return { | ||
title: 'Blog', | ||
auth: ['guest'], | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Link, useAuth, defineGetConfig } from 'ice'; | ||
import CustomAuth from '@/components/CustomAuth'; | ||
|
||
export default function Index() { | ||
const [, setAuth] = useAuth(); | ||
return ( | ||
<> | ||
<ul style={{ listStyleType: 'none' }}> | ||
<li><Link to="blog">Blog</Link></li> | ||
</ul> | ||
<h1>Index</h1> | ||
<CustomAuth authKey={'guest'} fallback={<><div onClick={() => setAuth({ guest: true })}>Set Guest Auth</div>No Auth</>}> | ||
I am ice.js. My auth is guest. | ||
</CustomAuth> | ||
</> | ||
); | ||
} | ||
|
||
export const getConfig = defineGetConfig(() => { | ||
return { | ||
title: 'Index', | ||
auth: ['admin'], | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "./", | ||
"module": "ESNext", | ||
"target": "ESNext", | ||
"lib": ["DOM", "ESNext", "DOM.Iterable"], | ||
"jsx": "react-jsx", | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": false, | ||
"importHelpers": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"skipLibCheck": true, | ||
"paths": { | ||
"@/*": ["./src/*"], | ||
"ice": [".ice"] | ||
} | ||
}, | ||
"include": ["src", ".ice"], | ||
"exclude": ["build"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { history } from 'ice'; | ||
import store from '@/store'; | ||
|
||
export default function Login() { | ||
const [, userDispatcher] = store.useModel('user'); | ||
|
||
function login() { | ||
userDispatcher.setState({ name: 'Hello' }); | ||
history?.push('/'); | ||
} | ||
|
||
return ( | ||
<div onClick={() => login()} id="login-click">Click Me to Login</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/// <reference types="@ice/app/types" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineConfig } from '@ice/app'; | ||
|
||
export default defineConfig({ | ||
postcss: { | ||
plugins: [ | ||
'tailwindcss', | ||
], | ||
}, | ||
}); |
Oops, something went wrong.