diff --git a/package.json b/package.json
index 37488f3..521723e 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,8 @@
"type": "module",
"scripts": {
"dev": "vite",
- "build": "tsc && vite build && pwsh scripts/build.ps1",
+ "build": "tsc && vite build",
+ "deploy": "tsc && vite build && pwsh scripts/build.ps1",
"preview": "vite preview"
},
"dependencies": {
@@ -32,4 +33,4 @@
"@vitejs/plugin-react": "^2.0.0",
"vite": "^3.0.0"
}
-}
+}
\ No newline at end of file
diff --git a/scripts/build.ps1 b/scripts/build.ps1
index 3d253d0..8a7cd68 100644
--- a/scripts/build.ps1
+++ b/scripts/build.ps1
@@ -1,3 +1,5 @@
$server_path='fadinglight:/root/docker/caddy/site/www'
+ssh fadinglight "rm ${server_path}/* -r"
+
scp -r dist/* $server_path
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index 027bc66..12ac22d 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,31 +1,23 @@
import Layout from './components/layout'
-import {Routes, Route} from 'react-router-dom'
-import {useEffect} from "react";
+import { Routes, Route } from 'react-router-dom'
import Home from './pages/Home/Home'
import NotFound from './pages/NotFound'
-import {Bill, BillContext} from "./store";
+import { Bill, BillContext } from "./store";
import './App.css'
import Record from "./pages/Record/Record";
function App() {
const billStore = new Bill()
- const now = new Date()
-
- useEffect(() => {
- billStore.fetch(now.getFullYear(), now.getMonth() + 1)
- .then()
- .catch(console.dir)
- }, [])
return (
- }/>
- }/>
- }/>
- }/>
+ } />
+ } />
+ } />
+ } />
diff --git a/src/pages/Home/Home.tsx b/src/pages/Home/Home.tsx
index 7c96d14..062aafc 100644
--- a/src/pages/Home/Home.tsx
+++ b/src/pages/Home/Home.tsx
@@ -6,13 +6,7 @@ import { useContext, useEffect, useState } from "react";
import { BillContext } from "../../store";
import { observer } from "mobx-react-lite";
import Pie from "../../components/charts/pie";
-import {
- Card,
- Modal,
- DatePicker,
- Radio,
- Space,
-} from "antd";
+import { Card, Modal, DatePicker, Radio, Space } from "antd";
import moment from 'moment';
import 'moment/locale/zh-cn';
import dayjs from 'dayjs'
diff --git a/src/pages/Record/Record.tsx b/src/pages/Record/Record.tsx
index fa7b1de..bd4ebd1 100644
--- a/src/pages/Record/Record.tsx
+++ b/src/pages/Record/Record.tsx
@@ -28,6 +28,9 @@ function Record() {
if (!!clsRef.current) clsRef.current.focus()
}, [clsRef])
+ useEffect(() => {
+ billStore.fetchLabels().then()
+ }, [])
// table
const columns = [
@@ -117,7 +120,7 @@ function Record() {
const [uploadLoading, setUploadLoading] = useState(false)
const upload = async () => {
setUploadLoading(true)
- datasource.forEach( it => Reflect.deleteProperty(it, "key"))
+ datasource.forEach(it => Reflect.deleteProperty(it, "key"))
try {
await postBills(datasource)
setDataSource([])
diff --git a/src/store/index.ts b/src/store/index.ts
index b2f1d9b..d572219 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -16,7 +16,6 @@ export class Bill {
constructor() {
makeAutoObservable(this)
- this.fetchLabels().then()
}
get bills() {
diff --git a/vite.config.ts b/vite.config.ts
index a5ccdb7..221c0e2 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -7,7 +7,7 @@ export default defineConfig({
server: {
proxy: {
"/api/": {
- target: "https://www.fadinglight.cn/api/",
+ target: "https://bill.fadinglight.cn/api/",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ""),
}