Skip to content

Commit

Permalink
refactor(project): re-adjust the overall folder
Browse files Browse the repository at this point in the history
  • Loading branch information
vince292007 committed Jul 22, 2024
1 parent a1a566c commit 14538f7
Show file tree
Hide file tree
Showing 281 changed files with 1,365 additions and 1,659 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@
},

"cssVariables.lookupFiles": [
"packages/@vben-core/shared/design-tokens/src/**/*.css"
"packages/@vben-core/shared/design/src/**/*.css"
],

"i18n-ally.localesPaths": [
"packages/@core/locales/src/langs",
"packages/locales/src/langs",
"apps/*/src/locales/langs"
],
"i18n-ally.enabledParsers": ["json", "ts", "js", "yaml"],
Expand Down
9 changes: 4 additions & 5 deletions apps/web-antd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@
"#/*": "./src/*"
},
"dependencies": {
"@vben-core/helpers": "workspace:*",
"@vben-core/locales": "workspace:*",
"@vben-core/preferences": "workspace:*",
"@vben-core/request": "workspace:*",
"@vben-core/stores": "workspace:*",
"@vben/access": "workspace:*",
"@vben/chart-ui": "workspace:*",
"@vben/common-ui": "workspace:*",
"@vben/constants": "workspace:*",
"@vben/hooks": "workspace:*",
"@vben/icons": "workspace:*",
"@vben/layouts": "workspace:*",
"@vben/locales": "workspace:*",
"@vben/preferences": "workspace:*",
"@vben/request": "workspace:*",
"@vben/stores": "workspace:*",
"@vben/styles": "workspace:*",
"@vben/types": "workspace:*",
"@vben/utils": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/src/apis/core/auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { UserApi } from '../types';

import { requestClient } from '#/forward';
import { requestClient } from '#/apis/request';

/**
* 登录
Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/src/apis/core/menu.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { RouteRecordStringComponent } from '@vben/types';

import { requestClient } from '#/forward';
import { requestClient } from '#/apis/request';

/**
* 获取用户所有菜单
Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/src/apis/core/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { UserInfo } from '@vben/types';

import { requestClient } from '#/forward';
import { requestClient } from '#/apis/request';

/**
* 获取用户信息
Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/src/apis/demos/status.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { requestClient } from '#/forward';
import { requestClient } from '#/apis/request';

/**
* 模拟任意状态码
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/**
* 该文件可自行根据业务逻辑进行调整
*/
import type { HttpResponse } from '@vben-core/request';
import type { HttpResponse } from '@vben/request';

import { preferences } from '@vben-core/preferences';
import { RequestClient } from '@vben-core/request';
import { preferences } from '@vben/preferences';
import { RequestClient } from '@vben/request';

import { message } from 'ant-design-vue';

Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { computed } from 'vue';
import { GlobalProvider } from '@vben/common-ui';
import { preferences, usePreferences } from '@vben-core/preferences';
import { preferences, usePreferences } from '@vben/preferences';
import { App, ConfigProvider, theme } from 'ant-design-vue';
Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/src/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createApp } from 'vue';

import { preferences } from '@vben/preferences';
import '@vben/styles';
import '@vben/styles/antd';
import { preferences } from '@vben-core/preferences';

import { loadMessages, setupI18n } from '#/locales';
import { setupStore } from '#/store';
Expand Down
11 changes: 0 additions & 11 deletions apps/web-antd/src/forward/README.md

This file was deleted.

2 changes: 0 additions & 2 deletions apps/web-antd/src/forward/index.ts

This file was deleted.

22 changes: 4 additions & 18 deletions apps/web-antd/src/layouts/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
NotificationItem,
UserDropdown,
} from '@vben/layouts';
import { preferences } from '@vben/preferences';
import { openWindow } from '@vben/utils';
import { preferences } from '@vben-core/preferences';
import { $t } from '#/locales';
import { resetRoutes } from '#/router';
import { storeToRefs, useAccessStore, useAppStore } from '#/store';
import { resetAllStores, storeToRefs, useAccessStore } from '#/store';
const notifications = ref<NotificationItem[]>([
{
Expand Down Expand Up @@ -84,10 +84,8 @@ const menus = computed(() => [
},
]);
const appStore = useAppStore();
const accessStore = useAccessStore();
const { isLockScreen, lockScreenPassword } = storeToRefs(appStore);
const {
loading: loginLoading,
openLoginExpiredModal,
Expand All @@ -101,8 +99,7 @@ const avatar = computed(() => {
const router = useRouter();
async function handleLogout() {
appStore.resetAppState();
appStore.unlockScreen();
resetAllStores();
resetRoutes();
await router.replace(LOGIN_PATH);
}
Expand All @@ -114,10 +111,6 @@ function handleNoticeClear() {
function handleMakeAll() {
notifications.value.forEach((item) => (item.isRead = true));
}
function handleLockScreen(password: string) {
appStore.lockScreen(password);
}
</script>

<template>
Expand All @@ -129,7 +122,6 @@ function handleLockScreen(password: string) {
:text="userInfo?.realName"
description="[email protected]"
tag-text="Pro"
@lock-screen="handleLockScreen"
@logout="handleLogout"
/>
</template>
Expand All @@ -152,13 +144,7 @@ function handleLockScreen(password: string) {
/>
</template>
<template #lock-screen>
<LockScreen
v-if="isLockScreen"
:avatar
:cached-password="lockScreenPassword"
@to-login="handleLogout"
@unlock="appStore.unlockScreen"
/>
<LockScreen :avatar @to-login="handleLogout" />
</template>
</BasicLayout>
</template>
2 changes: 1 addition & 1 deletion apps/web-antd/src/locales/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Locale } from 'ant-design-vue/es/locale';

import { ref } from 'vue';

import { $t, loadLocalesMap, setupI18n } from '@vben-core/locales';
import { $t, loadLocalesMap, setupI18n } from '@vben/locales';

import antdEnLocale from 'ant-design-vue/es/locale/en_US';
import antdDefaultLocale from 'ant-design-vue/es/locale/zh_CN';
Expand Down
4 changes: 2 additions & 2 deletions apps/web-antd/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { preferencesManager } from '@vben-core/preferences';
import { initPreferences } from '@vben/preferences';

import { overridesPreferences } from './preferences';

Expand All @@ -12,7 +12,7 @@ async function initApplication() {
const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${env}`;

// app偏好设置初始化
await preferencesManager.initPreferences({
await initPreferences({
namespace,
overrides: overridesPreferences,
});
Expand Down
2 changes: 1 addition & 1 deletion apps/web-antd/src/preferences.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineOverridesPreferences } from '@vben-core/preferences';
import { defineOverridesPreferences } from '@vben/preferences';

/**
* @description 项目配置文件
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
} from '@vben/types';

import { generateAccessible } from '@vben/access';
import { preferences } from '@vben-core/preferences';
import { preferences } from '@vben/preferences';

import { message } from 'ant-design-vue';

Expand Down
5 changes: 3 additions & 2 deletions apps/web-antd/src/router/guard.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import type { Router } from 'vue-router';

import { LOGIN_PATH } from '@vben/constants';
import { preferences } from '@vben/preferences';
import { startProgress, stopProgress } from '@vben/utils';
import { preferences } from '@vben-core/preferences';

import { useTitle } from '@vueuse/core';

import { generateAccess } from '#/forward';
import { $t } from '#/locales';
import { coreRouteNames, dynamicRoutes } from '#/router/routes';
import { useAccessStore } from '#/store';

import { generateAccess } from './access';

/**
* 通用守卫配置
* @param router
Expand Down
3 changes: 1 addition & 2 deletions apps/web-antd/src/router/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { RouteRecordRaw } from 'vue-router';

import { traverseTreeValues } from '@vben/utils';
import { mergeRouteModules } from '@vben-core/helpers';
import { mergeRouteModules, traverseTreeValues } from '@vben/utils';

import { coreRoutes, fallbackNotFoundRoute } from './core';

Expand Down
7 changes: 3 additions & 4 deletions apps/web-antd/src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { InitStoreOptions } from '@vben-core/stores';
import type { InitStoreOptions } from '@vben/stores';

import type { App } from 'vue';

import { initStore, storeToRefs } from '@vben-core/stores';
import { initStore, resetAllStores, storeToRefs } from '@vben/stores';

/**
* @zh_CN 初始化pinia
Expand All @@ -13,7 +13,6 @@ async function setupStore(app: App, options: InitStoreOptions) {
app.use(pinia);
}

export { setupStore, storeToRefs };
export { resetAllStores, setupStore, storeToRefs };

export { useAccessStore } from './modules/access';
export { useAppStore } from './modules/app';
15 changes: 8 additions & 7 deletions apps/web-antd/src/store/modules/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { computed, ref } from 'vue';
import { useRouter } from 'vue-router';

import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
import { useCoreAccessStore } from '@vben-core/stores';
import { resetAllStores, useCoreAccessStore } from '@vben/stores';

import { notification } from 'ant-design-vue';
import { defineStore } from 'pinia';
Expand Down Expand Up @@ -50,7 +50,7 @@ export const useAccessStore = defineStore('access', () => {
onSuccess?: () => Promise<void> | void,
) {
// 异步处理用户登录操作并获取 accessToken
let userInfo: UserInfo | null = null;
let userInfo: null | UserInfo = null;
try {
loading.value = true;
const { accessToken, refreshToken } = await login(params);
Expand Down Expand Up @@ -102,7 +102,7 @@ export const useAccessStore = defineStore('access', () => {
}

async function logout() {
coreStoreAccess.$reset();
resetAllStores();
openLoginExpiredModal.value = false;

// 回登陆页带上当前路由地址
Expand All @@ -115,17 +115,19 @@ export const useAccessStore = defineStore('access', () => {
}

async function fetchUserInfo() {
let userInfo: UserInfo | null = null;
let userInfo: null | UserInfo = null;
userInfo = await getUserInfo();
coreStoreAccess.setUserInfo(userInfo);
return userInfo;
}

function reset() {
coreStoreAccess.$reset();
function $reset() {
loading.value = false;
openLoginExpiredModal.value = false;
}

return {
$reset,
accessRoutes,
accessToken,
authLogin,
Expand All @@ -134,7 +136,6 @@ export const useAccessStore = defineStore('access', () => {
logout,
openLoginExpiredModal,
refreshToken,
reset,
setAccessMenus,
setAccessRoutes,
setAccessToken,
Expand Down
7 changes: 6 additions & 1 deletion apps/web-antd/src/views/_core/authentication/code-login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { LoginCodeParams } from '@vben/common-ui';
import { ref } from 'vue';
import { AuthenticationCodeLogin } from '@vben/common-ui';
import { LOGIN_PATH } from '@vben/constants';
defineOptions({ name: 'CodeLogin' });
Expand All @@ -21,5 +22,9 @@ async function handleLogin(values: LoginCodeParams) {
</script>

<template>
<AuthenticationCodeLogin :loading="loading" @submit="handleLogin" />
<AuthenticationCodeLogin
:loading="loading"
:login-path="LOGIN_PATH"
@submit="handleLogin"
/>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ref } from 'vue';
import { AuthenticationForgetPassword } from '@vben/common-ui';
import { LOGIN_PATH } from '@vben/constants';
defineOptions({ name: 'ForgetPassword' });
Expand All @@ -14,5 +15,9 @@ function handleSubmit(value: string) {
</script>

<template>
<AuthenticationForgetPassword :loading="loading" @submit="handleSubmit" />
<AuthenticationForgetPassword
:loading="loading"
:login-path="LOGIN_PATH"
@submit="handleSubmit"
/>
</template>
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script lang="ts" setup>
import { AuthenticationQrCodeLogin } from '@vben/common-ui';
import { LOGIN_PATH } from '@vben/constants';
defineOptions({ name: 'QrCodeLogin' });
</script>

<template>
<AuthenticationQrCodeLogin />
<AuthenticationQrCodeLogin :login-path="LOGIN_PATH" />
</template>
7 changes: 6 additions & 1 deletion apps/web-antd/src/views/_core/authentication/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { LoginAndRegisterParams } from '@vben/common-ui';
import { ref } from 'vue';
import { AuthenticationRegister } from '@vben/common-ui';
import { LOGIN_PATH } from '@vben/constants';
defineOptions({ name: 'Register' });
Expand All @@ -16,5 +17,9 @@ function handleSubmit(value: LoginAndRegisterParams) {
</script>

<template>
<AuthenticationRegister :loading="loading" @submit="handleSubmit" />
<AuthenticationRegister
:loading="loading"
:login-path="LOGIN_PATH"
@submit="handleSubmit"
/>
</template>
Loading

0 comments on commit 14538f7

Please sign in to comment.