wnm168 commited on
Commit
2e32b91
·
verified ·
1 Parent(s): e63cb1c

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +144 -0
index.html CHANGED
@@ -31,6 +31,8 @@
31
  <script src="https://unpkg.com/@tanstack/react-query@4/build/umd/index.production.js"></script>
32
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mitt.umd.min.js"></script>
33
  <script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js"></script>
 
 
34
 
35
  <style>
36
  .bi {
@@ -233,6 +235,18 @@
233
  //事件监听结束
234
 
235
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  var settingStorage = localforage.createInstance({
237
  name: "setting",
238
  driver: localforage.LOCALSTORAGE
@@ -660,6 +674,25 @@
660
  };
661
  //axios封闭结束
662
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  //API定义开始
664
  const getFiles = () => {
665
  const [response, error, loading, fetchData] = useAxios();
@@ -681,6 +714,13 @@
681
  };
682
  return [response, error, loading, fetchDataByPage];
683
  };
 
 
 
 
 
 
 
684
  //API定义结束
685
 
686
  const Layout = ({ children }) => {
@@ -794,6 +834,21 @@
794
  />
795
  离线管理
796
  </Nav.Link>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
797
  </Nav>
798
  </Container>
799
  </Offcanvas.Body>
@@ -852,6 +907,94 @@
852
  );
853
  };
854
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855
 
856
 
857
  const LocalTasks = () => {
@@ -1190,6 +1333,7 @@
1190
  <Route path="/:path?">
1191
  <Layout>
1192
  <Switch>
 
1193
  <Route path="/" exact component={App} />
1194
  <Route path="/:folder?" component={App} />
1195
  </Switch>
 
31
  <script src="https://unpkg.com/@tanstack/react-query@4/build/umd/index.production.js"></script>
32
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mitt.umd.min.js"></script>
33
  <script src="https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js"></script>
34
+ <script src="https://cdn.jsdelivr.net/npm/@fancyapps/[email protected]/dist/fancybox/fancybox.umd.js"></script>
35
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/[email protected]/dist/fancybox/fancybox.css" />
36
 
37
  <style>
38
  .bi {
 
235
  //事件监听结束
236
 
237
 
238
+ Fancybox.bind("[data-fancybox]", {
239
+ Toolbar: {
240
+ display: {
241
+ right: ["slideshow", "download", "thumbs", "close"],
242
+ },
243
+ },
244
+ Images: {
245
+ initialSize: "fit",
246
+ }
247
+ });
248
+
249
+
250
  var settingStorage = localforage.createInstance({
251
  name: "setting",
252
  driver: localforage.LOCALSTORAGE
 
674
  };
675
  //axios封闭结束
676
 
677
+ //分页hooks
678
+ const usePagination = () => {
679
+ const [pagination, setPagination] = useState({
680
+ pageSize: 36,
681
+ pageIndex: 1,
682
+ });
683
+ const { pageSize, pageIndex } = pagination;
684
+
685
+
686
+ return {
687
+ limit: pageSize,
688
+ onPaginationChange: setPagination,
689
+ pagination,
690
+ skip: pageSize * pageIndex,
691
+ };
692
+ }
693
+ //分页结束
694
+
695
+
696
  //API定义开始
697
  const getFiles = () => {
698
  const [response, error, loading, fetchData] = useAxios();
 
714
  };
715
  return [response, error, loading, fetchDataByPage];
716
  };
717
+
718
+ const paginateLinksGet = async (limit, skip) => {
719
+ const setting = STORE.getState().settings;
720
+ const url = setting.directus_host + `items/Video?limit=${limit}&offset=${skip}&meta[]=filter_count`;
721
+ const { data } = await axios.get(url, { headers: { Authorization: "Bearer " + setting.directus_token } })
722
+ return data
723
+ }
724
  //API定义结束
725
 
726
  const Layout = ({ children }) => {
 
834
  />
835
  离线管理
836
  </Nav.Link>
837
+ <Nav.Link
838
+ as={Link}
839
+ className="nav-link text-dark"
840
+ to="/videos"
841
+ onClick={
842
+ handleSidebarClose
843
+ }
844
+ >
845
+ <Icon
846
+ icon="movie"
847
+ size="6"
848
+ className="me-2"
849
+ />
850
+ 视频管理
851
+ </Nav.Link>
852
  </Nav>
853
  </Container>
854
  </Offcanvas.Body>
 
907
  );
908
  };
909
 
910
+ const Videos = () => {
911
+ const [reload, setReload] = useState(false);
912
+ const { limit, onPaginationChange, skip, pagination } = usePagination();
913
+ const [meta, setMeta] = useState({ filter_count: 0 })
914
+ const [videos, setVideos] = useState([])
915
+ const { data: linksData, refetch: linksRefetch, isLoading: linksLoading, error: linksError } = useQuery({
916
+ queryKey: ['get_paginate_links', limit, skip],
917
+ queryFn: () => paginateLinksGet(limit, skip)
918
+ })
919
+
920
+ useEffect(() => {
921
+ //linksRefetch()
922
+ }, [pagination, reload]);
923
+
924
+ useEffect(() => {
925
+ if (linksData) {
926
+ setMeta(linksData.meta)
927
+ setVideos([...linksData.data])
928
+ }
929
+ }, [linksData]);
930
+
931
+
932
+ const forceUpdate = () => {
933
+ setReload((pre) => !pre);
934
+ };
935
+
936
+ return (
937
+ <div>
938
+ <div className="d-flex justify-content-between align-items-center p-2 border-bottom bg-light">
939
+ <label className="fs-3">视频列表</label>
940
+ <ButtonToolbar
941
+ aria-label="视频列表"
942
+ className="bg-teal rounded"
943
+ >
944
+ <ButtonGroup className="bg-teal">
945
+ <IconButton
946
+ onClick={() => {
947
+ forceUpdate();
948
+ }}
949
+ text="刷新"
950
+ className="bg-teal border-0"
951
+ icon="reload"
952
+ iconClassName="me-1 text-white"
953
+ iconSize="6"
954
+ />
955
+ </ButtonGroup>
956
+ </ButtonToolbar>
957
+ </div>
958
+ {linksError && (
959
+ <div className="text-center text-danger">
960
+ 发生错误,请稍后重试!!!
961
+ </div>
962
+ )}
963
+ {(linksLoading) && (
964
+ <div className="text-center text-success">
965
+ 正在努力加载中......
966
+ </div>
967
+ )}
968
+
969
+ <Container fluid className="p-2">
970
+ <Row>
971
+ <Col xs={12} className="py-2">
972
+ <Paginate page={pagination.pageIndex} onClick={(i) => { onPaginationChange({ pageSize: 36, pageIndex: i }) }} itemsPerPage="36" totalCount={meta.filter_count} />
973
+ </Col>
974
+ </Row>
975
+ {linksData && (
976
+ <Row>
977
+ {videos.map((video, index) => (
978
+ <Col xs={6} md={4} className="py-2">
979
+ <a href={video.poster} target="_blank" data-fancybox="gallery"
980
+ data-download-src={video.src} data-caption={video.title}>
981
+ <img src={video.poster} className="img-fluid rounded" />
982
+ </a>
983
+ </Col>
984
+ ))}
985
+ </Row>
986
+ )}
987
+
988
+ <Row>
989
+ <Col xs={12} className="py-2">
990
+ <Paginate page={pagination.pageIndex} onClick={(i) => { onPaginationChange({ pageSize: 36, pageIndex: i }) }} itemsPerPage="36" totalCount={meta.filter_count} />
991
+ </Col>
992
+ </Row>
993
+ </Container>
994
+ </div>
995
+ );
996
+ };
997
+
998
 
999
 
1000
  const LocalTasks = () => {
 
1333
  <Route path="/:path?">
1334
  <Layout>
1335
  <Switch>
1336
+ <Route path="/videos" exact component={Videos} />
1337
  <Route path="/" exact component={App} />
1338
  <Route path="/:folder?" component={App} />
1339
  </Switch>