diff --git a/frontend/packages/admin/src/main.ts b/frontend/packages/admin/src/main.ts index 3986748..0e60f54 100644 --- a/frontend/packages/admin/src/main.ts +++ b/frontend/packages/admin/src/main.ts @@ -2,6 +2,7 @@ import { createApp } from "vue"; import router from "./router"; import App from "./App.vue"; import vuetify from "./plugins/vuetify"; +import "./plugins/dayjs"; import store from "@main/store"; import i18n from "@main/i18n"; diff --git a/frontend/packages/admin/src/plugins/dayjs.ts b/frontend/packages/admin/src/plugins/dayjs.ts new file mode 100644 index 0000000..c02ca5c --- /dev/null +++ b/frontend/packages/admin/src/plugins/dayjs.ts @@ -0,0 +1,14 @@ +import dayjs from "dayjs"; +import relativeTime from "dayjs/plugin/relativeTime"; +import UpdateLocale from "dayjs/plugin/updateLocale"; +import zhCn from "dayjs/locale/zh-cn"; + +dayjs.extend(relativeTime); + +dayjs.extend(UpdateLocale); +dayjs.updateLocale("zh-cn", zhCn); + +const language = + JSON.parse(localStorage.getItem("vuex") || "{}")?.i18n?.locale || + (navigator.language || "en").toLocaleLowerCase(); +dayjs.locale(language); diff --git a/frontend/packages/admin/src/router/index.ts b/frontend/packages/admin/src/router/index.ts index 6317ad2..ffff4f9 100644 --- a/frontend/packages/admin/src/router/index.ts +++ b/frontend/packages/admin/src/router/index.ts @@ -109,7 +109,7 @@ const Router = createRouter({ }, children: [ { - path: "/language/zh", + path: "/language/zh-cn", name: "Chinese", component: (): Promise => import("@main/views/ChangeLanguage.vue"), meta: { diff --git a/frontend/packages/locale/src/en/search.ts b/frontend/packages/locale/src/en/search.ts index 53cf3fa..36e5f01 100644 --- a/frontend/packages/locale/src/en/search.ts +++ b/frontend/packages/locale/src/en/search.ts @@ -4,4 +4,6 @@ export default { SearchByName: "Search by name", LearnwareName: "Learnware Name", UploadStatisticalRequirement: "Upload statistical requirement", + SpecificationScore: "Specification score", + Updated: "Updated", }; diff --git a/frontend/packages/locale/src/index.ts b/frontend/packages/locale/src/index.ts index 7e6a83c..7e6ba4d 100644 --- a/frontend/packages/locale/src/index.ts +++ b/frontend/packages/locale/src/index.ts @@ -1,2 +1,2 @@ -export { default as zh } from "./zh"; +export { default as zhCn } from "./zh-cn"; export { default as en } from "./en"; diff --git a/frontend/packages/locale/src/zh/allLearnware.ts b/frontend/packages/locale/src/zh-cn/allLearnware.ts similarity index 100% rename from frontend/packages/locale/src/zh/allLearnware.ts rename to frontend/packages/locale/src/zh-cn/allLearnware.ts diff --git a/frontend/packages/locale/src/zh/allUser.ts b/frontend/packages/locale/src/zh-cn/allUser.ts similarity index 100% rename from frontend/packages/locale/src/zh/allUser.ts rename to frontend/packages/locale/src/zh-cn/allUser.ts diff --git a/frontend/packages/locale/src/zh/changePassword.ts b/frontend/packages/locale/src/zh-cn/changePassword.ts similarity index 100% rename from frontend/packages/locale/src/zh/changePassword.ts rename to frontend/packages/locale/src/zh-cn/changePassword.ts diff --git a/frontend/packages/locale/src/zh/clientToken.ts b/frontend/packages/locale/src/zh-cn/clientToken.ts similarity index 100% rename from frontend/packages/locale/src/zh/clientToken.ts rename to frontend/packages/locale/src/zh-cn/clientToken.ts diff --git a/frontend/packages/locale/src/zh/home.ts b/frontend/packages/locale/src/zh-cn/home.ts similarity index 100% rename from frontend/packages/locale/src/zh/home.ts rename to frontend/packages/locale/src/zh-cn/home.ts diff --git a/frontend/packages/locale/src/zh/index.ts b/frontend/packages/locale/src/zh-cn/index.ts similarity index 100% rename from frontend/packages/locale/src/zh/index.ts rename to frontend/packages/locale/src/zh-cn/index.ts diff --git a/frontend/packages/locale/src/zh/learnware.ts b/frontend/packages/locale/src/zh-cn/learnware.ts similarity index 100% rename from frontend/packages/locale/src/zh/learnware.ts rename to frontend/packages/locale/src/zh-cn/learnware.ts diff --git a/frontend/packages/locale/src/zh/learnwareDetail.ts b/frontend/packages/locale/src/zh-cn/learnwareDetail.ts similarity index 100% rename from frontend/packages/locale/src/zh/learnwareDetail.ts rename to frontend/packages/locale/src/zh-cn/learnwareDetail.ts diff --git a/frontend/packages/locale/src/zh/login.ts b/frontend/packages/locale/src/zh-cn/login.ts similarity index 100% rename from frontend/packages/locale/src/zh/login.ts rename to frontend/packages/locale/src/zh-cn/login.ts diff --git a/frontend/packages/locale/src/zh/myLearnware.ts b/frontend/packages/locale/src/zh-cn/myLearnware.ts similarity index 100% rename from frontend/packages/locale/src/zh/myLearnware.ts rename to frontend/packages/locale/src/zh-cn/myLearnware.ts diff --git a/frontend/packages/locale/src/zh/page.ts b/frontend/packages/locale/src/zh-cn/page.ts similarity index 100% rename from frontend/packages/locale/src/zh/page.ts rename to frontend/packages/locale/src/zh-cn/page.ts diff --git a/frontend/packages/locale/src/zh/public.ts b/frontend/packages/locale/src/zh-cn/public.ts similarity index 100% rename from frontend/packages/locale/src/zh/public.ts rename to frontend/packages/locale/src/zh-cn/public.ts diff --git a/frontend/packages/locale/src/zh/register.ts b/frontend/packages/locale/src/zh-cn/register.ts similarity index 100% rename from frontend/packages/locale/src/zh/register.ts rename to frontend/packages/locale/src/zh-cn/register.ts diff --git a/frontend/packages/locale/src/zh/search.ts b/frontend/packages/locale/src/zh-cn/search.ts similarity index 75% rename from frontend/packages/locale/src/zh/search.ts rename to frontend/packages/locale/src/zh-cn/search.ts index b694f4d..4cfb18c 100644 --- a/frontend/packages/locale/src/zh/search.ts +++ b/frontend/packages/locale/src/zh-cn/search.ts @@ -4,4 +4,6 @@ export default { SearchByName: "按名称查找", LearnwareName: "学件名称", UploadStatisticalRequirement: "上传统计需求", + SpecificationScore: "规约匹配分数", + Updated: "更新于", }; diff --git a/frontend/packages/locale/src/zh/submit.ts b/frontend/packages/locale/src/zh-cn/submit.ts similarity index 100% rename from frontend/packages/locale/src/zh/submit.ts rename to frontend/packages/locale/src/zh-cn/submit.ts diff --git a/frontend/packages/locale/src/zh/summary.ts b/frontend/packages/locale/src/zh-cn/summary.ts similarity index 100% rename from frontend/packages/locale/src/zh/summary.ts rename to frontend/packages/locale/src/zh-cn/summary.ts diff --git a/frontend/packages/main/src/components/Learnware/LearnwareCard.vue b/frontend/packages/main/src/components/Learnware/LearnwareCard.vue index fbb3509..7057eeb 100644 --- a/frontend/packages/main/src/components/Learnware/LearnwareCard.vue +++ b/frontend/packages/main/src/components/Learnware/LearnwareCard.vue @@ -9,9 +9,7 @@ import ImageBtn from "../../assets/images/specification/dataType/image.svg?compo import TableBtn from "../../assets/images/specification/dataType/table.svg?component"; import { downloadLearnwareSync } from "../../utils"; import dayjs from "dayjs"; -import relativeTime from "dayjs/plugin/relativeTime"; import type { LearnwareCardInfo, Filter } from "@beiming-system/types/learnware"; -dayjs.extend(relativeTime); const { t } = useI18n(); @@ -75,23 +73,17 @@ function handleClickDelete(id: string): void {