feat: 更新
This commit is contained in:
1 parent
caf4fd2b86
commit
16e6cf572d
19 files changed
+226
-1603
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
interface ImportMetaEnv {
|
interface ImportMetaEnv {
|
||||||
readonly MODE: string
|
|
||||||
readonly VITE_APP_NAME: string
|
readonly VITE_APP_NAME: string
|
||||||
// 更多环境变量...
|
// 更多环境变量...
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
VITE_APP_NAME=vue3培训学习项目
|
VITE_APP_NAME=vue3培训学习项目
|
||||||
|
|
||||||
APP_PROXY_TARGET=https://xtbg.gdzwfw.gov.cn
|
NODE_APP_PROXY_TARGET=https://xtbg.gdzwfw.gov.cn
|
||||||
Vendored
+2
-1
@@ -1,2 +1,3 @@
|
|||||||
|
VITE_APP_NAME=vue3培训学习项目-测试
|
||||||
VITE_APP_XXX=哈哈哈哈
|
VITE_APP_XXX=哈哈哈哈
|
||||||
APP_PROXY_TARGET=https://xtbgtest.digitalgd.com.cn
|
NODE_APP_PROXY_TARGET=https://xtbgtest.digitalgd.com.cn
|
||||||
Generated
+6
-1519
File diff suppressed because it is too large.
Load diff
@@ -24,13 +24,11 @@
|
|||||||
"@rushstack/eslint-patch": "^1.3.3",
|
"@rushstack/eslint-patch": "^1.3.3",
|
||||||
"@tsconfig/node18": "^18.2.2",
|
"@tsconfig/node18": "^18.2.2",
|
||||||
"@types/node": "^18.18.5",
|
"@types/node": "^18.18.5",
|
||||||
"@vitejs/plugin-legacy": "^5.2.0",
|
|
||||||
"@vitejs/plugin-vue": "^4.4.0",
|
"@vitejs/plugin-vue": "^4.4.0",
|
||||||
"@vitejs/plugin-vue-jsx": "^3.0.2",
|
"@vitejs/plugin-vue-jsx": "^3.0.2",
|
||||||
"@vue/eslint-config-prettier": "^8.0.0",
|
"@vue/eslint-config-prettier": "^8.0.0",
|
||||||
"@vue/eslint-config-typescript": "^12.0.0",
|
"@vue/eslint-config-typescript": "^12.0.0",
|
||||||
"@vue/tsconfig": "^0.4.0",
|
"@vue/tsconfig": "^0.4.0",
|
||||||
"cross-env": "^7.0.3",
|
|
||||||
"eslint": "^8.49.0",
|
"eslint": "^8.49.0",
|
||||||
"eslint-plugin-vue": "^9.17.0",
|
"eslint-plugin-vue": "^9.17.0",
|
||||||
"npm-run-all2": "^6.1.1",
|
"npm-run-all2": "^6.1.1",
|
||||||
|
|||||||
+27
-26
@@ -1,28 +1,29 @@
|
|||||||
const { APP_PROXY_TARGET } = process.env;
|
const proxyConfig = (env: Record<string, string>) => {
|
||||||
const proxyTarget = APP_PROXY_TARGET || "";
|
const { NODE_APP_PROXY_TARGET } = env;
|
||||||
|
const proxyTarget = NODE_APP_PROXY_TARGET || "";
|
||||||
console.log("--------------", APP_PROXY_TARGET)
|
const proxyTable = {
|
||||||
const proxyTable = {
|
"/zuul": {
|
||||||
"/zuul": {
|
target: proxyTarget,
|
||||||
target: proxyTarget,
|
changeOrigin: true
|
||||||
changeOrigin: true
|
},
|
||||||
},
|
"/media/": {
|
||||||
"/media/": {
|
target: proxyTarget,
|
||||||
target: proxyTarget,
|
changeOrigin: true
|
||||||
changeOrigin: true
|
},
|
||||||
},
|
"/zwwxgzt": {
|
||||||
"/zwwxgzt": {
|
target: proxyTarget,
|
||||||
target: proxyTarget,
|
changeOrigin: true
|
||||||
changeOrigin: true
|
},
|
||||||
},
|
"/midjs": {
|
||||||
"/midjs": {
|
target: proxyTarget,
|
||||||
target: proxyTarget,
|
changeOrigin: true
|
||||||
changeOrigin: true
|
},
|
||||||
},
|
"/irc": {
|
||||||
"/irc": {
|
target: proxyTarget,
|
||||||
target: proxyTarget,
|
changeOrigin: true
|
||||||
changeOrigin: true
|
}
|
||||||
}
|
};
|
||||||
|
return proxyTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default proxyTable;
|
export default proxyConfig;
|
||||||
@@ -1,12 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="error">
|
<div class="error">
|
||||||
<img src="../assets/meme_sad_frog.svg" width="200px" />
|
<img src="../assets/meme_sad_frog.svg" width="200px" />
|
||||||
<p>加载组件出错了!</p>
|
<p>{{ massage }}</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
interface errorProps {
|
||||||
|
massage?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
withDefaults(defineProps<errorProps>(), {
|
||||||
|
massage: "加载出错了!"
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="asynccomp">
|
<div class="asynccomp">
|
||||||
<img src="@/assets/meme_salt_bae.svg" />
|
<img src="@/assets/meme_salt_bae.svg" />
|
||||||
<p>嘿嘿~</p>
|
<p>优雅~</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="asynccomp">
|
<div class="asynccomp">
|
||||||
<img src="@/assets/meme_hide_the_pain_harold.svg" />
|
<img src="@/assets/meme_hide_the_pain_harold.svg" />
|
||||||
<p>嘿嘿~</p>
|
<p>幸福~</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -1,7 +1,7 @@
|
|||||||
import "./styles/index.less";
|
import "./styles/index.less";
|
||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
import router from "./router/guards";
|
import router from "./router";
|
||||||
import pinia from "./stores/pinia";
|
import pinia from "./stores/pinia";
|
||||||
import { install } from "./installComponents";
|
import { install } from "./installComponents";
|
||||||
|
|
||||||
@@ -10,6 +10,4 @@ const app = createApp(App);
|
|||||||
app.use(pinia);
|
app.use(pinia);
|
||||||
app.use(router);
|
app.use(router);
|
||||||
install(app);
|
install(app);
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
|
|
||||||
console.log("-------", import.meta.env);
|
|
||||||
+25
-4
@@ -247,6 +247,18 @@ const routes = [
|
|||||||
name: "router",
|
name: "router",
|
||||||
meta: { title: "路由router" },
|
meta: { title: "路由router" },
|
||||||
children: [
|
children: [
|
||||||
|
{
|
||||||
|
path: "/router/transition",
|
||||||
|
name: "routerTransition",
|
||||||
|
meta: { title: "路由过渡动效" },
|
||||||
|
component: () => import("@/views/router/RouterTransition.vue")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/router/dynamic",
|
||||||
|
name: "routerDynamic",
|
||||||
|
meta: { title: "动态路由" },
|
||||||
|
component: () => import("@/views/router/RouterDynamic.vue")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/router/guard",
|
path: "/router/guard",
|
||||||
name: "routerGuard",
|
name: "routerGuard",
|
||||||
@@ -261,11 +273,20 @@ const routes = [
|
|||||||
meta: {},
|
meta: {},
|
||||||
component: () => import("@/EnterLoading.vue")
|
component: () => import("@/EnterLoading.vue")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/noaccess/:text?",
|
||||||
|
name: "noaccess",
|
||||||
|
props: true,
|
||||||
|
component: () => import("@/views/error/NoAccess.vue")
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/noaccess/:text?",
|
path: "/404",
|
||||||
name: "noaccess",
|
name: "404",
|
||||||
props: true,
|
component: () => import("@/views/error/Error404.vue")
|
||||||
component: () => import("@/views/error/NoAccess.vue")
|
},
|
||||||
|
{
|
||||||
|
path: "/:catchAll(.*)",
|
||||||
|
redirect: "/404"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -32,14 +32,6 @@ const showAsyncComponent = () => {
|
|||||||
const AsyncComp = defineAsyncComponent({
|
const AsyncComp = defineAsyncComponent({
|
||||||
// 加载函数
|
// 加载函数
|
||||||
loader: () => import("@/components/async/VAsyncComp1.vue"),
|
loader: () => import("@/components/async/VAsyncComp1.vue"),
|
||||||
// loader: () => {
|
|
||||||
// // const comp = () => import("../../components/async/VAsyncComp1.vue");
|
|
||||||
// return new Promise(resolve => {
|
|
||||||
// setTimeout(() => {
|
|
||||||
// resolve(() => import("../../components/async/VAsyncComp1.vue"));
|
|
||||||
// }, 2000);
|
|
||||||
// });
|
|
||||||
// },
|
|
||||||
// 加载异步组件时使用的组件
|
// 加载异步组件时使用的组件
|
||||||
loadingComponent: VLoading,
|
loadingComponent: VLoading,
|
||||||
// 展示加载组件前的延迟时间,默认为 200ms
|
// 展示加载组件前的延迟时间,默认为 200ms
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<VError massage="你的页面飞走了" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import VError from "@/components/VError.vue";
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -10,11 +10,12 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { inject } from "vue";
|
import { inject } from "vue";
|
||||||
|
import type { Ref } from "vue";
|
||||||
|
|
||||||
const num = inject("num");
|
const num = inject<Ref>("num");
|
||||||
|
|
||||||
const clickHander = () => {
|
const clickHander = () => {
|
||||||
num.value++;
|
if (num) num.value++;
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -22,8 +23,9 @@ const clickHander = () => {
|
|||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
div {
|
div {
|
||||||
border: 3px solid #aaa;
|
border: 3px solid #aaa;
|
||||||
padding:10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
button {
|
button {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { ref, provide } from "vue";
|
|||||||
import InjectBase from "./InjectBase.vue";
|
import InjectBase from "./InjectBase.vue";
|
||||||
|
|
||||||
|
|
||||||
const count = ref(0);
|
const count = ref<number>(0);
|
||||||
provide("num", count);
|
provide("num", count);
|
||||||
|
|
||||||
const clickHander = () => {
|
const clickHander = () => {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { ref, provide, readonly } from "vue";
|
|||||||
import InjectBase from "./InjectBase.vue";
|
import InjectBase from "./InjectBase.vue";
|
||||||
|
|
||||||
|
|
||||||
const count = ref(0);
|
const count = ref<number>(0);
|
||||||
provide("num", readonly(count));
|
provide("num", readonly(count));
|
||||||
|
|
||||||
const clickHander = () => {
|
const clickHander = () => {
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
<button @click="addHandler">添加</button>
|
||||||
|
</p>
|
||||||
|
<br />
|
||||||
|
<p>
|
||||||
|
<button @click="removeHandler">删除</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
// import { ref } from "vue";
|
||||||
|
import router from "@/router";
|
||||||
|
import type { RouteRecordRaw } from "vue-router";
|
||||||
|
|
||||||
|
const routerItem: RouteRecordRaw = {
|
||||||
|
path: "/heihei", name: "heihei", component: () => import("../../components/async/VAsyncComp1.vue")
|
||||||
|
};
|
||||||
|
|
||||||
|
const addHandler = () => {
|
||||||
|
router.addRoute(routerItem);
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeHandler = () => {
|
||||||
|
router.removeRoute("heihei");
|
||||||
|
};
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
button {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<button v-for="(item, index) in components" :key="`${item.name}_${index}`" @click="clickButton(index)">按钮{{ index
|
||||||
|
+ 1 }}</button>
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<transition :enter-active-class="`animate__animated ${atciveTransition}`">
|
||||||
|
<component :is="renderComponent" />
|
||||||
|
</transition>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref } from "vue";
|
||||||
|
import VAsyncComp1 from "@/components/async/VAsyncComp1.vue";
|
||||||
|
import VAsyncComp2 from "@/components/async/VAsyncComp2.vue";
|
||||||
|
import VAsyncComp3 from "@/components/async/VAsyncComp3.vue";
|
||||||
|
|
||||||
|
const components = [
|
||||||
|
{
|
||||||
|
name: VAsyncComp1.name || VAsyncComp1.__name,
|
||||||
|
component: VAsyncComp1,
|
||||||
|
transition: "animate__fadeInUp"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: VAsyncComp2.name || VAsyncComp2.__name,
|
||||||
|
component: VAsyncComp2,
|
||||||
|
transition: "animate__bounceIn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: VAsyncComp3.name || VAsyncComp3.__name,
|
||||||
|
component: VAsyncComp3,
|
||||||
|
transition: "animate__rotateIn"
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const activeButton = ref(0);
|
||||||
|
const clickButton = (index: number) => {
|
||||||
|
activeButton.value = index;
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderComponent = computed(() => {
|
||||||
|
return components[activeButton.value].component;
|
||||||
|
});
|
||||||
|
const atciveTransition = computed(() => {
|
||||||
|
return components[activeButton.value].transition;
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="less">
|
||||||
|
button {
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
@import "https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css";
|
||||||
|
</style>
|
||||||
+39
-29
@@ -1,38 +1,48 @@
|
|||||||
import { fileURLToPath, URL } from "node:url";
|
import { fileURLToPath, URL } from "node:url";
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig, loadEnv } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import vueJsx from "@vitejs/plugin-vue-jsx";
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
import legacy from "@vitejs/plugin-legacy";
|
|
||||||
import VueSetupExtend from "vite-plugin-vue-setup-extend";
|
import VueSetupExtend from "vite-plugin-vue-setup-extend";
|
||||||
import proxyConfig from "./proxy.config";
|
import proxyConfig from "./proxy.config";
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig(({ mode }) => {
|
||||||
base: "./",
|
// 根据当前工作目录中的 `mode` 加载 .env 文件
|
||||||
envDir: "./env",
|
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
|
||||||
plugins: [
|
const envDir = `${process.cwd()}/env`;
|
||||||
vue(),
|
const env = loadEnv(mode, envDir, "NODE_APP_");
|
||||||
vueJsx(),
|
return {
|
||||||
VueSetupExtend(),
|
base: "./",
|
||||||
|
envDir: "./env",
|
||||||
legacy({
|
plugins: [
|
||||||
// targets: ["defaults", "not IE 11"],
|
vue(),
|
||||||
targets: {
|
vueJsx(),
|
||||||
"chrome": "120"
|
VueSetupExtend()
|
||||||
},
|
],
|
||||||
additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
|
resolve: {
|
||||||
renderLegacyChunks: true,
|
alias: {
|
||||||
polyfills: [
|
"@": fileURLToPath(new URL("./src", import.meta.url))
|
||||||
"es.array.to-reversed"
|
}
|
||||||
]
|
},
|
||||||
})
|
server: {
|
||||||
],
|
proxy: proxyConfig(env)
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
"@": fileURLToPath(new URL("./src", import.meta.url))
|
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
server: {
|
|
||||||
proxy: proxyConfig
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
// export default defineConfig({
|
||||||
|
// base: "./",
|
||||||
|
// envDir: "./env",
|
||||||
|
// plugins: [
|
||||||
|
// vue(),
|
||||||
|
// vueJsx(),
|
||||||
|
// VueSetupExtend()
|
||||||
|
// ],
|
||||||
|
// resolve: {
|
||||||
|
// alias: {
|
||||||
|
// "@": fileURLToPath(new URL("./src", import.meta.url))
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// server: {
|
||||||
|
// proxy: proxyConfig
|
||||||
|
// }
|
||||||
|
// });
|
||||||
Reference in new issue
Block a user