Skip to content

Commit 7889d2e

Browse files
feat: |Worker| support multi language (#584)
1 parent 2426e0b commit 7889d2e

23 files changed

+912
-851
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<!-- markdownlint-disable-file MD004 MD024 MD034 MD036 -->
22
# CHANGE LOG
33

4-
## main(v0.8.7)
4+
## main(v0.9.0)
5+
6+
- feat: | Worker | 支持多语言
7+
8+
## v0.8.7
59

610
- fix: |UI| 修复移动设备日期显示问题
711
- feat: |Worker| 支持通过 `SMTP` 发送邮件, 使用 [zou-yu/worker-mailer](https://github.com/zou-yu/worker-mailer/blob/main/README_zh-CN.md)

frontend/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cloudflare_temp_email",
3-
"version": "0.8.7",
3+
"version": "0.9.0",
44
"private": true,
55
"type": "module",
66
"scripts": {
@@ -40,13 +40,13 @@
4040
"@vicons/material": "^0.13.0",
4141
"@vitejs/plugin-vue": "^5.2.1",
4242
"unplugin-auto-import": "^19.1.0",
43-
"unplugin-vue-components": "^28.1.0",
44-
"vite": "^6.1.0",
43+
"unplugin-vue-components": "^28.4.0",
44+
"vite": "^6.1.1",
4545
"vite-plugin-pwa": "^0.21.1",
4646
"vite-plugin-top-level-await": "^1.5.0",
4747
"vite-plugin-wasm": "^3.4.1",
4848
"workbox-build": "^7.3.0",
4949
"workbox-window": "^7.3.0",
50-
"wrangler": "^3.109.1"
50+
"wrangler": "^3.109.2"
5151
}
5252
}

frontend/pnpm-lock.yaml

+208-284
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/src/api/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { useGlobalState } from '../store'
22
import { h } from 'vue'
33
import axios from 'axios'
44

5+
import i18n from '../i18n'
6+
57
const API_BASE = import.meta.env.VITE_API_BASE || "";
68
const {
79
loading, auth, jwt, settings, openSettings,
@@ -22,6 +24,7 @@ const apiFetch = async (path, options = {}) => {
2224
method: options.method || 'GET',
2325
data: options.body || null,
2426
headers: {
27+
'x-lang': i18n.global.locale.value,
2528
'x-user-token': userJwt.value,
2629
'x-user-access-token': userSettings.value.access_token,
2730
'x-custom-auth': auth.value,
@@ -32,14 +35,12 @@ const apiFetch = async (path, options = {}) => {
3235
});
3336
if (response.status === 401 && path.startsWith("/admin")) {
3437
showAdminAuth.value = true;
35-
throw new Error("Unauthorized, your admin password is wrong")
3638
}
3739
if (response.status === 401 && openSettings.value.auth) {
3840
showAuth.value = true;
39-
throw new Error("Unauthorized, you access password is wrong")
4041
}
4142
if (response.status >= 300) {
42-
throw new Error(`${response.status} ${response.data}` || "error");
43+
throw new Error(`[${response.status}]: ${response.data}` || "error");
4344
}
4445
const data = response.data;
4546
return data;

frontend/src/i18n.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { createI18n } from 'vue-i18n'
2+
3+
const i18n = createI18n({
4+
legacy: false, // you must set `false`, to use Composition API
5+
locale: 'zh', // set locale
6+
fallbackLocale: 'en', // set fallback locale
7+
'en': {
8+
messages: {}
9+
},
10+
'zh': {
11+
messages: {}
12+
}
13+
})
14+
15+
export default i18n;

frontend/src/main.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
import { createApp } from 'vue'
22
import App from './App.vue'
3-
import { createI18n } from 'vue-i18n'
43
import router from './router'
54
import { createHead } from '@unhead/vue'
65

7-
const i18n = createI18n({
8-
legacy: false, // you must set `false`, to use Composition API
9-
locale: 'zh', // set locale
10-
fallbackLocale: 'en', // set fallback locale
11-
'en': {
12-
messages: {}
13-
},
14-
'zh': {
15-
messages: {}
16-
}
17-
})
6+
import i18n from './i18n'
187

198
router.beforeEach((to, from) => {
209
if (to.params.lang && ['en', 'zh'].includes(to.params.lang)) {

pages/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "temp-email-pages",
3-
"version": "0.8.7",
3+
"version": "0.9.0",
44
"description": "",
55
"main": "index.js",
66
"scripts": {
@@ -11,6 +11,6 @@
1111
"author": "",
1212
"license": "ISC",
1313
"devDependencies": {
14-
"wrangler": "^3.109.1"
14+
"wrangler": "^3.109.2"
1515
}
1616
}

vitepress-docs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "temp-mail-docs",
33
"private": true,
4-
"version": "0.8.7",
4+
"version": "0.9.0",
55
"type": "module",
66
"devDependencies": {
77
"@types/node": "^22.13.4",
88
"vitepress": "^1.6.3",
9-
"wrangler": "^3.109.1"
9+
"wrangler": "^3.109.2"
1010
},
1111
"scripts": {
1212
"dev": "vitepress dev docs",

0 commit comments

Comments
 (0)