feat: 更新 @riwa/api-types 依赖地址,优化语言加载逻辑
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
"@elysiajs/eden": "^1.4.5",
|
"@elysiajs/eden": "^1.4.5",
|
||||||
"@ionic/vue": "^8.7.11",
|
"@ionic/vue": "^8.7.11",
|
||||||
"@ionic/vue-router": "^8.7.11",
|
"@ionic/vue-router": "^8.7.11",
|
||||||
"@riwa/api-types": "http://192.168.1.33:9527/api/riwa-api-types-0.0.35.tgz",
|
"@riwa/api-types": "http://192.168.1.27:9527/api/riwa-api-types-0.0.37.tgz",
|
||||||
"@tailwindcss/vite": "^4.1.18",
|
"@tailwindcss/vite": "^4.1.18",
|
||||||
"@vee-validate/yup": "^4.15.1",
|
"@vee-validate/yup": "^4.15.1",
|
||||||
"@vueuse/core": "^14.1.0",
|
"@vueuse/core": "^14.1.0",
|
||||||
|
|||||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -45,8 +45,8 @@ importers:
|
|||||||
specifier: ^8.7.11
|
specifier: ^8.7.11
|
||||||
version: 8.7.11(@stencil/core@4.39.0)(vue-router@4.6.3(vue@3.5.25(typescript@5.9.3)))(vue@3.5.25(typescript@5.9.3))
|
version: 8.7.11(@stencil/core@4.39.0)(vue-router@4.6.3(vue@3.5.25(typescript@5.9.3)))(vue@3.5.25(typescript@5.9.3))
|
||||||
'@riwa/api-types':
|
'@riwa/api-types':
|
||||||
specifier: http://192.168.1.33:9527/api/riwa-api-types-0.0.35.tgz
|
specifier: http://192.168.1.27:9527/api/riwa-api-types-0.0.37.tgz
|
||||||
version: http://192.168.1.33:9527/api/riwa-api-types-0.0.35.tgz(@elysiajs/eden@1.4.5(elysia@1.4.18(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))
|
version: http://192.168.1.27:9527/api/riwa-api-types-0.0.37.tgz(@elysiajs/eden@1.4.5(elysia@1.4.18(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))
|
||||||
'@tailwindcss/vite':
|
'@tailwindcss/vite':
|
||||||
specifier: ^4.1.18
|
specifier: ^4.1.18
|
||||||
version: 4.1.18(vite@7.2.7(@types/node@24.10.2)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2))
|
version: 4.1.18(vite@7.2.7(@types/node@24.10.2)(jiti@2.6.1)(lightningcss@1.30.2)(terser@5.44.1)(yaml@2.8.2))
|
||||||
@@ -1315,9 +1315,9 @@ packages:
|
|||||||
resolution: {integrity: sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==}
|
resolution: {integrity: sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==}
|
||||||
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
||||||
|
|
||||||
'@riwa/api-types@http://192.168.1.33:9527/api/riwa-api-types-0.0.35.tgz':
|
'@riwa/api-types@http://192.168.1.27:9527/api/riwa-api-types-0.0.37.tgz':
|
||||||
resolution: {tarball: http://192.168.1.33:9527/api/riwa-api-types-0.0.35.tgz}
|
resolution: {tarball: http://192.168.1.27:9527/api/riwa-api-types-0.0.37.tgz}
|
||||||
version: 0.0.35
|
version: 0.0.37
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@elysiajs/eden': ^1.4.5
|
'@elysiajs/eden': ^1.4.5
|
||||||
|
|
||||||
@@ -6390,7 +6390,7 @@ snapshots:
|
|||||||
|
|
||||||
'@pkgr/core@0.2.9': {}
|
'@pkgr/core@0.2.9': {}
|
||||||
|
|
||||||
'@riwa/api-types@http://192.168.1.33:9527/api/riwa-api-types-0.0.35.tgz(@elysiajs/eden@1.4.5(elysia@1.4.18(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))':
|
'@riwa/api-types@http://192.168.1.27:9527/api/riwa-api-types-0.0.37.tgz(@elysiajs/eden@1.4.5(elysia@1.4.18(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3)))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@elysiajs/eden': 1.4.5(elysia@1.4.18(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3))
|
'@elysiajs/eden': 1.4.5(elysia@1.4.18(@sinclair/typebox@0.34.41)(exact-mirror@0.2.5(@sinclair/typebox@0.34.41))(file-type@21.1.1)(openapi-types@12.1.3)(typescript@5.9.3))
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import type { App } from "@riwa/api-types";
|
|||||||
import type { WatchSource } from "vue";
|
import type { WatchSource } from "vue";
|
||||||
import { treaty } from "@elysiajs/eden";
|
import { treaty } from "@elysiajs/eden";
|
||||||
import { toastController } from "@ionic/vue";
|
import { toastController } from "@ionic/vue";
|
||||||
|
import { i18n } from "@/locales";
|
||||||
|
|
||||||
const client = treaty<App>(window.location.origin, {
|
const client = treaty<App>(window.location.origin, {
|
||||||
fetch: {
|
fetch: {
|
||||||
@@ -54,7 +55,9 @@ export function safeClient<T, E>(
|
|||||||
if (res.error && res.status === 418) {
|
if (res.error && res.status === 418) {
|
||||||
if (!options.silent) {
|
if (!options.silent) {
|
||||||
const toast = await toastController.create({
|
const toast = await toastController.create({
|
||||||
message: (res.error as any).value.message,
|
message: i18n.global.t((res.error as any).value.code, {
|
||||||
|
...(res.error as any).value.context,
|
||||||
|
}),
|
||||||
duration: 3000,
|
duration: 3000,
|
||||||
position: "bottom",
|
position: "bottom",
|
||||||
color: "danger",
|
color: "danger",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { Locale } from "vue-i18n";
|
import type { Locale } from "vue-i18n";
|
||||||
|
import { client, safeClient } from "@/api";
|
||||||
|
|
||||||
export interface Language {
|
export interface Language {
|
||||||
code: Locale;
|
code: Locale;
|
||||||
@@ -10,7 +11,7 @@ export interface Language {
|
|||||||
* 语言管理组合式函数
|
* 语言管理组合式函数
|
||||||
*/
|
*/
|
||||||
export function useLanguage() {
|
export function useLanguage() {
|
||||||
const { locale, availableLocales } = useI18n();
|
const { locale, availableLocales, mergeLocaleMessage } = useI18n();
|
||||||
const language = useStorage<Locale>("app-language", locale.value);
|
const language = useStorage<Locale>("app-language", locale.value);
|
||||||
|
|
||||||
// 可用的语言列表
|
// 可用的语言列表
|
||||||
@@ -38,6 +39,13 @@ export function useLanguage() {
|
|||||||
function setLanguage(langCode: Locale) {
|
function setLanguage(langCode: Locale) {
|
||||||
locale.value = langCode;
|
locale.value = langCode;
|
||||||
language.value = langCode;
|
language.value = langCode;
|
||||||
|
loadRemoteLanguage();
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadRemoteLanguage() {
|
||||||
|
safeClient(client.api.error_messages({ lang: language.value }).get()).then((res) => {
|
||||||
|
mergeLocaleMessage(locale.value, res.data.value);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,6 +54,7 @@ export function useLanguage() {
|
|||||||
function loadSavedLanguage() {
|
function loadSavedLanguage() {
|
||||||
if (language.value && availableLocales.includes(language.value)) {
|
if (language.value && availableLocales.includes(language.value)) {
|
||||||
locale.value = language.value;
|
locale.value = language.value;
|
||||||
|
loadRemoteLanguage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { authClient, modelControllerLogin, modelControllerSignup } from "@/auth"
|
|||||||
|
|
||||||
const page = useTemplateRef<PageInstance>("page");
|
const page = useTemplateRef<PageInstance>("page");
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
|
const tradingViewContainer = useTemplateRef<HTMLElement>("tradingViewContainer");
|
||||||
|
|
||||||
async function openSignin() {
|
async function openSignin() {
|
||||||
const modal = await modelControllerLogin(page.value?.$el);
|
const modal = await modelControllerLogin(page.value?.$el);
|
||||||
@@ -15,6 +16,19 @@ async function openSignup() {
|
|||||||
async function handleLogout() {
|
async function handleLogout() {
|
||||||
await authClient.signOut();
|
await authClient.signOut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useTradingView(tradingViewContainer, {
|
||||||
|
data: [
|
||||||
|
// 随机k线图数据
|
||||||
|
{ time: "2023-10-01", open: 100, high: 110, low: 90, close: 105 },
|
||||||
|
{ time: "2023-10-02", open: 105, high: 115, low: 95, close: 100 },
|
||||||
|
{ time: "2023-10-03", open: 100, high: 120, low: 80, close: 110 },
|
||||||
|
{ time: "2023-10-04", open: 110, high: 130, low: 100, close: 120 },
|
||||||
|
{ time: "2023-10-05", open: 120, high: 140, low: 110, close: 130 },
|
||||||
|
{ time: "2023-10-06", open: 130, high: 150, low: 120, close: 140 },
|
||||||
|
{ time: "2023-10-07", open: 140, high: 160, low: 130, close: 150 },
|
||||||
|
],
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -34,7 +48,7 @@ async function handleLogout() {
|
|||||||
<IonButton @click="handleLogout">
|
<IonButton @click="handleLogout">
|
||||||
Log out
|
Log out
|
||||||
</IonButton>
|
</IonButton>
|
||||||
|
<div ref="tradingViewContainer" />
|
||||||
{{ user }}
|
{{ user }}
|
||||||
</IonContent>
|
</IonContent>
|
||||||
</IonPage>
|
</IonPage>
|
||||||
|
|||||||
Reference in New Issue
Block a user