Browse Source

perf: 优化代码

i18n
xiaoxian521 2 years ago
parent
commit
ea28240d56
  1. 4
      mock/asyncRoutes.ts
  2. 0
      src/assets/svg/keyboard_esc.svg
  3. 6
      src/layout/components/navbar.vue
  4. 2
      src/layout/components/search/components/SearchFooter.vue
  5. 6
      src/layout/components/sidebar/horizontal.vue
  6. 6
      src/layout/components/sidebar/mixNav.vue
  7. 1
      src/store/modules/user.ts
  8. 5
      src/utils/README.md
  9. 25
      src/utils/http/README.md
  10. 2
      src/views/welcome/index.vue

4
mock/asyncRoutes.ts

@ -19,8 +19,8 @@ const permissionRouter = {
path: "/permission/page/index",
name: "PermissionPage",
meta: {
roles: ["admin", "common"],
title: "menus.permissionPage"
title: "menus.permissionPage",
roles: ["admin", "common"]
}
},
{

0
src/assets/svg/mdi_keyboard_esc.svg → src/assets/svg/keyboard_esc.svg

6
src/layout/components/navbar.vue

@ -2,7 +2,6 @@
import Search from "./search/index.vue";
import Notice from "./notice/index.vue";
import mixNav from "./sidebar/mixNav.vue";
import avatars from "@/assets/avatars.jpg";
import { useNav } from "@/layout/hooks/useNav";
import Breadcrumb from "./sidebar/breadCrumb.vue";
import topCollapse from "./sidebar/topCollapse.vue";
@ -83,7 +82,10 @@ const { t, locale, translationCh, translationEn } = useTranslationLang();
<!-- 退出登录 -->
<el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover select-none">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" />
<img
src="https://avatars.githubusercontent.com/u/44761321?v=4"
:style="avatarsStyle"
/>
<p v-if="username" class="dark:text-white">{{ username }}</p>
</span>
<template #dropdown>

2
src/layout/components/search/components/SearchFooter.vue

@ -18,7 +18,7 @@
<script lang="ts" setup>
import enterOutlined from "@/assets/svg/enter_outlined.svg?component";
import mdiKeyboardEsc from "@/assets/svg/mdi_keyboard_esc.svg?component";
import mdiKeyboardEsc from "@/assets/svg/keyboard_esc.svg?component";
</script>
<style lang="scss" scoped>
.search-footer {

6
src/layout/components/sidebar/horizontal.vue

@ -3,7 +3,6 @@ import Search from "../search/index.vue";
import Notice from "../notice/index.vue";
import { ref, watch, nextTick } from "vue";
import SidebarItem from "./sidebarItem.vue";
import avatars from "@/assets/avatars.jpg";
import { useNav } from "@/layout/hooks/useNav";
import { useTranslationLang } from "../../hooks/useTranslationLang";
import { usePermissionStoreHook } from "@/store/modules/permission";
@ -97,7 +96,10 @@ watch(
<!-- 退出登录 -->
<el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" />
<img
src="https://avatars.githubusercontent.com/u/44761321?v=4"
:style="avatarsStyle"
/>
<p v-if="username" class="dark:text-white">{{ username }}</p>
</span>
<template #dropdown>

6
src/layout/components/sidebar/mixNav.vue

@ -1,7 +1,6 @@
<script setup lang="ts">
import Search from "../search/index.vue";
import Notice from "../notice/index.vue";
import avatars from "@/assets/avatars.jpg";
import { useNav } from "@/layout/hooks/useNav";
import { transformI18n } from "@/plugins/i18n";
import { ref, toRaw, watch, onMounted, nextTick } from "vue";
@ -129,7 +128,10 @@ watch(
<!-- 退出登录 -->
<el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover select-none">
<img v-if="avatars" :src="avatars" :style="avatarsStyle" />
<img
src="https://avatars.githubusercontent.com/u/44761321?v=4"
:style="avatarsStyle"
/>
<p v-if="username" class="dark:text-white">{{ username }}</p>
</span>
<template #dropdown>

1
src/store/modules/user.ts

@ -12,6 +12,7 @@ import { type DataInfo, setToken, removeToken, sessionKey } from "@/utils/auth";
export const useUserStore = defineStore({
id: "pure-user",
state: (): userType => ({
// 用户名
username:
storageSession.getItem<DataInfo<number>>(sessionKey)?.username ?? "",
// 页面级别权限

5
src/utils/README.md

@ -1,5 +0,0 @@
### 注意
- [文档](https://pure-admin-utils-docs.vercel.app/)
- [npm](https://www.npmjs.com/package/@pureadmin/utils)
- vue-pure-admin 从 3.3.0 版本之后(不包括 3.3.0 版本),大部分工具和 hooks 都集成到了[@pureadmin/utils](https://pure-admin-utils-docs.vercel.app/)

25
src/utils/http/README.md

@ -1,25 +0,0 @@
## 用法
### Get 请求
```
import { http } from "@/utils/http";
// params传参
http.request('get', '/xxx', { params: param });
// url拼接传参
http.request('get', '/xxx?message=' + msg);
```
### Post 请求
```
import { http } from "@/utils/http";
// params传参
http.request('post', '/xxx', { params: param });
// data传参
http.request('post', '/xxx', { data: param });
```

2
src/views/welcome/index.vue

@ -5,5 +5,5 @@ defineOptions({
</script>
<template>
<h1>Pure-Admin-Thin</h1>
<h1>Pure-Admin-Thin国际化版本</h1>
</template>
Loading…
Cancel
Save