Skip to content

Commit

Permalink
refactor: ♻️ 项目升级重构
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxianrui committed Feb 24, 2024
1 parent 7734c49 commit ae67323
Show file tree
Hide file tree
Showing 71 changed files with 2,396 additions and 2,655 deletions.
10 changes: 2 additions & 8 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
## 开发环境

# 变量必须以 VITE_ 为前缀才能暴露给外部读取
NODE_ENV='development'

VITE_APP_TITLE = 'mall-admin'
# 应用端口
VITE_APP_PORT = 9527

# API请求前缀
# 代理前缀
VITE_APP_BASE_API = '/dev-api'

# proxy代理配置
VITE_APP_TARGET_URL = 'http://localhost:9999'
VITE_APP_TARGET_BASE_API = ''
8 changes: 1 addition & 7 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
## 生产环境
NODE_ENV='production'

VITE_APP_TITLE = 'mall-admin'
VITE_APP_PORT = 3000

# API请求前缀
# 代理前缀
VITE_APP_BASE_API = '/prod-api'

# proxy代理配置
VITE_APP_TARGET_URL = "http://vapi.youlai.tech"
VITE_APP_TARGET_BASE_API = ''
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules
dist
dist-ssr
*.local
.history

# Editor directories and files
.idea
Expand Down
10 changes: 9 additions & 1 deletion .stylelintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = {
"custom-property-pattern": null, // 自定义属性命名规则
"keyframes-name-pattern": null, // 动画帧节点样式命名规则
"no-descending-specificity": null, // 允许无降序特异性
"no-empty-source": null, // 允许空样式
// 允许 global 、export 、deep伪类
"selector-pseudo-class-no-unknown": [
true,
Expand All @@ -36,7 +37,14 @@ module.exports = {
"property-no-unknown": [
true,
{
ignoreProperties: ["menuBg", "menuText", "menuActiveText"],
ignoreProperties: [],
},
],
// 允许未知规则
"at-rule-no-unknown": [
true,
{
ignoreAtRules: ["apply", "use"],
},
],
},
Expand Down
97 changes: 50 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "mall-admin",
"version": "3.2.0",
"private": true,
"version": "3.1.0",
"type": "module",
"scripts": {
"preinstall": "npx only-allow pnpm",
"dev": "vite serve --mode development",
Expand Down Expand Up @@ -40,14 +41,15 @@
]
},
"dependencies": {
"@element-plus/icons-vue": "^2.1.0",
"@vitejs/plugin-vue": "^4.4.0",
"@vueuse/core": "^10.5.0",
"@element-plus/icons-vue": "^2.3.1",
"@vitejs/plugin-vue": "^5.0.4",
"@vueuse/core": "^10.7.2",
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "5.1.10",
"axios": "^1.6.0",
"echarts": "^5.4.3",
"element-plus": "^2.4.2",
"animate.css": "^4.1.1",
"axios": "^1.6.7",
"echarts": "^5.5.0",
"element-plus": "^2.5.6",
"lodash-es": "^4.17.21",
"net": "^1.0.2",
"nprogress": "^0.2.0",
Expand All @@ -56,63 +58,64 @@
"pinia": "^2.1.7",
"screenfull": "^6.0.2",
"sockjs-client": "1.6.1",
"sortablejs": "^1.15.0",
"sortablejs": "^1.15.2",
"stompjs": "^2.3.3",
"terser": "^5.24.0",
"vue": "^3.3.8",
"vue-i18n": "9.2.2",
"terser": "^5.27.2",
"vue": "^3.4.19",
"vue-i18n": "9.9.1",
"vue-router": "^4.2.5",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@commitlint/cli": "^17.8.1",
"@commitlint/config-conventional": "^17.8.1",
"@iconify-json/ep": "^1.1.12",
"@types/lodash": "^4.14.201",
"@commitlint/cli": "^18.6.1",
"@commitlint/config-conventional": "^18.6.2",
"@iconify-json/ep": "^1.1.14",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.19",
"@types/nprogress": "^0.2.3",
"@types/path-browserify": "^1.0.2",
"@types/sockjs-client": "^1.5.4",
"@types/sortablejs": "^1.15.5",
"@types/stompjs": "^2.3.8",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vitejs/plugin-vue-jsx": "^3.0.2",
"autoprefixer": "^10.4.16",
"@types/sortablejs": "^1.15.8",
"@types/stompjs": "^2.3.9",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"autoprefixer": "^10.4.17",
"commitizen": "^4.3.0",
"cz-git": "^1.7.1",
"eslint": "^8.53.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.18.1",
"cz-git": "^1.8.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.21.1",
"fast-glob": "^3.3.2",
"husky": "^8.0.3",
"lint-staged": "^13.3.0",
"postcss": "^8.4.31",
"postcss-html": "^1.5.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"postcss": "^8.4.35",
"postcss-html": "^1.6.0",
"postcss-scss": "^4.0.9",
"prettier": "^2.8.8",
"sass": "^1.69.5",
"stylelint": "^15.11.0",
"prettier": "^3.2.5",
"sass": "^1.71.0",
"stylelint": "^16.2.1",
"stylelint-config-html": "^1.1.0",
"stylelint-config-recess-order": "^4.3.0",
"stylelint-config-recommended-scss": "^13.1.0",
"stylelint-config-recess-order": "^4.6.0",
"stylelint-config-recommended-scss": "^14.0.0",
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-config-standard": "^34.0.0",
"stylelint-config-standard-scss": "^11.1.0",
"typescript": "^5.2.2",
"unocss": "^0.51.13",
"unplugin-auto-import": "^0.15.3",
"unplugin-icons": "^0.16.6",
"unplugin-vue-components": "^0.24.1",
"vite": "^4.5.0",
"stylelint-config-standard": "^36.0.0",
"typescript": "^5.3.3",
"unocss": "^0.58.5",
"unplugin-auto-import": "^0.17.5",
"unplugin-icons": "^0.18.5",
"unplugin-vue-components": "^0.26.0",
"vite": "^5.1.3",
"vite-plugin-mock-dev-server": "^1.4.7",
"vite-plugin-svg-icons": "^2.0.1",
"vue-tsc": "^1.8.22"
"vue-tsc": "^1.8.27"
},
"repository": "https://gitee.com/youlaiorg/mall-admin.git",
"repository": "https://gitee.com/youlaiorg/vue3-element-admin.git",
"author": "有来开源组织",
"license": "MIT",
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
}
}
39 changes: 31 additions & 8 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
<template>
<el-config-provider :locale="locale" :size="size">
<!-- 开启水印 -->
<el-watermark
v-if="watermarkEnabled"
:font="{ color: fontColor }"
:content="defaultSettings.watermarkContent"
class="wh-full"
>
<router-view />
</el-watermark>
<!-- 关闭水印 -->
<router-view v-else />
</el-config-provider>
</template>

<script setup lang="ts">
import { ElConfigProvider } from "element-plus";
import { useAppStore } from "@/store/modules/app";
import { useAppStore, useSettingsStore } from "@/store";
import defaultSettings from "@/settings";
import { ThemeEnum } from "@/enums/ThemeEnum";
const appStore = useAppStore();
</script>
const settingsStore = useSettingsStore();
<template>
<el-config-provider :locale="appStore.locale" :size="appStore.size">
<router-view />
</el-config-provider>
</template>
const locale = computed(() => appStore.locale);
const size = computed(() => appStore.size);
const watermarkEnabled = computed(() => settingsStore.watermarkEnabled);
// 明亮/暗黑主题水印字体颜色适配
const fontColor = computed(() => {
return settingsStore.theme === ThemeEnum.DARK
? "rgba(255, 255, 255, .15)"
: "rgba(0, 0, 0, .15)";
});
</script>
22 changes: 11 additions & 11 deletions src/api/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export function loginApi(data: LoginData): AxiosPromise<LoginResult> {
const formData = new FormData();
formData.append("username", data.username);
formData.append("password", data.password);
formData.append("verifyCodeKey", data.verifyCodeKey || "");
formData.append("verifyCode", data.verifyCode || "");
formData.append("grant_type", "captcha");
formData.append("captchaId", data.captchaId as string);
formData.append("captchaCode", data.captchaCode as string);
formData.append("grant_type", "password");
return request({
url: "/youlai-auth/oauth2/token",
method: "post",
Expand All @@ -27,21 +27,21 @@ export function loginApi(data: LoginData): AxiosPromise<LoginResult> {
}

/**
* 注销API
* 获取验证码
*/
export function logoutApi() {
export function getCaptchaApi(): AxiosPromise<CaptchaResult> {
return request({
url: "/youlai-system/api/v1/users/logout",
method: "delete",
url: "/youlai-auth/api/v1/auth/captcha",
method: "get",
});
}

/**
* 获取验证码
* 注销API
*/
export function getCaptchaApi(): AxiosPromise<CaptchaResult> {
export function logoutApi() {
return request({
url: "/captcha",
method: "get",
url: "/youlai-auth/api/v1/auth/logout",
method: "delete",
});
}
14 changes: 8 additions & 6 deletions src/api/auth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ export interface LoginData {
* 密码
*/
password: string;

/**
* 授权类型
*/
grant_type?: string;
/**
* 验证码Code
*/
verifyCode?: string;
captchaCode?: string;
/**
* 验证码Code服务端缓存key(UUID)
* 验证码唯一标识(UUID)
*/
verifyCodeKey?: string;
captchaId?: string;
}

/**
Expand Down Expand Up @@ -51,9 +53,9 @@ export interface CaptchaResult {
/**
* 验证码缓存key
*/
verifyCodeKey: string;
captchaId: string;
/**
* 验证码图片Base64字符串
*/
captchaImgBase64: string;
captchaBase64: string;
}
File renamed without changes
40 changes: 40 additions & 0 deletions src/components/AppLink/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<template>
<component :is="type" v-bind="linkProps(to)">
<slot></slot>
</component>
</template>

<script setup lang="ts">
defineOptions({
name: "AppLink",
inheritAttrs: false,
});
import { isExternal } from "@/utils/index";
const props = defineProps({
to: {
type: String,
required: true,
},
});
const isExternalLink = computed(() => isExternal(props.to));
const type = computed(() => {
return isExternalLink.value ? "a" : "router-link";
});
const linkProps = (to: string) => {
if (isExternalLink.value) {
return {
href: to,
target: "_blank",
rel: "noopener noreferrer",
};
}
return {
to: to,
};
};
</script>
Loading

0 comments on commit ae67323

Please sign in to comment.