From b76faea13324bee713afc8766d6812c459bac95b Mon Sep 17 00:00:00 2001 From: spacemeowx2 Date: Fri, 3 Mar 2023 22:06:14 +0800 Subject: [PATCH] build: add baseUrl --- gui/.editorconfig | 12 ++++++++++++ gui/package.json | 3 ++- gui/pnpm-lock.yaml | 30 ++++++++++++++++++++++++++++++ gui/src/App.tsx | 33 +++++++++++---------------------- gui/src/components/Layout.tsx | 10 ++++++++++ gui/src/pages/Home.tsx | 7 +++++++ gui/tsconfig.json | 1 + gui/vite.config.ts | 3 ++- 8 files changed, 75 insertions(+), 24 deletions(-) create mode 100644 gui/.editorconfig create mode 100644 gui/src/components/Layout.tsx create mode 100644 gui/src/pages/Home.tsx diff --git a/gui/.editorconfig b/gui/.editorconfig new file mode 100644 index 0000000..ebe51d3 --- /dev/null +++ b/gui/.editorconfig @@ -0,0 +1,12 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = false +insert_final_newline = false \ No newline at end of file diff --git a/gui/package.json b/gui/package.json index 8671ce4..df6a522 100644 --- a/gui/package.json +++ b/gui/package.json @@ -25,6 +25,7 @@ "postcss": "^8.4.21", "tailwindcss": "^3.2.7", "typescript": "^4.9.5", - "vite": "^4.1.4" + "vite": "^4.1.4", + "vite-tsconfig-paths": "^4.0.5" } } \ No newline at end of file diff --git a/gui/pnpm-lock.yaml b/gui/pnpm-lock.yaml index b2ad054..f64e8d2 100644 --- a/gui/pnpm-lock.yaml +++ b/gui/pnpm-lock.yaml @@ -15,6 +15,7 @@ specifiers: tailwindcss: ^3.2.7 typescript: ^4.9.5 vite: ^4.1.4 + vite-tsconfig-paths: ^4.0.5 dependencies: '@tauri-apps/api': 1.2.0 @@ -33,6 +34,7 @@ devDependencies: tailwindcss: 3.2.7_postcss@8.4.21 typescript: 4.9.5 vite: 4.1.4_@types+node@18.14.5 + vite-tsconfig-paths: 4.0.5_typescript@4.9.5 packages: @@ -950,6 +952,10 @@ packages: engines: {node: '>=4'} dev: true + /globrex/0.1.2: + resolution: {integrity: sha512-uHJgbwAMwNFf5mLst7IWLNg14x1CkeqglJb/K3doi4dw6q2IvAAmM/Y81kevy83wP+Sst+nutFTYOGg3d1lsxg==} + dev: true + /has-flag/3.0.0: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} @@ -1335,6 +1341,19 @@ packages: is-number: 7.0.0 dev: true + /tsconfck/2.0.3_typescript@4.9.5: + resolution: {integrity: sha512-o3DsPZO1+C98KqHMdAbWs30zpxD30kj8r9OLA4ML1yghx4khNDzaaShNalfluh8ZPPhzKe3qyVCP1HiZszSAsw==} + engines: {node: ^14.13.1 || ^16 || >=18} + hasBin: true + peerDependencies: + typescript: ^4.3.5 + peerDependenciesMeta: + typescript: + optional: true + dependencies: + typescript: 4.9.5 + dev: true + /typescript/4.9.5: resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} engines: {node: '>=4.2.0'} @@ -1356,6 +1375,17 @@ packages: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: true + /vite-tsconfig-paths/4.0.5_typescript@4.9.5: + resolution: {integrity: sha512-/L/eHwySFYjwxoYt1WRJniuK/jPv+WGwgRGBYx3leciR5wBeqntQpUE6Js6+TJemChc+ter7fDBKieyEWDx4yQ==} + dependencies: + debug: 4.3.4 + globrex: 0.1.2 + tsconfck: 2.0.3_typescript@4.9.5 + transitivePeerDependencies: + - supports-color + - typescript + dev: true + /vite/4.1.4_@types+node@18.14.5: resolution: {integrity: sha512-3knk/HsbSTKEin43zHu7jTwYWv81f8kgAL99G5NWBcA1LKvtvcVAC4JjBH1arBunO9kQka+1oGbrMKOjk4ZrBg==} engines: {node: ^14.18.0 || >=16.0.0} diff --git a/gui/src/App.tsx b/gui/src/App.tsx index 0c49c26..f6983f5 100644 --- a/gui/src/App.tsx +++ b/gui/src/App.tsx @@ -1,28 +1,17 @@ -import { useState } from "react"; -import reactLogo from "./assets/react.svg"; -import { invoke } from "@tauri-apps/api/tauri"; -import { Routes, Route, Outlet, Link } from "react-router-dom"; +import { + +} from "@tauri-apps/api/window"; +import { Routes, Route } from "react-router-dom"; +import { Layout } from "components/Layout"; +import { Home } from "pages/Home"; function App() { return ( -
-

Welcome to Tauri!

- -
- - Vite logo - - - Tauri logo - - - React logo - -
- -
-
-
+ + }> + } /> + + ); } diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx new file mode 100644 index 0000000..df11dda --- /dev/null +++ b/gui/src/components/Layout.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { Outlet } from "react-router-dom"; + +export const Layout: React.FC = () => { + return ( +
+ +
+ ); +}; \ No newline at end of file diff --git a/gui/src/pages/Home.tsx b/gui/src/pages/Home.tsx new file mode 100644 index 0000000..1f2efc8 --- /dev/null +++ b/gui/src/pages/Home.tsx @@ -0,0 +1,7 @@ +import React from 'react' + +export const Home: React.FC = ({ }) => { + return <> + Hello world! + +} \ No newline at end of file diff --git a/gui/tsconfig.json b/gui/tsconfig.json index 3d0a51a..7959a47 100644 --- a/gui/tsconfig.json +++ b/gui/tsconfig.json @@ -3,6 +3,7 @@ "target": "ESNext", "useDefineForClassFields": true, "lib": ["DOM", "DOM.Iterable", "ESNext"], + "baseUrl": "src", "allowJs": false, "skipLibCheck": true, "esModuleInterop": false, diff --git a/gui/vite.config.ts b/gui/vite.config.ts index ee4440d..5067e19 100644 --- a/gui/vite.config.ts +++ b/gui/vite.config.ts @@ -1,9 +1,10 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; +import tsconfigPaths from 'vite-tsconfig-paths' // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react()], + plugins: [react(), tsconfigPaths()], // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // prevent vite from obscuring rust errors