mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): 代码优化
This commit is contained in:
BIN
src/assets/fonts/aguazyuan-bold.ttf
Normal file
BIN
src/assets/fonts/aguazyuan-bold.ttf
Normal file
Binary file not shown.
BIN
src/assets/fonts/aguazyuan-light.ttf
Normal file
BIN
src/assets/fonts/aguazyuan-light.ttf
Normal file
Binary file not shown.
BIN
src/assets/fonts/aguazyuan-regular.ttf
Normal file
BIN
src/assets/fonts/aguazyuan-regular.ttf
Normal file
Binary file not shown.
@ -7,7 +7,7 @@ interface DemoContext {
|
||||
setCounts: (count: number) => void;
|
||||
}
|
||||
|
||||
const { useProvide: useDemoProvider, useInject: useDemoInject } = useContext<DemoContext>();
|
||||
const { useProvide: useDemoProvide, useInject: useDemoInject } = useContext<DemoContext>();
|
||||
|
||||
export function useDemoContext() {
|
||||
const counts = ref(0);
|
||||
@ -21,12 +21,12 @@ export function useDemoContext() {
|
||||
setCounts
|
||||
};
|
||||
|
||||
function useProvider() {
|
||||
useDemoProvider(demoContext);
|
||||
function useProvide() {
|
||||
useDemoProvide(demoContext);
|
||||
}
|
||||
|
||||
return {
|
||||
useProvider,
|
||||
useProvide,
|
||||
useInject: useDemoInject
|
||||
};
|
||||
}
|
||||
@ -34,8 +34,8 @@ export function useDemoContext() {
|
||||
// 示例用法: A.vue为父组件, B.vue为子孙组件 C.vue为子孙组件
|
||||
// A.vue
|
||||
// import { useDemoContext } from '@/context';
|
||||
// const { useProvider } = useDemoContext();
|
||||
// useProvider();
|
||||
// const { useProvide } = useDemoContext();
|
||||
// useProvide();
|
||||
|
||||
// B.vue 和 C.vue : 共享状态 counts
|
||||
// import { useDemoContext } from '@/context';
|
||||
|
@ -12,7 +12,7 @@
|
||||
<full-screen />
|
||||
<theme-mode />
|
||||
<system-message />
|
||||
<setting-button v-if="isProd" />
|
||||
<setting-button v-if="showButton" />
|
||||
<user-avatar />
|
||||
</div>
|
||||
</dark-mode-container>
|
||||
@ -47,7 +47,7 @@ defineProps<Props>();
|
||||
|
||||
const theme = useThemeStore();
|
||||
|
||||
const isProd = import.meta.env.PROD;
|
||||
const showButton = import.meta.env.PROD && import.meta.env.VITE_VERCEL !== '1';
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<theme-config />
|
||||
</n-drawer-content>
|
||||
</n-drawer>
|
||||
<drawer-button v-if="isDev" />
|
||||
<drawer-button v-if="showButton" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@ -18,7 +18,7 @@ import { DrawerButton, DarkMode, LayoutMode, ThemeColorSelect, PageFunc, PageVie
|
||||
|
||||
const app = useAppStore();
|
||||
|
||||
const isDev = import.meta.env.DEV;
|
||||
const showButton = import.meta.env.DEV || import.meta.env.VITE_VERCEL === '1';
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
@ -5,10 +5,10 @@ import { constantRoutes } from './routes';
|
||||
import { scrollBehavior } from './helpers';
|
||||
import { createRouterGuard } from './guard';
|
||||
|
||||
const { VITE_HASH_ROUTE = 'false', VITE_BASE_URL } = import.meta.env;
|
||||
const { VITE_HASH_ROUTE = '0', VITE_BASE_URL } = import.meta.env;
|
||||
|
||||
export const router = createRouter({
|
||||
history: VITE_HASH_ROUTE === 'true' ? createWebHashHistory(VITE_BASE_URL) : createWebHistory(VITE_BASE_URL),
|
||||
history: VITE_HASH_ROUTE === '1' ? createWebHashHistory(VITE_BASE_URL) : createWebHistory(VITE_BASE_URL),
|
||||
routes: transformAuthRoutesToVueRoutes(constantRoutes),
|
||||
scrollBehavior
|
||||
});
|
||||
|
@ -2,7 +2,7 @@ import { getEnvConfig } from '~/.env-config';
|
||||
import { createRequest } from './request';
|
||||
|
||||
const envConfig = getEnvConfig(import.meta.env);
|
||||
const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'true';
|
||||
const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === '1';
|
||||
|
||||
export const request = createRequest({ baseURL: isHttpProxy ? envConfig.proxy : envConfig.url });
|
||||
|
||||
|
12
src/typings/env.d.ts
vendored
12
src/typings/env.d.ts
vendored
@ -30,19 +30,21 @@ interface ImportMetaEnv {
|
||||
*/
|
||||
readonly VITE_AUTH_ROUTE_MODE: 'static' | 'dynamic';
|
||||
/** 路由首页的路径 */
|
||||
readonly VITE_ROUTE_HOME_PATH: Exclude<AuthRoute.RoutePath, '/not-found-page' | '/:pathMatch(.*)*'>;
|
||||
readonly VITE_ROUTE_HOME_PATH: Exclude<AuthRoute.RoutePath, '/' | '/not-found-page' | '/:pathMatch(.*)*'>;
|
||||
/** vite环境类型 */
|
||||
readonly VITE_ENV_TYPE?: EnvType;
|
||||
/** 开启请求代理 */
|
||||
readonly VITE_HTTP_PROXY?: 'true' | 'false';
|
||||
readonly VITE_HTTP_PROXY?: '1' | '0';
|
||||
/** 是否开启打包文件大小结果分析 */
|
||||
readonly VITE_VISUALIZER?: 'true' | 'false';
|
||||
readonly VITE_VISUALIZER?: '1' | '0';
|
||||
/** 是否开启打包压缩 */
|
||||
readonly VITE_COMPRESS?: 'true' | 'false';
|
||||
readonly VITE_COMPRESS?: '1' | '0';
|
||||
/** 压缩算法类型 */
|
||||
readonly VITE_COMPRESS_TYPE?: 'gzip' | 'brotliCompress' | 'deflate' | 'deflateRaw';
|
||||
/** hash路由模式 */
|
||||
readonly VITE_HASH_ROUTE?: 'true' | 'false';
|
||||
readonly VITE_HASH_ROUTE?: '1' | '0';
|
||||
/** 是否是部署的vercel */
|
||||
readonly VITE_VERCEL?: '1' | '0';
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
|
5
src/typings/system.d.ts
vendored
5
src/typings/system.d.ts
vendored
@ -21,11 +21,6 @@ declare namespace EnumType {
|
||||
|
||||
/** 请求的相关类型 */
|
||||
declare namespace Service {
|
||||
/** 请求环境类型
|
||||
* - test:测试环境
|
||||
* - prod:正式环境 */
|
||||
type HttpEnv = 'test' | 'prod';
|
||||
|
||||
/**
|
||||
* 请求的错误类型:
|
||||
* - axios: axios错误:网络错误, 请求超时, 默认的兜底错误
|
||||
|
Reference in New Issue
Block a user