-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
raojinlin
committed
Mar 22, 2023
1 parent
b8b60b1
commit d417b34
Showing
20 changed files
with
120 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,51 @@ | ||
这是一个记事本应用,支持离线模式和云端同步模式 | ||
这是一个记事本PWA应用,支持离线模式和云端同步模式。 | ||
|
||
## Getting Started | ||
## 特性 | ||
* 离线可用 | ||
* 云端同步 | ||
* 笔记下载 | ||
* 可配置自动同步 | ||
|
||
First, run the development server: | ||
## 技术栈 | ||
* 前端 | ||
* NextJS | ||
* MUI | ||
* 后端 | ||
* Vercel serverless function (NodeJS) | ||
* MongoDB | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
## 安装应用 | ||
|
||
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file. | ||
打开网址[https://notepad-nine.vercel.app/](https://notepad-nine.vercel.app/),右上角会出现一个安装提示,点击它安装。 | ||
|
||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`. | ||
 | ||
安装后会自动打开,可以在`chrome://apps`查看。 | ||
 | ||
|
||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. | ||
 | ||
|
||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
|
||
## Learn More | ||
## 截图 | ||
Web | ||
 | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
移动端 | ||
 | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
## 开发 | ||
后端连接mangodb依赖`MONGODB_URL`变量,本地开发需要配置.env文件 | ||
```.dotenv | ||
MONGODB_URI=mongodb+srv://[username]:[password]@[cluster-host]/?retryWrites=true&w=majority | ||
``` | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
运行开发环境 | ||
```bash | ||
$ npm i | ||
$ npm run dev | ||
``` | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. | ||
## 部署到vercel | ||
``` | ||
$ vercel vercel -e NODE_ENV=production -e MANGODB_URL= | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const isDev = process.env.NODE_ENV !== "production"; | ||
|
||
|
||
const withPWA = require('next-pwa')({ | ||
dest: 'public', | ||
exclude: [ | ||
// add buildExcludes here | ||
({ asset, compilation }) => { | ||
if ( | ||
asset.name.startsWith("server/") || | ||
asset.name.match(/^((app-|^)build-manifest\.json|react-loadable-manifest\.json)$/) | ||
) { | ||
return true; | ||
} | ||
|
||
return isDev && !asset.name.startsWith("static/runtime/"); | ||
} | ||
], | ||
}); | ||
|
||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
} | ||
|
||
module.exports = process.env.NODE_ENV === 'production' ? withPWA(nextConfig) : nextConfig; | ||
module.exports = isDev ? nextConfig : withPWA(nextConfig); |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import styles from './page.module.css' | ||
import Notepad from "@/app/components/Notepad"; | ||
|
||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"use client" | ||
|
||
import { useEffect } from "react"; | ||
|
||
export default function Pwa() { | ||
let sw; | ||
if (typeof window !== "undefined") { | ||
sw = window?.navigator?.serviceWorker; | ||
} | ||
|
||
useEffect(() => { | ||
if (sw) { | ||
sw.register("/sw.js", { scope: "/" }).then((registration) => { | ||
console.log("Service Worker registration successful with scope: ", registration.scope); | ||
}).catch((err) => { | ||
console.log("Service Worker registration failed: ", err); | ||
}); | ||
} | ||
}, [sw]); | ||
|
||
return ( | ||
<></> | ||
) | ||
} |
d417b34
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
notepad – ./
notepad-raojinlin.vercel.app
notepad-git-main-raojinlin.vercel.app
notepad-nine.vercel.app