mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-06 08:32:51 +08:00
refactor(ui): ui 替换,从 antdv 换成 vuetify
This commit is contained in:
@@ -2,12 +2,12 @@
|
|||||||
Author: 目棃
|
Author: 目棃
|
||||||
Date: 2023-03-05
|
Date: 2023-03-05
|
||||||
Description: 说明文档
|
Description: 说明文档
|
||||||
Update: 2023-03-05
|
Update: 2023-03-06
|
||||||
---
|
---
|
||||||
|
|
||||||
> 本文档 [`Front-matter`](https://github.com/BTMuli/Mucli#FrontMatter) 由 [MuCli](https://github.com/BTMuli/Mucli) 自动生成于`2023-03-05 14:41:55`
|
> 本文档 [`Front-matter`](https://github.com/BTMuli/Mucli#FrontMatter) 由 [MuCli](https://github.com/BTMuli/Mucli) 自动生成于`2023-03-05 14:41:55`
|
||||||
>
|
>
|
||||||
> 更新于 `2023-03-05 17:10:10`
|
> 更新于 `2023-03-06 16:14:02`
|
||||||
|
|
||||||
# Tauri.Genshin
|
# Tauri.Genshin
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ Tauri 练手项目
|
|||||||
- [Vue3](https://v3.cn.vuejs.org/)
|
- [Vue3](https://v3.cn.vuejs.org/)
|
||||||
- [Vite](https://cn.vitejs.dev/)
|
- [Vite](https://cn.vitejs.dev/)
|
||||||
- [TypeScript](https://www.typescriptlang.org/)
|
- [TypeScript](https://www.typescriptlang.org/)
|
||||||
- [Ant Design Vue](https://www.antdv.com/docs/vue/introduce-cn/)
|
- [Vuetify](https://vuetifyjs.com/en/)
|
||||||
|
|
||||||
## 开发
|
## 开发
|
||||||
|
|
||||||
|
|||||||
25
components.d.ts
vendored
25
components.d.ts
vendored
@@ -1,25 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
/* prettier-ignore */
|
|
||||||
// @ts-nocheck
|
|
||||||
// Generated by unplugin-vue-components
|
|
||||||
// Read more: https://github.com/vuejs/core/pull/3399
|
|
||||||
import '@vue/runtime-core'
|
|
||||||
|
|
||||||
export {};
|
|
||||||
|
|
||||||
declare module "@vue/runtime-core" {
|
|
||||||
export interface GlobalComponents {
|
|
||||||
ACard: typeof import("ant-design-vue/es")["Card"];
|
|
||||||
ACardMeta: typeof import("ant-design-vue/es")["CardMeta"];
|
|
||||||
ALayout: typeof import("ant-design-vue/es")["Layout"];
|
|
||||||
ALayoutContent: typeof import("ant-design-vue/es")["LayoutContent"];
|
|
||||||
ALayoutSider: typeof import("ant-design-vue/es")["LayoutSider"];
|
|
||||||
AMenu: typeof import("ant-design-vue/es")["Menu"];
|
|
||||||
AMenuItem: typeof import("ant-design-vue/es")["MenuItem"];
|
|
||||||
ATabPane: typeof import("ant-design-vue/es")["TabPane"];
|
|
||||||
ATabs: typeof import("ant-design-vue/es")["Tabs"];
|
|
||||||
RouterLink: typeof import("vue-router")["RouterLink"];
|
|
||||||
RouterView: typeof import("vue-router")["RouterView"];
|
|
||||||
TSidebar: typeof import("./src/components/t-sidebar.vue")["default"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1796
package-lock.json
generated
1796
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
25
package.json
25
package.json
@@ -3,6 +3,7 @@
|
|||||||
"description": "A Tauri App Demo",
|
"description": "A Tauri App Demo",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
|
"author": "BTMuli <bt-muli@outlook.com>",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -10,29 +11,30 @@
|
|||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"tauri": "tauri"
|
"tauri": "tauri"
|
||||||
},
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/BTMuli/Tauri.Genshin/issues"
|
||||||
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"doc": "docs"
|
"doc": "docs"
|
||||||
},
|
},
|
||||||
"repository": {
|
"homepage": "https://github.com/BTMuli/Tauri.Genshin#readme",
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/BTMuli/Tauri.Genshin.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Tauri",
|
"Tauri",
|
||||||
"Node",
|
"Node",
|
||||||
"Typescript",
|
"Typescript",
|
||||||
"Vite"
|
"Vite"
|
||||||
],
|
],
|
||||||
"author": "BTMuli <bt-muli@outlook.com>",
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"repository": {
|
||||||
"url": "https://github.com/BTMuli/Tauri.Genshin/issues"
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/BTMuli/Tauri.Genshin.git"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/BTMuli/Tauri.Genshin#readme",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@mdi/font": "5.9.55",
|
||||||
"@tauri-apps/api": "^1.2.0",
|
"@tauri-apps/api": "^1.2.0",
|
||||||
"ant-design-vue": "^3.2.15",
|
"ant-design-vue": "^3.2.15",
|
||||||
"vue": "^3.2.45"
|
"vue": "^3.2.45",
|
||||||
|
"vuetify": "npm:@vuetify/nightly@next"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^1.2.2",
|
"@tauri-apps/cli": "^1.2.2",
|
||||||
@@ -42,9 +44,10 @@
|
|||||||
"pinia-plugin-persistedstate": "^3.1.0",
|
"pinia-plugin-persistedstate": "^3.1.0",
|
||||||
"prettier": "^2.8.4",
|
"prettier": "^2.8.4",
|
||||||
"typescript": "^4.6.4",
|
"typescript": "^4.6.4",
|
||||||
"unplugin-vue-components": "^0.24.0",
|
|
||||||
"vite": "^4.0.0",
|
"vite": "^4.0.0",
|
||||||
|
"vite-plugin-vuetify": "^1.0.2",
|
||||||
"vue-router": "^4.1.6",
|
"vue-router": "^4.1.6",
|
||||||
"vue-tsc": "^1.0.11"
|
"vue-tsc": "^1.0.11",
|
||||||
|
"vuetify": "^3.1.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/App.vue
31
src/App.vue
@@ -1,13 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-layout style="min-height: 100vh">
|
<v-card>
|
||||||
<!-- 侧边栏 -->
|
<v-layout>
|
||||||
<t-sidebar />
|
<!-- 顶部导航栏 -->
|
||||||
<!-- 内容区 -->
|
<!-- todo 写个组件 -->
|
||||||
<a-layout-content class="app-content">
|
<v-app-bar title="App Bar" />
|
||||||
<!-- 路由组件 -->
|
<!-- 侧边栏菜单 -->
|
||||||
<router-view></router-view>
|
<t-sidebar />
|
||||||
</a-layout-content>
|
<!-- 主体内容 -->
|
||||||
</a-layout>
|
<v-main>
|
||||||
|
<v-container fluid>
|
||||||
|
<router-view />
|
||||||
|
</v-container>
|
||||||
|
</v-main>
|
||||||
|
</v-layout>
|
||||||
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
@@ -21,10 +27,3 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="css">
|
|
||||||
.app-content {
|
|
||||||
padding: 10px;
|
|
||||||
min-height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,51 +1,62 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-layout-sider v-model:collapsed="collpased" collapsible :theme="theme">
|
<v-navigation-drawer permanent :rail="rail">
|
||||||
<a-menu
|
<v-list>
|
||||||
v-model:selected-keys="selectedKeys"
|
<!-- 第一个图标,负责收缩侧边栏 -->
|
||||||
:theme="theme"
|
<v-list-item @click="collapse">
|
||||||
mode="inline"
|
<v-list-item-action>
|
||||||
@select="selectMenu"
|
<v-icon>mdi-menu</v-icon>
|
||||||
>
|
</v-list-item-action>
|
||||||
<a-menu-item key="home">
|
</v-list-item>
|
||||||
<HomeOutlined />
|
<!-- 菜单项 -->
|
||||||
<span>首页</span>
|
<v-list-subheader>
|
||||||
</a-menu-item>
|
<v-icon>mdi-bug-outline</v-icon>
|
||||||
<a-menu-item key="news">
|
<span v-show="!rail"> 测试功能 </span>
|
||||||
<ScheduleOutlined />
|
</v-list-subheader>
|
||||||
<span>咨讯</span>
|
<v-list-item @click="toPage('/news')">
|
||||||
</a-menu-item>
|
<template v-slot:prepend>
|
||||||
<a-menu-item key="config">
|
<v-icon>mdi-calendar-text-outline</v-icon>
|
||||||
<SettingOutlined />
|
</template>
|
||||||
<span>设置</span>
|
<v-list-item-title v-show="!rail"> 咨讯 </v-list-item-title>
|
||||||
</a-menu-item>
|
</v-list-item>
|
||||||
</a-menu>
|
<v-list-subheader>
|
||||||
</a-layout-sider>
|
<v-icon>mdi-cog-outline</v-icon>
|
||||||
|
<span v-show="!rail"> 开发功能 </span>
|
||||||
|
</v-list-subheader>
|
||||||
|
<v-list-item @click="toPage('/config')">
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-icon>mdi-cog-outline</v-icon>
|
||||||
|
</template>
|
||||||
|
<v-list-item-title v-show="!rail"> 设置 </v-list-item-title>
|
||||||
|
</v-list-item>
|
||||||
|
|
||||||
|
<v-list-subheader>
|
||||||
|
<v-icon>mdi-rocket-outline</v-icon>
|
||||||
|
<span v-show="!rail"> 预期功能 </span>
|
||||||
|
</v-list-subheader>
|
||||||
|
</v-list>
|
||||||
|
</v-navigation-drawer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import { HomeOutlined, ScheduleOutlined, SettingOutlined } from "@ant-design/icons-vue";
|
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "TSidebar",
|
name: "TSidebar",
|
||||||
components: {
|
|
||||||
HomeOutlined,
|
|
||||||
ScheduleOutlined,
|
|
||||||
SettingOutlined,
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
rail: true,
|
||||||
router: useRouter(),
|
router: useRouter(),
|
||||||
collpased: false,
|
|
||||||
selectedKeys: ["home"],
|
|
||||||
theme: "dark",
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
selectMenu({ key }: { key: string }) {
|
collapse() {
|
||||||
this.selectedKeys = [key];
|
this.rail = !this.rail;
|
||||||
this.router.push(key);
|
},
|
||||||
|
toPage(path: string) {
|
||||||
|
if (this.router.currentRoute.path !== path) {
|
||||||
|
this.router.push(path);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import { createApp } from "vue";
|
|||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
// 路由
|
// 路由
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
// Pinia
|
import store from "./store";
|
||||||
import { pinia } from "./store";
|
// Vuetify
|
||||||
|
import "@mdi/font/css/materialdesignicons.css";
|
||||||
|
import "vuetify/styles";
|
||||||
|
import { createVuetify } from "vuetify";
|
||||||
|
|
||||||
createApp(App).use(router).use(pinia).mount("#app");
|
createApp(App).use(router).use(store).use(createVuetify()).mount("#app");
|
||||||
|
|||||||
@@ -1,48 +1,84 @@
|
|||||||
<template>
|
<template>
|
||||||
<a-tabs v-model:active-key="activeKey" type="card">
|
<v-tabs v-model="tab" align-tabs="start" stacked>
|
||||||
<!-- todo 专门写一个卡片组件来展示数据 -->
|
<v-tab value="activity">活动</v-tab>
|
||||||
<a-tab-pane key="activity" tab="活动">
|
<v-tab value="news">新闻</v-tab>
|
||||||
<!-- 遍历渲染活动卡片 -->
|
<v-tab value="notice">公告</v-tab>
|
||||||
|
</v-tabs>
|
||||||
|
<v-window v-model="tab">
|
||||||
|
<v-window-item value="activity">
|
||||||
<div v-show="postData.activity === {}">暂无活动</div>
|
<div v-show="postData.activity === {}">暂无活动</div>
|
||||||
<div class="cards-grid" v-show="postData.activity !== {}">
|
<div class="cards-grid" v-show="postData.activity !== {}">
|
||||||
<a-card v-for="item in postData.activity" @click="toPost(item.post_id)">
|
<v-card
|
||||||
<template #cover>
|
v-for="item in postData.activity"
|
||||||
<img :src="item.cover" alt="cover" class="card-cover" />
|
class="justify-space-between flex-nowrap"
|
||||||
</template>
|
width="320"
|
||||||
<a-card-meta :title="item.title" :description="item.post_id" />
|
>
|
||||||
</a-card>
|
<v-img :src="item.cover" class="post-cover"></v-img>
|
||||||
|
<v-card-title>{{ item.title }}</v-card-title>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn
|
||||||
|
@click="toPost(item.post_id)"
|
||||||
|
prepend-icon="mdi-arrow-right-circle"
|
||||||
|
class="ms-2 bg-blue-accent-2"
|
||||||
|
>查看</v-btn
|
||||||
|
>
|
||||||
|
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
</a-tab-pane>
|
</v-window-item>
|
||||||
<a-tab-pane key="news" tab="新闻">
|
<v-window-item value="news">
|
||||||
<div v-show="postData.news === {}">暂无新闻</div>
|
<div v-show="postData.news === {}">暂无新闻</div>
|
||||||
<div class="cards-grid" v-show="postData.news !== {}">
|
<div class="cards-grid" v-show="postData.news !== {}">
|
||||||
<a-card v-for="item in postData.news" @click="toPost(item.post_id)">
|
<v-card
|
||||||
<template #cover>
|
v-for="item in postData.news"
|
||||||
<img :src="item.cover" alt="cover" class="card-cover" />
|
class="justify-space-between flex-nowrap"
|
||||||
</template>
|
width="320"
|
||||||
<a-card-meta :title="item.title" :description="item.post_id" />
|
>
|
||||||
</a-card>
|
<v-img :src="item.cover" class="post-cover"></v-img>
|
||||||
|
<v-card-title>{{ item.title }}</v-card-title>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn
|
||||||
|
@click="toPost(item.post_id)"
|
||||||
|
prepend-icon="mdi-arrow-right-circle"
|
||||||
|
class="ms-2 bg-blue-accent-2"
|
||||||
|
>查看</v-btn
|
||||||
|
>
|
||||||
|
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
</a-tab-pane>
|
</v-window-item>
|
||||||
<a-tab-pane key="notice" tab="公告">
|
<v-window-item value="notice">
|
||||||
<div v-show="postData.notice === {}">暂无公告</div>
|
<div v-show="postData.news === {}">暂无新闻</div>
|
||||||
<div class="cards-grid" v-show="postData.notice !== {}">
|
<div class="cards-grid" v-show="postData.news !== {}">
|
||||||
<a-card v-for="item in postData.notice" @click="toPost(item.post_id)">
|
<v-card
|
||||||
<template #cover>
|
v-for="item in postData.notice"
|
||||||
<img :src="item.cover" alt="cover" class="card-cover" />
|
class="justify-space-between flex-nowrap"
|
||||||
</template>
|
width="320"
|
||||||
<a-card-meta :title="item.title" :description="item.post_id" />
|
>
|
||||||
</a-card>
|
<!-- todo: 优化图片显示 -->
|
||||||
|
<v-img :src="item.cover" class="post-cover"></v-img>
|
||||||
|
<v-card-title>{{ item.title }}</v-card-title>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn
|
||||||
|
@click="toPost(item.post_id)"
|
||||||
|
prepend-icon="mdi-arrow-right-circle"
|
||||||
|
class="ms-2 bg-blue-accent-2"
|
||||||
|
>查看</v-btn
|
||||||
|
>
|
||||||
|
<v-card-subtitle>id:{{ item.post_id }}</v-card-subtitle>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
</a-tab-pane>
|
</v-window-item>
|
||||||
</a-tabs>
|
</v-window>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import { MysPostType, ResponseListType, ResponseType } from "../interface/MysPost";
|
import { MysPostType, ResponseListType, ResponseType } from "../interface/MysPost";
|
||||||
import { http } from "@tauri-apps/api";
|
import { http } from "@tauri-apps/api";
|
||||||
import { ResponseType as TauriResponseType } from "@tauri-apps/api/http";
|
|
||||||
|
|
||||||
const MysApi = "https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids=2&type=";
|
const MysApi = "https://bbs-api.mihoyo.com/post/wapi/getNewsList?gids=2&type=";
|
||||||
const enum MysType {
|
const enum MysType {
|
||||||
@@ -59,7 +95,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeKey: "activity",
|
tab: "activity",
|
||||||
postData: {
|
postData: {
|
||||||
activity: {},
|
activity: {},
|
||||||
news: {},
|
news: {},
|
||||||
@@ -151,10 +187,9 @@ export default defineComponent({
|
|||||||
grid-gap: 20px;
|
grid-gap: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-cover {
|
.post-cover {
|
||||||
|
object-fit: cover;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 150px;
|
min-height: 150px;
|
||||||
object-fit: contain;
|
|
||||||
background-color: #f0f2f5;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { createPinia } from "pinia";
|
import { createPinia } from "pinia";
|
||||||
import { createPersistedState } from "pinia-plugin-persistedstate";
|
import { createPersistedState } from "pinia-plugin-persistedstate";
|
||||||
|
|
||||||
const pinia = createPinia();
|
const store = createPinia();
|
||||||
|
|
||||||
pinia.use(createPersistedState());
|
store.use(createPersistedState());
|
||||||
|
|
||||||
export { pinia };
|
export default store;
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import Components from "unplugin-vue-components/vite";
|
// Vuetify
|
||||||
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
|
import vuetify from "vite-plugin-vuetify";
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [vue(), vuetify()],
|
||||||
vue(),
|
|
||||||
Components({
|
|
||||||
resolvers: [AntDesignVueResolver()],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
|
|
||||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||||
// prevent vite from obscuring rust errors
|
// prevent vite from obscuring rust errors
|
||||||
|
|||||||
Reference in New Issue
Block a user