mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2025-12-15 07:27:54 +00:00
解决兼容警告问题
This commit is contained in:
parent
6df3f8e086
commit
eef160a6ba
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "front-next",
|
||||
"version": "5.7.7",
|
||||
"version": "5.7.8",
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
"build": "vite build",
|
||||
@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"@codemirror/lang-javascript": "^6.0.1",
|
||||
"@codemirror/theme-one-dark": "^6.0.0",
|
||||
"@cool-vue/crud": "^5.3.2",
|
||||
"@cool-vue/crud": "^5.3.5",
|
||||
"@element-plus/icons-vue": "^2.0.6",
|
||||
"@vueuse/core": "^8.9.4",
|
||||
"axios": "^0.27.2",
|
||||
|
||||
@ -48,9 +48,7 @@ router.href = function (path) {
|
||||
router.append = function (data) {
|
||||
const list = isArray(data) ? data : [data];
|
||||
|
||||
list.forEach((e) => {
|
||||
const d = { ...e };
|
||||
|
||||
list.forEach((d) => {
|
||||
if (!d.name) {
|
||||
d.name = d.path.substring(1);
|
||||
}
|
||||
@ -73,7 +71,7 @@ router.append = function (data) {
|
||||
}
|
||||
}
|
||||
|
||||
if (e.isPage) {
|
||||
if (d.isPage) {
|
||||
router.addRoute(d);
|
||||
} else {
|
||||
router.addRoute("index", d);
|
||||
@ -81,6 +79,11 @@ router.append = function (data) {
|
||||
});
|
||||
};
|
||||
|
||||
// 找路由
|
||||
router.find = function (path: string) {
|
||||
return router.getRoutes().find((e) => e.path == path);
|
||||
};
|
||||
|
||||
let lock = false;
|
||||
|
||||
// 错误监听
|
||||
@ -100,9 +103,9 @@ router.onError((err: any) => {
|
||||
// 注册
|
||||
async function register(path: string) {
|
||||
// 当前路由是否存在
|
||||
const d = router.getRoutes().find((e) => e.path == path);
|
||||
const f = Boolean(router.find(path));
|
||||
|
||||
if (!d) {
|
||||
if (!f) {
|
||||
const { menu } = useBase();
|
||||
|
||||
// 等待加载
|
||||
@ -143,46 +146,49 @@ async function register(path: string) {
|
||||
if (r) {
|
||||
router.append(r);
|
||||
}
|
||||
|
||||
return r?.path || "/404";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { route: router.find(path), isReg: !f };
|
||||
}
|
||||
|
||||
// 路由守卫
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
// 注册路由
|
||||
const path = await register(to.path);
|
||||
// 数据缓存
|
||||
const { user, process } = useBase();
|
||||
|
||||
if (path) {
|
||||
// 重定向
|
||||
next({ ...to, path });
|
||||
// 预先注册路由
|
||||
const { isReg, route } = await register(to.path);
|
||||
|
||||
// 组件不存在、路由不存在
|
||||
if (!route?.components) {
|
||||
next(user.token ? "/404" : "/login");
|
||||
} else {
|
||||
// 数据缓存
|
||||
const { user, process } = useBase();
|
||||
|
||||
// 登录成功
|
||||
if (user.token) {
|
||||
// 在登录页
|
||||
if (to.path.includes("/login")) {
|
||||
// Token 未过期
|
||||
if (!storage.isExpired("token")) {
|
||||
// 回到首页
|
||||
return next("/");
|
||||
// 注册后重定向
|
||||
if (isReg) {
|
||||
next({ ...to, path: route.path });
|
||||
} else {
|
||||
// 登录成功
|
||||
if (user.token) {
|
||||
// 在登录页
|
||||
if (to.path.includes("/login")) {
|
||||
// Token 未过期
|
||||
if (!storage.isExpired("token")) {
|
||||
// 回到首页
|
||||
return next("/");
|
||||
}
|
||||
} else {
|
||||
// 添加路由进程
|
||||
process.add(to);
|
||||
}
|
||||
} else {
|
||||
// 添加路由进程
|
||||
process.add(to);
|
||||
// 忽略部分 Token 验证
|
||||
if (!config.ignore.token.find((e) => to.path == e)) {
|
||||
return next("/login");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 忽略部分 Token 验证
|
||||
if (!config.ignore.token.find((e) => to.path == e)) {
|
||||
return next("/login");
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
next();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -124,6 +124,8 @@ request.interceptors.response.use(
|
||||
const { status, config } = error.response;
|
||||
const { user } = useBase();
|
||||
|
||||
console.log(config);
|
||||
|
||||
if (status == 401) {
|
||||
user.logout();
|
||||
}
|
||||
|
||||
1
src/cool/types/index.d.ts
vendored
1
src/cool/types/index.d.ts
vendored
@ -28,6 +28,7 @@ export declare interface Module extends ModuleConfig {
|
||||
|
||||
export declare interface Router extends VueRouter {
|
||||
href(path: string): void;
|
||||
find(path: string): RouteRecordRaw | undefined;
|
||||
append(data: any[] | any): void;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ export const Loading = {
|
||||
this.resolve();
|
||||
},
|
||||
|
||||
wait() {
|
||||
async wait() {
|
||||
return this.next;
|
||||
},
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ export default defineComponent({
|
||||
props: {
|
||||
modelValue: [String, Number],
|
||||
options: {
|
||||
type: Array,
|
||||
type: [Array, Object],
|
||||
default: () => []
|
||||
},
|
||||
prop: String
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
v-model="form.username"
|
||||
placeholder="请输入用户名"
|
||||
maxlength="20"
|
||||
auto-complete="off"
|
||||
autocomplete="on"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
type="password"
|
||||
placeholder="请输入密码"
|
||||
maxlength="20"
|
||||
auto-complete="off"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
v-model="form.verifyCode"
|
||||
placeholder="图片验证码"
|
||||
maxlength="4"
|
||||
auto-complete="off"
|
||||
@keyup.enter="toLogin"
|
||||
/>
|
||||
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { useCool } from "/@/cool";
|
||||
import { service } from "/@/cool";
|
||||
|
||||
export const useMessageStore = defineStore("chat-message", () => {
|
||||
const { service } = useCool();
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false);
|
||||
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { ref } from "vue";
|
||||
import { useCool } from "/@/cool";
|
||||
import { service } from "/@/cool";
|
||||
|
||||
export const useSessionStore = defineStore("chat-session", () => {
|
||||
const { service } = useCool();
|
||||
|
||||
// 加载状态
|
||||
const loading = ref(false);
|
||||
|
||||
|
||||
@ -31,7 +31,6 @@ const chartOption = reactive({
|
||||
radius: ["50%", "60%"],
|
||||
center: ["50%", "40%"],
|
||||
avoidLabelOverlap: false,
|
||||
hoverAnimation: false,
|
||||
label: {
|
||||
show: false,
|
||||
position: "center"
|
||||
@ -54,10 +53,8 @@ const chartOption = reactive({
|
||||
{ value: 500, name: "手表" }
|
||||
],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
borderColor: "#fff",
|
||||
borderWidth: 4
|
||||
}
|
||||
borderColor: "#fff",
|
||||
borderWidth: 4
|
||||
},
|
||||
roundCap: 1
|
||||
}
|
||||
|
||||
@ -55,9 +55,7 @@ const chartOption = reactive({
|
||||
type: "bar",
|
||||
data: [81, 24, 77, 13, 87, 92, 68, 55],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#4165d7"
|
||||
}
|
||||
color: "#4165d7"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -67,9 +65,7 @@ const chartOption = reactive({
|
||||
barGap: "-100%",
|
||||
data: [100, 100, 100, 100, 100, 100, 100, 100],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#f1f1f9"
|
||||
}
|
||||
color: "#f1f1f9"
|
||||
},
|
||||
zlevel: -1
|
||||
}
|
||||
|
||||
@ -85,35 +85,29 @@ const chartOption = reactive({
|
||||
"1322"
|
||||
],
|
||||
areaStyle: {
|
||||
normal: {
|
||||
color: new echarts.graphic.LinearGradient(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
[
|
||||
{
|
||||
offset: 0,
|
||||
color: "#D1E5FF"
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: "#FFFFFF"
|
||||
}
|
||||
],
|
||||
false
|
||||
)
|
||||
}
|
||||
color: new echarts.graphic.LinearGradient(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
[
|
||||
{
|
||||
offset: 0,
|
||||
color: "#D1E5FF"
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: "#FFFFFF"
|
||||
}
|
||||
],
|
||||
false
|
||||
)
|
||||
},
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#4165d7"
|
||||
}
|
||||
color: "#4165d7"
|
||||
},
|
||||
lineStyle: {
|
||||
normal: {
|
||||
width: 2
|
||||
}
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -151,35 +151,29 @@ const chartOption = reactive({
|
||||
"1322"
|
||||
],
|
||||
areaStyle: {
|
||||
normal: {
|
||||
color: new echarts.graphic.LinearGradient(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
[
|
||||
{
|
||||
offset: 0,
|
||||
color: "#D1E5FF"
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: "#FFFFFF"
|
||||
}
|
||||
],
|
||||
false
|
||||
)
|
||||
}
|
||||
color: new echarts.graphic.LinearGradient(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
[
|
||||
{
|
||||
offset: 0,
|
||||
color: "#D1E5FF"
|
||||
},
|
||||
{
|
||||
offset: 1,
|
||||
color: "#FFFFFF"
|
||||
}
|
||||
],
|
||||
false
|
||||
)
|
||||
},
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#4165d7"
|
||||
}
|
||||
color: "#4165d7"
|
||||
},
|
||||
lineStyle: {
|
||||
normal: {
|
||||
width: 2
|
||||
}
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -76,9 +76,7 @@ const chartOption = reactive<any>({
|
||||
type: "bar",
|
||||
data: [],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#4165d7"
|
||||
}
|
||||
color: "#4165d7"
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -88,9 +86,7 @@ const chartOption = reactive<any>({
|
||||
barGap: "-100%",
|
||||
data: [],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: "#f1f1f9"
|
||||
}
|
||||
color: "#f1f1f9"
|
||||
},
|
||||
zlevel: -1
|
||||
}
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
import { defineStore } from "pinia";
|
||||
import { computed, reactive } from "vue";
|
||||
import { isDev, useCool } from "/@/cool";
|
||||
import { isDev, service } from "/@/cool";
|
||||
|
||||
declare interface Data {
|
||||
[key: string]: Array<{ label: string; value: any }>;
|
||||
}
|
||||
|
||||
export const useDictStore = defineStore("dict", () => {
|
||||
const { service } = useCool();
|
||||
|
||||
// 对象数据
|
||||
const data = reactive<Data>({});
|
||||
|
||||
|
||||
@ -166,11 +166,11 @@ const Table = useTable({
|
||||
"order-desc"
|
||||
],
|
||||
columns: [
|
||||
{ label: "名称", prop: "name", align: "left" },
|
||||
{ label: "名称", prop: "name", align: "left", minWidth: 200 },
|
||||
{ label: "排序", prop: "orderNum", sortable: "custom", width: 100 },
|
||||
{ label: "备注", prop: "remark", showOverflowTooltip: true },
|
||||
{ label: "创建时间", prop: "createTime", sortable: "custom" },
|
||||
{ label: "更新时间", prop: "updateTime", sortable: "custom" },
|
||||
{ label: "备注", prop: "remark", showOverflowTooltip: true, minWidth: 150 },
|
||||
{ label: "创建时间", prop: "createTime", sortable: "custom", minWidth: 160 },
|
||||
{ label: "更新时间", prop: "updateTime", sortable: "custom", minWidth: 160 },
|
||||
{
|
||||
type: "op",
|
||||
width: 250,
|
||||
|
||||
@ -171,7 +171,11 @@ const props = defineProps({
|
||||
default: true
|
||||
},
|
||||
drag: Boolean,
|
||||
disabled: Boolean
|
||||
disabled: Boolean,
|
||||
|
||||
// 穿透值
|
||||
isEdit: null,
|
||||
scope: null
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "upload", "success", "error", "progress"]);
|
||||
|
||||
35
yarn.lock
35
yarn.lock
@ -1052,17 +1052,17 @@
|
||||
style-mod "^4.0.0"
|
||||
w3c-keyname "^2.2.4"
|
||||
|
||||
"@cool-vue/crud@^5.3.2":
|
||||
version "5.3.2"
|
||||
resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-5.3.2.tgz#61b01eb012688a0539e5939958cd9fb2bf60513a"
|
||||
integrity sha512-tHmF6OGjGvoOCPTSzgFKv6x3UvFLDKq5NIneHx1jeoJwPE422lWHd/CeBr/tLq7pvFrRMsKWhlvD6moyfZDiQA==
|
||||
"@cool-vue/crud@^5.3.5":
|
||||
version "5.3.5"
|
||||
resolved "https://registry.npmjs.org/@cool-vue/crud/-/crud-5.3.5.tgz#350d7b307ce1d0445b78f179ec2d0f16eb91b99c"
|
||||
integrity sha512-xWwxv2zQCYGt4GqHg1vDEsiv2sGhJCKYKjxDW6hTo5O/oNuzm8uVcWGVGKyYn5y8//F8wcmod4Kk1L/OvdvS5w==
|
||||
dependencies:
|
||||
array.prototype.flat "^1.2.4"
|
||||
core-js "^3.21.1"
|
||||
element-plus "^2.2.11"
|
||||
element-plus "^2.2.12"
|
||||
merge "^2.1.1"
|
||||
mitt "^3.0.0"
|
||||
vue "^3.2.31"
|
||||
vue "^3.2.37"
|
||||
|
||||
"@ctrl/tinycolor@^3.4.1":
|
||||
version "3.4.1"
|
||||
@ -2467,6 +2467,27 @@ element-plus@^2.2.11:
|
||||
memoize-one "^6.0.0"
|
||||
normalize-wheel-es "^1.2.0"
|
||||
|
||||
element-plus@^2.2.12:
|
||||
version "2.2.12"
|
||||
resolved "https://registry.npmjs.org/element-plus/-/element-plus-2.2.12.tgz#b6c4e298e02ba9b904d70daa54def27b2de8c43c"
|
||||
integrity sha512-g/hIHj3b+dND2R3YRvyvCJtJhQvR7lWvXqhJaoxaQmajjNWedoe4rttxG26fOSv9YCC2wN4iFDcJHs70YFNgrA==
|
||||
dependencies:
|
||||
"@ctrl/tinycolor" "^3.4.1"
|
||||
"@element-plus/icons-vue" "^2.0.6"
|
||||
"@floating-ui/dom" "^0.5.4"
|
||||
"@popperjs/core" "npm:@sxzz/popperjs-es@^2.11.7"
|
||||
"@types/lodash" "^4.14.182"
|
||||
"@types/lodash-es" "^4.17.6"
|
||||
"@vueuse/core" "^8.7.5"
|
||||
async-validator "^4.2.5"
|
||||
dayjs "^1.11.3"
|
||||
escape-html "^1.0.3"
|
||||
lodash "^4.17.21"
|
||||
lodash-es "^4.17.21"
|
||||
lodash-unified "^1.0.2"
|
||||
memoize-one "^6.0.0"
|
||||
normalize-wheel-es "^1.2.0"
|
||||
|
||||
emojis-list@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78"
|
||||
@ -4718,7 +4739,7 @@ vue-router@^4.1.2:
|
||||
dependencies:
|
||||
"@vue/devtools-api" "^6.1.4"
|
||||
|
||||
vue@^3.2.31, vue@^3.2.37:
|
||||
vue@^3.2.37:
|
||||
version "3.2.37"
|
||||
resolved "https://registry.npmjs.org/vue/-/vue-3.2.37.tgz#da220ccb618d78579d25b06c7c21498ca4e5452e"
|
||||
integrity sha512-bOKEZxrm8Eh+fveCqS1/NkG/n6aMidsI6hahas7pa0w/l7jkbssJVsRhVDs07IdDq7h9KHswZOgItnwJAgtVtQ==
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user