mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-23 23:04:04 +00:00
Own files for i18n and router + fix some of markdown warnings
This commit is contained in:
parent
2d7767c905
commit
54ffef8b7a
6 changed files with 149 additions and 164 deletions
|
@ -52,8 +52,8 @@ For example, recently, because I am not a python expert, I spent a 2 hours to re
|
||||||
|
|
||||||
# Coding Styles
|
# Coding Styles
|
||||||
|
|
||||||
- Follow .editorconfig
|
- Follow `.editorconfig`
|
||||||
- Follow eslint
|
- Follow ESLint
|
||||||
|
|
||||||
## Name convention
|
## Name convention
|
||||||
|
|
||||||
|
@ -62,9 +62,10 @@ For example, recently, because I am not a python expert, I spent a 2 hours to re
|
||||||
- CSS/SCSS: dash-type
|
- CSS/SCSS: dash-type
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
|
|
||||||
- Node.js >= 14
|
- Node.js >= 14
|
||||||
- Git
|
- Git
|
||||||
- IDE that supports .editorconfig and eslint (I am using Intellji Idea)
|
- IDE that supports EditorConfig and ESLint (I am using Intellji Idea)
|
||||||
- A SQLite tool (I am using SQLite Expert Personal)
|
- A SQLite tool (I am using SQLite Expert Personal)
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
@ -75,7 +76,7 @@ npm install --dev
|
||||||
|
|
||||||
For npm@7, you need --legacy-peer-deps
|
For npm@7, you need --legacy-peer-deps
|
||||||
|
|
||||||
```
|
```bash
|
||||||
npm install --legacy-peer-deps --dev
|
npm install --legacy-peer-deps --dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -89,8 +90,7 @@ npm run start-server
|
||||||
node server/server.js
|
node server/server.js
|
||||||
```
|
```
|
||||||
|
|
||||||
It binds to 0.0.0.0:3001 by default.
|
It binds to `0.0.0.0:3001` by default.
|
||||||
|
|
||||||
|
|
||||||
## Backend Details
|
## Backend Details
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ express.js is just used for serving the frontend built files (index.html, .js an
|
||||||
|
|
||||||
# Frontend Dev
|
# Frontend Dev
|
||||||
|
|
||||||
Start frontend dev server. Hot-reload enabled in this way. It binds to 0.0.0.0:3000.
|
Start frontend dev server. Hot-reload enabled in this way. It binds to `0.0.0.0:3000` by default.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
npm run dev
|
||||||
|
@ -108,7 +108,7 @@ npm run dev
|
||||||
|
|
||||||
PS: You can ignore those scss warnings, those warnings are from Bootstrap that I cannot fix.
|
PS: You can ignore those scss warnings, those warnings are from Bootstrap that I cannot fix.
|
||||||
|
|
||||||
You can use Vue Devtool Chrome extension for debugging.
|
You can use Vue.js devtools Chrome extension for debugging.
|
||||||
|
|
||||||
After the frontend server started. It cannot connect to the websocket server even you have started the server. You need to tell the frontend that is a dev env by running this in DevTool console and refresh:
|
After the frontend server started. It cannot connect to the websocket server even you have started the server. You need to tell the frontend that is a dev env by running this in DevTool console and refresh:
|
||||||
|
|
||||||
|
@ -118,8 +118,7 @@ localStorage.dev = "dev";
|
||||||
|
|
||||||
So that the frontend will try to connect websocket server in 3001.
|
So that the frontend will try to connect websocket server in 3001.
|
||||||
|
|
||||||
Alternately, you can specific NODE_ENV to "development".
|
Alternately, you can specific `NODE_ENV` to "development".
|
||||||
|
|
||||||
|
|
||||||
## Build the frontend
|
## Build the frontend
|
||||||
|
|
||||||
|
@ -131,22 +130,17 @@ npm run build
|
||||||
|
|
||||||
Uptime Kuma Frontend is a single page application (SPA). Most paths are handled by Vue Router.
|
Uptime Kuma Frontend is a single page application (SPA). Most paths are handled by Vue Router.
|
||||||
|
|
||||||
The router in "src/main.js"
|
The router is in `src/router.js`
|
||||||
|
|
||||||
As you can see, most data in frontend is stored in root level, even though you changed the current router to any other pages.
|
As you can see, most data in frontend is stored in root level, even though you changed the current router to any other pages.
|
||||||
|
|
||||||
The data and socket logic in "src/mixins/socket.js"
|
The data and socket logic are in `src/mixins/socket.js`.
|
||||||
|
|
||||||
# Database Migration
|
# Database Migration
|
||||||
|
|
||||||
1. create `patch{num}.sql` in `./db/`
|
1. Create `patch{num}.sql` in `./db/`
|
||||||
1. update `latestVersion` in `./server/database.js`
|
2. Update `latestVersion` in `./server/database.js`
|
||||||
|
|
||||||
# Unit Test
|
# Unit Test
|
||||||
|
|
||||||
Yes, no unit test for now. I know it is very important, but at the same time my spare time is very limited. I want to implement my ideas first. I will go back to this in some points.
|
Yes, no unit test for now. I know it is very important, but at the same time my spare time is very limited. I want to implement my ideas first. I will go back to this in some points.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ It is a 5 minutes live demo, all data will be deleted after that. The server is
|
||||||
|
|
||||||
VPS is sponsored by Uptime Kuma sponsors on [Open Collective](https://opencollective.com/uptime-kuma)! Thank you so much!
|
VPS is sponsored by Uptime Kuma sponsors on [Open Collective](https://opencollective.com/uptime-kuma)! Thank you so much!
|
||||||
|
|
||||||
|
|
||||||
## ⭐ Features
|
## ⭐ Features
|
||||||
|
|
||||||
* Monitoring uptime for HTTP(s) / TCP / Ping / DNS Record.
|
* Monitoring uptime for HTTP(s) / TCP / Ping / DNS Record.
|
||||||
|
@ -65,7 +64,6 @@ If you need more options or need to browse via a reserve proxy, please read:
|
||||||
|
|
||||||
https://github.com/louislam/uptime-kuma/wiki/%F0%9F%94%A7-How-to-Install
|
https://github.com/louislam/uptime-kuma/wiki/%F0%9F%94%A7-How-to-Install
|
||||||
|
|
||||||
|
|
||||||
## 🆙 How to Update
|
## 🆙 How to Update
|
||||||
|
|
||||||
Please read:
|
Please read:
|
||||||
|
@ -107,7 +105,6 @@ Telegram Notification Sample:
|
||||||
|
|
||||||
If you love this project, please consider giving me a ⭐.
|
If you love this project, please consider giving me a ⭐.
|
||||||
|
|
||||||
|
|
||||||
## 🗣️ Discussion
|
## 🗣️ Discussion
|
||||||
|
|
||||||
You can also discuss or ask for help in [Issues](https://github.com/louislam/uptime-kuma/issues).
|
You can also discuss or ask for help in [Issues](https://github.com/louislam/uptime-kuma/issues).
|
||||||
|
@ -116,7 +113,6 @@ Alternatively, you can discuss in my original post on reddit: https://www.reddit
|
||||||
|
|
||||||
I think the real "Discussion" tab is hard to use, as it is reddit-like flow, I always missed new comments.
|
I think the real "Discussion" tab is hard to use, as it is reddit-like flow, I always missed new comments.
|
||||||
|
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
If you want to report a bug or request a new feature. Free feel to open a [new issue](https://github.com/louislam/uptime-kuma/issues).
|
If you want to report a bug or request a new feature. Free feel to open a [new issue](https://github.com/louislam/uptime-kuma/issues).
|
||||||
|
@ -126,4 +122,3 @@ If you want to translate Uptime Kuma into your langauge, please read: https://gi
|
||||||
If you want to modify Uptime Kuma, this guideline may be useful for you: https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md
|
If you want to modify Uptime Kuma, this guideline may be useful for you: https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md
|
||||||
|
|
||||||
English proofreading is needed too because my grammar is not that great sadly. Feel free to correct my grammar in this readme, source code, or wiki.
|
English proofreading is needed too because my grammar is not that great sadly. Feel free to correct my grammar in this readme, source code, or wiki.
|
||||||
|
|
||||||
|
|
46
src/i18n.js
Normal file
46
src/i18n.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
import { createI18n } from "vue-i18n";
|
||||||
|
import daDK from "./languages/da-DK";
|
||||||
|
import deDE from "./languages/de-DE";
|
||||||
|
import en from "./languages/en";
|
||||||
|
import esEs from "./languages/es-ES";
|
||||||
|
import etEE from "./languages/et-EE";
|
||||||
|
import frFR from "./languages/fr-FR";
|
||||||
|
import itIT from "./languages/it-IT";
|
||||||
|
import ja from "./languages/ja";
|
||||||
|
import koKR from "./languages/ko-KR";
|
||||||
|
import nlNL from "./languages/nl-NL";
|
||||||
|
import pl from "./languages/pl";
|
||||||
|
import ruRU from "./languages/ru-RU";
|
||||||
|
import sr from "./languages/sr";
|
||||||
|
import srLatn from "./languages/sr-latn";
|
||||||
|
import svSE from "./languages/sv-SE";
|
||||||
|
import zhCN from "./languages/zh-CN";
|
||||||
|
import zhHK from "./languages/zh-HK";
|
||||||
|
|
||||||
|
const languageList = {
|
||||||
|
en,
|
||||||
|
"zh-HK": zhHK,
|
||||||
|
"de-DE": deDE,
|
||||||
|
"nl-NL": nlNL,
|
||||||
|
"es-ES": esEs,
|
||||||
|
"fr-FR": frFR,
|
||||||
|
"it-IT": itIT,
|
||||||
|
"ja": ja,
|
||||||
|
"da-DK": daDK,
|
||||||
|
"sr": sr,
|
||||||
|
"sr-latn": srLatn,
|
||||||
|
"sv-SE": svSE,
|
||||||
|
"ko-KR": koKR,
|
||||||
|
"ru-RU": ruRU,
|
||||||
|
"zh-CN": zhCN,
|
||||||
|
"pl": pl,
|
||||||
|
"et-EE": etEE,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const i18n = createI18n({
|
||||||
|
locale: localStorage.locale || "en",
|
||||||
|
fallbackLocale: "en",
|
||||||
|
silentFallbackWarn: true,
|
||||||
|
silentTranslationWarn: false,
|
||||||
|
messages: languageList,
|
||||||
|
});
|
|
@ -3,16 +3,12 @@
|
||||||
1. Fork this repo.
|
1. Fork this repo.
|
||||||
2. Create a language file. (e.g. `zh-TW.js`) The filename must be ISO language code: http://www.lingoes.net/en/translator/langcode.htm
|
2. Create a language file. (e.g. `zh-TW.js`) The filename must be ISO language code: http://www.lingoes.net/en/translator/langcode.htm
|
||||||
3. `npm run update-language-files --base-lang=de-DE`
|
3. `npm run update-language-files --base-lang=de-DE`
|
||||||
6. Your language file should be filled in. You can translate now.
|
4. Your language file should be filled in. You can translate now.
|
||||||
7. Translate `src/pages/Settings.vue` (search for a `Confirm` component with `rel="confirmDisableAuth"`).
|
5. Translate `src/pages/Settings.vue` (search for a `Confirm` component with `rel="confirmDisableAuth"`).
|
||||||
8. Import your language file in `src/main.js` and add it to `languageList` constant.
|
6. Import your language file in `src/i18n.js` and add it to `languageList` constant.
|
||||||
9. Make a [pull request](https://github.com/louislam/uptime-kuma/pulls) when you have done.
|
7. Make a [pull request](https://github.com/louislam/uptime-kuma/pulls) when you have done.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
One of good examples:
|
One of good examples:
|
||||||
https://github.com/louislam/uptime-kuma/pull/316/files
|
https://github.com/louislam/uptime-kuma/pull/316/files
|
||||||
|
|
||||||
|
|
||||||
If you do not have programming skills, let me know in [Issues section](https://github.com/louislam/uptime-kuma/issues). I will assist you. 😏
|
If you do not have programming skills, let me know in [Issues section](https://github.com/louislam/uptime-kuma/issues). I will assist you. 😏
|
||||||
|
|
||||||
|
|
125
src/main.js
125
src/main.js
|
@ -1,135 +1,18 @@
|
||||||
import "bootstrap";
|
import "bootstrap";
|
||||||
import { createApp, h } from "vue";
|
import { createApp, h } from "vue";
|
||||||
import { createI18n } from "vue-i18n"
|
|
||||||
import { createRouter, createWebHistory } from "vue-router";
|
|
||||||
import Toast from "vue-toastification";
|
import Toast from "vue-toastification";
|
||||||
import "vue-toastification/dist/index.css";
|
import "vue-toastification/dist/index.css";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import "./assets/app.scss";
|
import "./assets/app.scss";
|
||||||
|
import { i18n } from "./i18n";
|
||||||
import { FontAwesomeIcon } from "./icon.js";
|
import { FontAwesomeIcon } from "./icon.js";
|
||||||
import EmptyLayout from "./layouts/EmptyLayout.vue";
|
import datetime from "./mixins/datetime";
|
||||||
import Layout from "./layouts/Layout.vue";
|
import mobile from "./mixins/mobile";
|
||||||
import socket from "./mixins/socket";
|
import socket from "./mixins/socket";
|
||||||
import theme from "./mixins/theme";
|
import theme from "./mixins/theme";
|
||||||
import mobile from "./mixins/mobile";
|
import { router } from "./router";
|
||||||
import datetime from "./mixins/datetime";
|
|
||||||
import Dashboard from "./pages/Dashboard.vue";
|
|
||||||
import DashboardHome from "./pages/DashboardHome.vue";
|
|
||||||
import Details from "./pages/Details.vue";
|
|
||||||
import EditMonitor from "./pages/EditMonitor.vue";
|
|
||||||
import Settings from "./pages/Settings.vue";
|
|
||||||
import Setup from "./pages/Setup.vue";
|
|
||||||
import List from "./pages/List.vue";
|
|
||||||
|
|
||||||
import { appName } from "./util.ts";
|
import { appName } from "./util.ts";
|
||||||
|
|
||||||
import en from "./languages/en";
|
|
||||||
import zhHK from "./languages/zh-HK";
|
|
||||||
import deDE from "./languages/de-DE";
|
|
||||||
import nlNL from "./languages/nl-NL";
|
|
||||||
import esEs from "./languages/es-ES";
|
|
||||||
import frFR from "./languages/fr-FR";
|
|
||||||
import itIT from "./languages/it-IT";
|
|
||||||
import ja from "./languages/ja";
|
|
||||||
import daDK from "./languages/da-DK";
|
|
||||||
import sr from "./languages/sr";
|
|
||||||
import srLatn from "./languages/sr-latn";
|
|
||||||
import svSE from "./languages/sv-SE";
|
|
||||||
import koKR from "./languages/ko-KR";
|
|
||||||
import ruRU from "./languages/ru-RU";
|
|
||||||
import zhCN from "./languages/zh-CN";
|
|
||||||
import pl from "./languages/pl"
|
|
||||||
import etEE from "./languages/et-EE"
|
|
||||||
|
|
||||||
const routes = [
|
|
||||||
{
|
|
||||||
path: "/",
|
|
||||||
component: Layout,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
name: "root",
|
|
||||||
path: "",
|
|
||||||
component: Dashboard,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
name: "DashboardHome",
|
|
||||||
path: "/dashboard",
|
|
||||||
component: DashboardHome,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "/dashboard/:id",
|
|
||||||
component: EmptyLayout,
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: "",
|
|
||||||
component: Details,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/edit/:id",
|
|
||||||
component: EditMonitor,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/add",
|
|
||||||
component: EditMonitor,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/list",
|
|
||||||
component: List,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/settings",
|
|
||||||
component: Settings,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/setup",
|
|
||||||
component: Setup,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const router = createRouter({
|
|
||||||
linkActiveClass: "active",
|
|
||||||
history: createWebHistory(),
|
|
||||||
routes,
|
|
||||||
})
|
|
||||||
|
|
||||||
const languageList = {
|
|
||||||
en,
|
|
||||||
"zh-HK": zhHK,
|
|
||||||
"de-DE": deDE,
|
|
||||||
"nl-NL": nlNL,
|
|
||||||
"es-ES": esEs,
|
|
||||||
"fr-FR": frFR,
|
|
||||||
"it-IT": itIT,
|
|
||||||
"ja": ja,
|
|
||||||
"da-DK": daDK,
|
|
||||||
"sr": sr,
|
|
||||||
"sr-latn": srLatn,
|
|
||||||
"sv-SE": svSE,
|
|
||||||
"ko-KR": koKR,
|
|
||||||
"ru-RU": ruRU,
|
|
||||||
"zh-CN": zhCN,
|
|
||||||
"pl": pl,
|
|
||||||
"et-EE": etEE,
|
|
||||||
};
|
|
||||||
|
|
||||||
const i18n = createI18n({
|
|
||||||
locale: localStorage.locale || "en",
|
|
||||||
fallbackLocale: "en",
|
|
||||||
silentFallbackWarn: true,
|
|
||||||
silentTranslationWarn: true,
|
|
||||||
messages: languageList
|
|
||||||
});
|
|
||||||
|
|
||||||
const app = createApp({
|
const app = createApp({
|
||||||
mixins: [
|
mixins: [
|
||||||
socket,
|
socket,
|
||||||
|
|
71
src/router.js
Normal file
71
src/router.js
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
import { createRouter, createWebHistory } from "vue-router";
|
||||||
|
import EmptyLayout from "./layouts/EmptyLayout.vue";
|
||||||
|
import Layout from "./layouts/Layout.vue";
|
||||||
|
import Dashboard from "./pages/Dashboard.vue";
|
||||||
|
import DashboardHome from "./pages/DashboardHome.vue";
|
||||||
|
import Details from "./pages/Details.vue";
|
||||||
|
import EditMonitor from "./pages/EditMonitor.vue";
|
||||||
|
import List from "./pages/List.vue";
|
||||||
|
import Settings from "./pages/Settings.vue";
|
||||||
|
import Setup from "./pages/Setup.vue";
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{
|
||||||
|
path: "/",
|
||||||
|
component: Layout,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: "root",
|
||||||
|
path: "",
|
||||||
|
component: Dashboard,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
name: "DashboardHome",
|
||||||
|
path: "/dashboard",
|
||||||
|
component: DashboardHome,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "/dashboard/:id",
|
||||||
|
component: EmptyLayout,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "",
|
||||||
|
component: Details,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/edit/:id",
|
||||||
|
component: EditMonitor,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/add",
|
||||||
|
component: EditMonitor,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/list",
|
||||||
|
component: List,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/settings",
|
||||||
|
component: Settings,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/setup",
|
||||||
|
component: Setup,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
export const router = createRouter({
|
||||||
|
linkActiveClass: "active",
|
||||||
|
history: createWebHistory(),
|
||||||
|
routes,
|
||||||
|
});
|
Loading…
Reference in a new issue