chore: update README and clean up code structure
This commit is contained in:
24
kevisual.json
Normal file
24
kevisual.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"metadata": {
|
||||||
|
"name": "kevisual",
|
||||||
|
"share": "public"
|
||||||
|
},
|
||||||
|
"ignore": [
|
||||||
|
".swc"
|
||||||
|
],
|
||||||
|
"registry": "https://kevisual.cn/root/ai/kevisual/mini/taro-template",
|
||||||
|
"clone": {
|
||||||
|
".": {
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"syncd": [
|
||||||
|
{
|
||||||
|
"files": [
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"registry": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sync": {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
|
||||||
|
## clone
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ev sync clone -i https://kevisual.cn/root/ai/kevisual/mini/taro-template/kevisual.json
|
||||||
|
```
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
import React, { useEffect } from 'react'
|
import { useEffect } from 'react'
|
||||||
import { useDidShow, useDidHide } from '@tarojs/taro'
|
import { useDidShow, useDidHide } from '@tarojs/taro'
|
||||||
// 全局样式
|
// 全局样式
|
||||||
import './app.scss'
|
import './app.scss'
|
||||||
|
|
||||||
function App(props) {
|
function App(props) {
|
||||||
// 可以使用所有的 React Hooks
|
// 可以使用所有的 React Hooks
|
||||||
useEffect(() => {})
|
useEffect(() => { })
|
||||||
|
|
||||||
// 对应 onShow
|
// 对应 onShow
|
||||||
useDidShow(() => {})
|
useDidShow(() => { })
|
||||||
|
|
||||||
// 对应 onHide
|
// 对应 onHide
|
||||||
useDidHide(() => {})
|
useDidHide(() => { })
|
||||||
|
|
||||||
return props.children
|
return props.children
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
import React, { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { View } from '@tarojs/components'
|
import { View } from '@tarojs/components'
|
||||||
import { Button, ConfigProvider, TextArea, Dialog } from '@nutui/nutui-react-taro'
|
import { ConfigProvider } from '@nutui/nutui-react-taro'
|
||||||
import enUS from '@nutui/nutui-react-taro/dist/locales/en-US'
|
|
||||||
import zhCN from '@nutui/nutui-react-taro/dist/locales/zh-CN'
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
function Index() {
|
function Index() {
|
||||||
const [locale, setLocale] = useState(zhCN)
|
|
||||||
const localeKey = locale === zhCN ? 'zhCN' : 'enUS'
|
|
||||||
const [visible, setVisible] = useState(false)
|
|
||||||
const [translated] = useState({
|
const [translated] = useState({
|
||||||
zhCN: {
|
zhCN: {
|
||||||
welcome: '欢迎使用 NutUI React 开发 Taro 多端项目。',
|
welcome: '欢迎使用 NutUI React 开发 Taro 多端项目。',
|
||||||
@@ -20,28 +15,11 @@ function Index() {
|
|||||||
open: 'Click Me',
|
open: 'Click Me',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const handleSwitchLocale = () => {
|
|
||||||
setLocale(locale === zhCN ? enUS : zhCN)
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<ConfigProvider locale={locale}>
|
<ConfigProvider>
|
||||||
<View className='nutui-react-demo'>
|
<View className='nutui-react-demo'>
|
||||||
<View>{translated[localeKey].welcome}</View>
|
<View className='welcome'>{translated.zhCN.welcome}</View>
|
||||||
<View>
|
|
||||||
<Button type='primary' onClick={handleSwitchLocale}>
|
|
||||||
{translated[localeKey].button}
|
|
||||||
</Button>
|
|
||||||
<Button type='success' onClick={() => setVisible(true)}>
|
|
||||||
{translated[localeKey].open}
|
|
||||||
</Button>
|
|
||||||
<Dialog
|
|
||||||
visible={visible}
|
|
||||||
onConfirm={() => setVisible(false)}
|
|
||||||
onCancel={() => setVisible(false)}>
|
|
||||||
{translated[localeKey].welcome}
|
|
||||||
</Dialog>
|
|
||||||
<TextArea disabled showCount maxLength={20} />
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user