|
@@ -7,109 +7,8 @@
|
|
@Desc : ente point
|
|
@Desc : ente point
|
|
'''
|
|
'''
|
|
|
|
|
|
-import logging
|
|
|
|
|
|
+from app import App
|
|
|
|
|
|
-import flet as ft
|
|
|
|
-from app.pages.home import HomePage
|
|
|
|
-from app.pages.todo import TodoPage
|
|
|
|
-from app.pages.plotly_chart import ChartPage
|
|
|
|
-
|
|
|
|
-import plotly.graph_objects as go
|
|
|
|
-from flet.plotly_chart import PlotlyChart
|
|
|
|
-
|
|
|
|
-from flet import AppBar
|
|
|
|
-from flet import Card
|
|
|
|
-from flet import Column
|
|
|
|
-from flet import Container
|
|
|
|
-from flet import ElevatedButton
|
|
|
|
-from flet import IconButton
|
|
|
|
-from flet import NavigationRail
|
|
|
|
-from flet import NavigationRailDestination
|
|
|
|
-from flet import Page
|
|
|
|
-from flet import Row
|
|
|
|
-from flet import Stack
|
|
|
|
-from flet import Switch
|
|
|
|
-from flet import Text
|
|
|
|
-from flet import VerticalDivider
|
|
|
|
-from flet import colors
|
|
|
|
-from flet import icons
|
|
|
|
-from flet.utils import slugify
|
|
|
|
-
|
|
|
|
-def main(page: ft.Page):
|
|
|
|
- ''' main '''
|
|
|
|
- log_format = "%(asctime)s - %(levelname)s - %(message)s"
|
|
|
|
- logging.basicConfig(filename='app.log', level=logging.DEBUG, format=log_format)
|
|
|
|
- logging.info('程序启动')
|
|
|
|
-
|
|
|
|
- content = HomePage()
|
|
|
|
- def menu_changed(e):
|
|
|
|
- ''' menu change evnet '''
|
|
|
|
- content.controls.clear()
|
|
|
|
- if e.control.selected_index == 0:
|
|
|
|
- content.controls.append(HomePage())
|
|
|
|
- elif e.control.selected_index == 1:
|
|
|
|
- content.controls.append(TodoPage())
|
|
|
|
- elif e.control.selected_index == 2:
|
|
|
|
- content.controls.append(ft.Text("商品库!"))
|
|
|
|
- elif e.control.selected_index == 3:
|
|
|
|
- fig = ChartPage().DrawChart()
|
|
|
|
- # fig.show()
|
|
|
|
- content.controls.append(PlotlyChart(fig, expand=True))
|
|
|
|
- elif e.control.selected_index == 4:
|
|
|
|
- content.controls.append(ft.Text("Setting!"))
|
|
|
|
- page.update()
|
|
|
|
-
|
|
|
|
- rail = ft.NavigationRail(
|
|
|
|
- selected_index=0,
|
|
|
|
- label_type=ft.NavigationRailLabelType.ALL,
|
|
|
|
- # extended=True,
|
|
|
|
- min_width=100,
|
|
|
|
- min_extended_width=400,
|
|
|
|
- # leading=ft.FloatingActionButton(icon=ft.icons.CREATE, text="Add"),
|
|
|
|
- group_alignment=-0.9,
|
|
|
|
- destinations=[
|
|
|
|
- ft.NavigationRailDestination(
|
|
|
|
- icon=ft.icons.HOME, selected_icon=ft.icons.HOME, label="首页"
|
|
|
|
- ),
|
|
|
|
- ft.NavigationRailDestination(
|
|
|
|
- icon_content=ft.Icon(ft.icons.FAVORITE),
|
|
|
|
- selected_icon_content=ft.Icon(name=ft.icons.FAVORITE, color=ft.colors.PINK),
|
|
|
|
- label="关键词",
|
|
|
|
- ),
|
|
|
|
- ft.NavigationRailDestination(
|
|
|
|
- icon_content=ft.Icon(ft.icons.SHOPIFY),
|
|
|
|
- selected_icon_content=ft.Icon(name=ft.icons.SHOPIFY, color=ft.colors.PINK),
|
|
|
|
- label="商品库",
|
|
|
|
- ),
|
|
|
|
- ft.NavigationRailDestination(
|
|
|
|
- icon_content=ft.Icon(ft.icons.BAR_CHART),
|
|
|
|
- selected_icon_content=ft.Icon(name=ft.icons.BAR_CHART, color=ft.colors.PINK),
|
|
|
|
- label="数据分析",
|
|
|
|
- ),
|
|
|
|
- ft.NavigationRailDestination(
|
|
|
|
- icon=ft.icons.SETTINGS_OUTLINED,
|
|
|
|
- selected_icon_content=ft.Icon(ft.icons.SETTINGS),
|
|
|
|
- label_content=ft.Text("Settings"),
|
|
|
|
- ),
|
|
|
|
- ],
|
|
|
|
- on_change=menu_changed,
|
|
|
|
- )
|
|
|
|
- page.title = 'First App'
|
|
|
|
- # menu_button = IconButton(icons.MENU)
|
|
|
|
- # page.appbar = AppBar(
|
|
|
|
- # leading=menu_button,
|
|
|
|
- # leading_width=40,
|
|
|
|
- # bgcolor=colors.SURFACE_VARIANT,
|
|
|
|
- # )
|
|
|
|
-
|
|
|
|
- page.add(
|
|
|
|
- ft.Row(
|
|
|
|
- [
|
|
|
|
- rail,
|
|
|
|
- ft.VerticalDivider(width=1),
|
|
|
|
- content,
|
|
|
|
- ],
|
|
|
|
- expand=True,
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
-ft.app(target=main, view=ft.WEB_BROWSER)
|
|
|
|
|
|
+if __name__=='__main__':
|
|
|
|
+ app = App()
|
|
|
|
+ app.run()
|