Commit d5d1480b authored by 赵伟庚's avatar 赵伟庚

合并dev至dev0217

parents 2479f9a2 5113c325
......@@ -32,12 +32,12 @@ steps: # 定义流水线执行步骤,这些步骤将顺序执行
- name: build # 项目打包
image: registry.cn-qingdao.aliyuncs.com/wod/devops-node:16.16.0-slim
# 将宿主机中文件夹挂载到容器中,宿主机文件夹中的文件会被容器访问并修改,起到使用缓存的作用,避免每次运行都要重现下载依赖,提高运行速度
# 将宿主机中文件夹挂载到容器中,宿主机文件夹中的文件会被容器访问并修改,起到使用缓存的作用,避免每次运行都要重现下载依赖,提高运行速度
commands:
- yarn
- export NODE_ENV=production
- yarn build
- name: s3-cache-build
image: registry.cn-qingdao.aliyuncs.com/wod/devops-s3-cache:1.0
network_mode: host
......@@ -54,7 +54,7 @@ steps: # 定义流水线执行步骤,这些步骤将顺序执行
- name: docker
image: registry.cn-qingdao.aliyuncs.com/wod/devops-docker:1.0
# 将宿主机的 docker和配置挂载到运行的 docker 容器中,那么在容器中运行 docker 命令时,等同于在宿主机中运行该docker命令
# 将宿主机的 docker和配置挂载到运行的 docker 容器中,那么在容器中运行 docker 命令时,等同于在宿主机中运行该docker命令
volumes:
- name: docker-sock
path: /var/run/docker.sock # 将下载依赖的目录挂载出来,防止重复下载
......@@ -70,7 +70,7 @@ steps: # 定义流水线执行步骤,这些步骤将顺序执行
from_secret: REGISTRY_USER_ALIYUN
registry_password: # 密码
from_secret: REGISTRY_PASSWORD_ALIYUN
- name: deploy-cloud
image: registry.cn-qingdao.aliyuncs.com/wod/devops-kubernetes:1.0
settings:
......@@ -131,8 +131,8 @@ steps:
REGISTRY_PASSWORD:
from_secret: REGISTRY_PASSWORD_ALIYUN
settings:
source: registry.cn-qingdao.aliyuncs.com/wod/apaas-system-ui:5.0.5-alpha
target: registry.cn-qingdao.aliyuncs.com/wod/apaas-system-ui:5.0.5
source: registry.cn-qingdao.aliyuncs.com/wod/apaas-system-ui:5.0.10-alpha
target: registry.cn-qingdao.aliyuncs.com/wod/apaas-system-ui:5.0.10
registry: registry.cn-qingdao.aliyuncs.com
- name: harbor-arm64
......@@ -149,8 +149,8 @@ steps:
REGISTRY_PASSWORD:
from_secret: REGISTRY_PASSWORD_ALIYUN
settings:
source: registry.cn-qingdao.aliyuncs.com/wod/apaas-system-ui:5.0.5-alpha-arm64
target: registry.cn-qingdao.aliyuncs.com/wod/apaas-system-ui:5.0.5-arm64
source: registry.cn-qingdao.aliyuncs.com/wod/apaas-system-ui:5.0.10-alpha-arm64
target: registry.cn-qingdao.aliyuncs.com/wod/apaas-system-ui:5.0.10-arm64
registry: registry.cn-qingdao.aliyuncs.com
##--------------对于需要保密的信息隐藏,减少账户信息的泄密⬇-----------------##
---
......@@ -202,4 +202,4 @@ kind: secret
name: REGISTRY_PASSWORD_ALIYUN
get:
name: PASSWORD
path: devops-registry-aliyun
\ No newline at end of file
path: devops-registry-aliyun
......@@ -19,17 +19,17 @@
<login></login>
</div>
</div>
<div class="container" v-else-if="$route.path=='/registe'">
<div class="container" v-else-if="$route.path == '/registe'">
<div class="bg-main view">
<registe></registe>
</div>
</div>
<div class="container" v-else-if="$route.path=='/password'">
<div class="container" v-else-if="$route.path == '/password'">
<div class="bg-main view">
<password></password>
</div>
</div>
<div class="container" v-else-if="$route.path=='/404'">
<div class="container" v-else-if="$route.path == '/404'">
<div class="bg-main view">
<page404></page404>
</div>
......@@ -40,18 +40,18 @@
</template>
<script>
import bgMenu from '@/components/bg-menu.vue'
import login from '@/page/login/index.vue'
import page404 from '@/page/404.vue'
import registe from '@/page/registe/index.vue'
import password from '@/page/password/index.vue'
import bgMenu from "@/components/bg-menu.vue";
import login from "@/page/login/index.vue";
import page404 from "@/page/404.vue";
import registe from "@/page/registe/index.vue";
import password from "@/page/password/index.vue";
export default {
components: {
bgMenu,
login,
page404,
registe,
password
password,
},
computed: {
msgBoxFlag() {
......@@ -66,11 +66,11 @@ export default {
menuObj() {
return this.$store.state.menuObj;
},
navShow(){
return false||!['/','/404','/login','/registe','/password'].includes(this.$route.path)
navShow() {
return false || !["/", "/404", "/login", "/registe", "/password"].includes(this.$route.path);
},
pageShow(){
return false||!['/404','/login','/registe','/password'].includes(this.$route.path)
pageShow() {
return false || !["/404", "/login", "/registe", "/password"].includes(this.$route.path);
},
rowPath() {
if (this.pageShow && this.$store.state.userInfo) {
......@@ -81,9 +81,6 @@ export default {
},
nowParent() {
if (this.pageShow && this.$store.state.userInfo) {
// console.log(2222222)
// console.log(this.navMenu)
// console.log(this.rowPath)
return this.rowPath ? this.navMenu[this.rowPath.slice(1, 2)] : "";
} else {
return "";
......@@ -154,9 +151,7 @@ export default {
highlightParentRule(pathArr) {
return pathArr.includes(this.$route.path);
},
ada() {
console.log(12312);
},
ada() {},
},
};
</script>
......
......@@ -85,7 +85,6 @@ const codeChange = () => {
onMounted(() => {
let obj = "";
// console.log(typeof JSON.parse(this.datas));
try {
if (typeof JSON.parse(props.modelValue) == "object") {
obj = JSON.stringify(JSON.parse(props.modelValue), null, "\t");
......
......@@ -43,7 +43,6 @@
<script setup>
import { reactive, ref, onBeforeMount, toRefs, watch } from "vue";
import helper from "./utils/index.js";
console.log(helper);
const props = defineProps({
data: {
type: Array,
......@@ -82,7 +81,6 @@ watch(
const down_file = (url) => {
if (url) {
console.log(url);
const a = document.createElement("a"); // 创建a标签
a.setAttribute("download", ""); // download属性
a.setAttribute("href", url); // href链接
......
......@@ -121,6 +121,7 @@ const copyText = (text, e) => {
const copyIcon = (data) => {
navigator.clipboard.writeText(data).then(
ElMessage.success("复制成功"),
function () {},
function () {}
);
......
<template>
<ul class="nav-list" v-if="list && list.length">
<ul class="nav-list bg-no-scroll" v-if="list && list.length">
<li v-for="(item, index) in list" v-show="item.menuType !== 2" :key="'nav_' + index">
<template v-if="item.children && item.children.length && item.menuType == 0">
<div
......
......@@ -65,9 +65,6 @@ const calcTabs = () => {
if (tabSlots) {
tabSlots.forEach((e, idx) => {
if (idx + 2 > props.limit && tabSlots.length > props.limit && e.props) {
// console.log(e);
// console.log(e.props);
state.lastChildren.push(e.props);
}
});
......
......@@ -213,8 +213,6 @@ const updateFileList = (fileList) => {
state.fileList = fileList;
console.log(values);
emit("update:modelValue", values);
emit("change", values);
};
......
......@@ -522,7 +522,7 @@ a {
}
> .bg-nav-list {
height: calc(100% - 135px);
height: calc(100% - 10px);
box-sizing: border-box;
ul.nav-list {
......@@ -644,17 +644,20 @@ a {
&::before {
display: none;
}
.empty_container {
height: 500px;
padding-top: 247px;
img {
width: 257px;
height: 145px;
}
.text {
font-size: 16px;
color: #616f94;
line-height: 1;
.el-table__empty-block {
height: 500px!important;
.empty_container {
height: 500px;
padding-top: 247px;
img {
width: 257px;
height: 145px;
}
.text {
font-size: 16px;
color: #616f94;
line-height: 1;
}
}
}
th,
......
......@@ -12,12 +12,14 @@
v-model="props.item.checked"
@change="change_check"></el-checkbox>
<div class="logo">
<img v-if="props.item.ability_logo" :src="props.item.ability_logo" alt="" />
<img v-if="props.item.ability_logo" :src="JSON.parse(props.item.ability_logo)[0].url" alt="" />
<img v-else src="../assets/imgs/img_cover_ability.png" alt="" />
</div>
<div class="info">
<div class="name">
<span class="ability_name">{{ props.item.ability_name }}</span>
<el-tooltip class="box-item" effect="light" :content="props.item.ability_name" placement="top">
<span class="ability_name">{{ props.item.ability_name }}</span>
</el-tooltip>
<span class="icon_box openness" :class="openClassObj[props.item.openness_id]">{{ props.item.openness }}</span>
<span class="icon_box mock" v-if="props.item.include_mock_service">mock</span>
</div>
......
......@@ -234,7 +234,6 @@ export default {
},
created() {
console.log(this.userInfo);
this.getLogo()
if (this.userInfo) {
// this.getUserDetail(this.userInfo.user_id)
......@@ -243,7 +242,6 @@ export default {
}
},
mounted() {
console.log(this.currentMenuIndex);
this.$nextTick(this.scrollAction);
window.addEventListener("scroll", this.scrollAction, true);
......
......@@ -85,7 +85,6 @@ Promise.all([getUser(), getMenu("dadb2d3f-e263-48d1-9389-42acb9ea49f8")])
// if (res[0].data.data.userType == 1) {//超管
store.commit("setMenu", data);
console.log("data", data);
menu.menuToRouter(data);
store.commit("setRoute", data);
......
......@@ -68,7 +68,6 @@ const transitionOptions = (_options, options) => {
}
const install = (Vue, options = {}) => {
console.log("执行以下")
init(options);
if (Vue.prototype) {
Vue.prototype.$trace = { ...methods,option };
......
......@@ -86,7 +86,6 @@ import detailTable2 from "./detail-table2.vue";
import MarkdownIt from "markdown-it";
import axios from "axios";
import { h } from 'vue'
console.log(h);
var md = new MarkdownIt();
export default {
// model: {
......@@ -152,7 +151,6 @@ export default {
},
watch: {
modelValue(n,o){
console.log(n)
if(n==true){
this.getUnreadNum();
this.changeRead(0)
......@@ -226,8 +224,6 @@ export default {
getDetail(id) {
this.dialogVisible = true;
//刷新未读数量
console.log(id);
axios
.get(`${this.$trace.option.requestUrl}/msg/api/my/msg/detail`, {
params: {
......
......@@ -28,6 +28,10 @@
<bg-filter-group @search="changeSearch" v-model="filter.search" placeholder="请输入关键字">
<template v-slot:left_action v-if="nodeClassifyId != '263758a4-0349-4d49-a816-e8ff8d33a8bb'">
<div class="apaas_button">
<el-button class="register_btn" type="primary" @click="backDict" v-if="dictLevel != 1">
<!-- <bg-icon style="font-size: 12px; color: #fff; margin-right: 8px" icon="#bg-ic-add"></bg-icon> -->
返回上级
</el-button>
<el-button class="register_btn" type="primary" @click="register">
<bg-icon style="font-size: 12px; color: #fff; margin-right: 8px" icon="#bg-ic-add"></bg-icon>
新增
......@@ -56,7 +60,15 @@
</bg-filter-group>
<div class="table_container">
<div class="table bg-scroll">
<bg-table ref="bgTable" :headers="headers" :rows="tableRows" :isIndex="true" :stripe="true">
<bg-table ref="bgTable" :headers="isLang && dictLevel == 1 ? langHeaders : headers" :rows="tableRows" :isIndex="true" :stripe="true">
<template v-slot:name="{ row }">
<span class="can_click_text" @click="getChildren(row)" v-if="isLang && dictLevel == 1">
{{ row.name }}
</span>
<span v-else>
{{ row.name }}
</span>
</template>
<template v-slot:updated_time="{ row }">
{{ row.updated_time.split("+")[0].replace("T", " ").replace("Z", " ") }}
</template>
......@@ -204,6 +216,36 @@ const state = reactive({
fixed: "right",
},
], // 表格数据表头
langHeaders: [
{
label: "名称",
prop: "name",
},
{
label: "版本数",
prop: "total_children",
},
{
label: "描述",
prop: "describe",
minWidth: 360,
},
{
label: "更新时间",
prop: "updated_time",
width: 220,
},
{
label: "是否启用",
prop: "state",
},
{
label: "操作",
prop: "action",
width: 176,
fixed: "right",
},
],
tableRows: [], // 表格数据
tableTotal: 0, // 表格数据条数
filter: {
......@@ -234,6 +276,7 @@ const state = reactive({
name: "",
describe: "",
state: 1,
p_dict_id: "",
},
rules: {
name: [{ required: true, message: "请输入名称", trigger: "blur" }],
......@@ -243,10 +286,30 @@ const state = reactive({
],
state: [{ required: true, message: "请选择是否启用", trigger: "change" }],
},
fatherRow: null,
});
const isLang = computed(() => {
return state.nodeClassifyId == "59315100-5c2a-4381-83fe-32934605f0a9"
})
const dictLevel = ref(1)
const getChildren = (row) => {
dictLevel.value = 2
state.tableRows = row.children || []
state.tableTotal = row.total_children
state.fatherRow = row
}
const backDict = () => {
dictLevel.value = 1
state.fatherRow = null
changePage(1);
}
const nodeClick = (item) => {
state.nodeId = item.id;
dictLevel.value = 1
state.fatherRow = null
state.nodeClassifyId = item.classify_id;
state.filter = {
state: "",
......@@ -317,8 +380,15 @@ const getTableRows = () => {
})
.then((res) => {
if (res.data.code == 200) {
state.tableRows = res.data.data || [];
state.tableTotal = res.data.total;
let data = res.data.data || []
if (dictLevel.value == 1) {
state.tableRows = data;
state.tableTotal = res.data.total;
}else {
let row = data.filter(e => {return e.dict_id == state.fatherRow.dict_id})
state.tableRows = row[0].children
state.tableTotal = row[0].total_children
}
if (state.tableRows.length > 0) {
state.tableRows.forEach((e) => {
e.canMoveUp = true;
......@@ -360,6 +430,7 @@ const register = () => {
name: "",
describe: "",
state: 1,
p_dict_id: state.fatherRow ? state.fatherRow.dict_id : "",
};
if (state.bgForm) {
nextTick().then(() => {
......@@ -384,6 +455,7 @@ const edit_row = (row) => {
name: state.actionRow.name,
describe: state.actionRow.describe,
state: state.actionRow.state,
p_dict_id: state.actionRow.p_dict_id
};
} else {
ElMessage.error(res.data.data);
......@@ -518,6 +590,7 @@ const {
addDialog,
formData,
rules,
langHeaders,
} = toRefs(state);
</script>
......
<template>
<el-form :model="formData" :rules="formRules" ref="form" style="max-width: 1048px" class="form">
<el-form-item label="banner名称" prop="banner_name">
<el-input v-model.trim="formData.banner_name" />
<el-input v-model.trim="formData.banner_name" show-word-limit maxlength="30" />
</el-form-item>
<el-form-item label="链接地址(选填)" prop="link_address">
<el-input v-model.trim="formData.link_address" />
......@@ -11,9 +11,10 @@
v-model="formData.banner_image"
:fileSize="1"
:showTips="true"
customTips="请选择图片上传:大小1920 * 464像素支持jpg、png等格式,图片需小于1MB"
customTips="请选择图片上传:大小1920 * 464像素支持jpg、jpeg、png格式,图片需小于1MB"
:limit="1"
listType="picture-card"
@change="changeLogo"
:accept="['.jpg', '.jpeg', '.png']"></bg-upload-image>
</el-form-item>
<el-form-item label="是否启用" prop="state" class="state_form_item">
......@@ -39,11 +40,18 @@ const state = reactive({
},
formRules: {
banner_name: [{ required: true, message: "请输入banner名称", trigger: "blur" }],
link_address: [{ max: 8182, message: "最长可输入8182个字符", trigger: "blur" }],
banner_image: [{ required: true, message: "请上传banner图", trigger: "change" }],
state: [{ required: true, message: "请选择启用状态", trigger: "change" }],
},
});
const changeLogo = (value) => {
if (value && value.length > 0) {
form.value.clearValidate("banner_image");
}
};
const emit = defineEmits(["action"]);
const submitForm = async () => {
......
......@@ -17,7 +17,7 @@
:fileSize="500"
:fileSizeUnit="'KB'"
:showTips="true"
customTips="请选择图片上传:大小80 * 80像素支持jpg、png等格式,图片需小于500KB"
customTips="请选择图片上传:大小80 * 80像素支持jpg、jpeg、png格式,图片需小于500KB"
:limit="1"
listType="picture-card"
:accept="['.jpg', '.jpeg', '.png']"></bg-upload-image>
......
......@@ -76,7 +76,7 @@
</el-cascader>
<el-input
v-model.trim="dialogFilter.keyword"
placeholder="请输入内容"
placeholder="请输入能力/开发商名称"
style="width: 240px"
:prefix-icon="Search" />
<el-button type="primary" @click="searchAction">查询</el-button>
......@@ -299,6 +299,7 @@ const move = (temp) => {
}
}
});
state.selectArrNew = state.selectArr.filter((e) => e )
};
const changePage = (val) => {
state.dialogFilter.page = 1;
......
......@@ -6,7 +6,7 @@
placeholder="请选择能力类型"
style="width: 100%"
@change="changeType"
:disabled="route.query.id">
:disabled="!!route.query.id">
<el-option v-for="item in props.businessList" :key="item.dict_id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
......@@ -16,9 +16,10 @@
:fileSize="500"
:fileSizeUnit="'KB'"
:showTips="true"
customTips="请选择图片上传:大小36 * 36像素支持jpg、png等格式,图片需小于500KB"
customTips="请选择图片上传:大小36 * 36像素支持jpg、jpeg、png格式,图片需小于500KB"
:limit="1"
listType="picture-card"
@change="changeLogo"
:accept="['.jpg', '.jpeg', '.png']"></bg-upload-image>
</el-form-item>
</el-form>
......@@ -51,6 +52,12 @@ const state = reactive({
const emit = defineEmits(["action", "changeType"]);
const changeLogo = (value) => {
if (value && value.length > 0) {
form.value.clearValidate("logo")
}
}
const submitForm = async () => {
if (!form) return;
await form.value.validate((valid, fields) => {
......
......@@ -886,7 +886,7 @@ onBeforeMount(() => {});
padding: 16px;
}
.tree {
overflow: auto;
overflow: hidden auto;
height: calc(100% - 65px);
/* padding: 5px; */
}
......
......@@ -166,7 +166,6 @@ const getDetail = () => {
};
const getSystemInfo = () => {
console.log(11111111);
const params = { ...filter, organization_id: route.query.id };
axios.get(`/apaas/system/v5/org/business/msg`, { params }).then((res) => {
if (res.data.code == 200) {
......
......@@ -92,20 +92,25 @@ const validatePass = (rule, value, callback) => {
};
const validateSystemAccount = (rule, value, callback) => {
let params = null;
if (props.id) {
params = { id: parseInt(props.id), system_account: value };
let reg = /^[a-zA-Z0-9]+$/;
if (!reg.test(value)) {
callback(new Error("只能输入字母和数字"));
} else {
params = { system_account: value };
}
axios.post(`/apaas/system/v5/user/check/account`, params).then((res) => {
if (res.data.code == 200) {
callback();
let params = null;
if (props.id) {
params = { id: parseInt(props.id), system_account: value };
} else {
callback(new Error(res.data.data));
params = { system_account: value };
}
});
axios.post(`/apaas/system/v5/user/check/account`, params).then((res) => {
if (res.data.code == 200) {
callback();
} else {
callback(new Error(res.data.data));
}
});
}
};
const checkPhone = (rule, value, callback) => {
......@@ -141,6 +146,8 @@ const orgAccountFormRules = reactive({
select_role: [{ required: true, message: "请选择角色", trigger: "blur" }],
system_account: [
{ required: true, message: "请输入账号", trigger: "blur" },
{ min: 4, message: "帐号长度不得低于4个字符", trigger: "blur" },
{ max: 20, message: "帐号最大长度为20个字符", trigger: "blur" },
{ validator: validateSystemAccount, trigger: "blur" },
],
contact_phone: [
......
......@@ -95,20 +95,25 @@ const checkPhone = (rule, value, callback) => {
};
const validateSystemAccount = (rule, value, callback) => {
let params = null;
if (props.id) {
params = { id: parseInt(props.id), system_account: value };
let reg = /^[a-zA-Z0-9]+$/;
if (!reg.test(value)) {
callback(new Error("只能输入字母和数字"));
} else {
params = { system_account: value };
}
axios.post(`/apaas/system/v5/user/check/account`, params).then((res) => {
if (res.data.code == 200) {
callback();
let params = null;
if (props.id) {
params = { id: parseInt(props.id), system_account: value };
} else {
callback(new Error(res.data.data));
params = { system_account: value };
}
});
axios.post(`/apaas/system/v5/user/check/account`, params).then((res) => {
if (res.data.code == 200) {
callback();
} else {
callback(new Error(res.data.data));
}
});
}
};
const checkPhoneRepet = (rule, value, callback) => {
......@@ -131,6 +136,8 @@ const checkPhoneRepet = (rule, value, callback) => {
const platformAccountFormRules = reactive({
system_account: [
{ required: true, message: "请输入账号", trigger: "blur" },
{ min: 4, message: "帐号长度不得低于4个字符", trigger: "blur" },
{ max: 20, message: "帐号最大长度为20个字符", trigger: "blur" },
{ validator: validateSystemAccount, trigger: "blur" },
],
contact_phone: [
......
......@@ -23,7 +23,6 @@
<span
v-else
class="tree-action-box"
:class="{ position_sticky: isSticky(data.name) }"
@click.stop="showAction($event, data, node)">
<bg-icon class="tree-more" icon="#bg-ic-s-more"></bg-icon>
</span>
......@@ -248,7 +247,6 @@ const showAction = (e, data, node) => {
height = parseInt(height);
//判断弹窗位置是否超过屏幕,超过则吸底展示
if (height + rect.y - 17 > allHeight - bottomGap.value) {
console.log(123);
acBottom.value = bottomGap.value + "px";
acLeft.value = rect.x + 35 + "px";
} else {
......@@ -370,7 +368,9 @@ defineExpose({ getOrgTree, filterTree, setCurrentNode });
.file-tree :deep() .el-tree-node__content:hover .tree-action-box {
display: inline-block;
}
.file-tree :deep() .el-tree-node__content:hover + .label-text {
width: calc(100% - 48px);
}
.file-tree :deep() .el-tree-node__content .first_node {
display: inline-block;
background-color: #fff;
......@@ -396,6 +396,11 @@ defineExpose({ getOrgTree, filterTree, setCurrentNode });
.label-text {
font-size: 14px;
color: #404a62;
display: inline-block;
width: calc(100% - 24px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tree-action-box:hover + .label-text {
padding: 8px 0;
......@@ -404,7 +409,8 @@ defineExpose({ getOrgTree, filterTree, setCurrentNode });
.label-text:hover {
padding: 8px 0;
background-color: var(--el-tree-node-hover-bg-color);
/* background-color: var(--el-tree-node-hover-bg-color); */
width: calc(100% - 48px);
}
.is_active {
padding: 8px 0;
......
......@@ -342,12 +342,10 @@ const clearRoleSelection = () => {
};
const register = () => {
console.log("新增角色");
router.push("/system/role/add");
}; // 新增角色
const edit_row = (row) => {
console.log(row, "编辑角色");
router.push({
path: "/system/role/edit",
query: {
......@@ -365,7 +363,6 @@ const distribute_user = (row) => {
const getUserList = () => {
nextTick(() => {
console.log(userTable);
clearUserSelection();
});
let params = {
......
//路由前端原则可以不写,但是需要在recorder中记录,防止以后忘记
//不用新增父路由的文件,父路由全部由parent/parent.vue来支撑
import {
createRouter,
createWebHashHistory
} from "vue-router";
import store from '../store'
import { createRouter, createWebHashHistory } from "vue-router";
import store from "../store";
//写入初始必须有的路由
//或者隐藏式路由,不会表现在菜单上,但是需要存在的路由
const routes = [{
path: '/login',
name: 'login',
const routes = [
{
path: "/login",
name: "login",
show: true,
component: () => import('../page/login/index.vue')
component: () => import("../page/login/index.vue"),
},
{
path: '/registe',
name: 'registe',
path: "/registe",
name: "registe",
show: true,
component: () => import('../page/registe/index.vue')
component: () => import("../page/registe/index.vue"),
},
{
path: '/password',
name: 'password',
path: "/password",
name: "password",
show: true,
component: () => import('../page/password/index.vue')
component: () => import("../page/password/index.vue"),
},
{
path: '/',
name: 'index',
component: () => import('../page/welcom.vue'),
path: "/",
name: "index",
component: () => import("../page/welcom.vue"),
},
{
path: '/404',
path: "/404",
show: true,
component: () => import('../page/404.vue')
component: () => import("../page/404.vue"),
},
];
......@@ -51,7 +48,7 @@ const router = newRouterFunc();
function inWhiteList(toPath) {
//配置白名单
const whiteList = ['/login', '/registe', '/password']
const whiteList = ["/login", "/registe", "/password"];
const path = whiteList.find((value) => {
// 使用正则匹配
const reg = new RegExp("^" + value);
......@@ -62,16 +59,14 @@ function inWhiteList(toPath) {
router.beforeEach((to, from, next) => {
const userInfo = store.state.userInfo;
console.log(store.state.route);
//已登录不可跳转登陆页
if (userInfo && (to.path == '/login' || to.path == '/')) {
if (userInfo && (to.path == "/login" || to.path == "/")) {
next({
path: '/develop/account'
})
path: "/develop/account",
});
}
// 检查to.path是否存在于免登陆白名单
if (inWhiteList(to.path)) {
next();
......@@ -83,7 +78,8 @@ router.beforeEach((to, from, next) => {
next({
path: "/login",
});
} else {}
} else {
}
}
//判读是否匹配,否则跳转404
......@@ -91,8 +87,8 @@ router.beforeEach((to, from, next) => {
next();
} else {
return next({
path: '/404'
})
path: "/404",
});
}
});
......@@ -102,11 +98,11 @@ router.beforeEach((to, from, next) => {
// generateRoutes()
// })
function addRoute(router, routers) {
routers.forEach(e => {
if (e.path[0] == '/') {
router.addRoute(e)
routers.forEach((e) => {
if (e.path[0] == "/") {
router.addRoute(e);
if (e.children && e.children.length) {
addRoute(router, e.children)
addRoute(router, e.children);
}
}
});
......@@ -118,15 +114,13 @@ export function generateRoutes() {
if (_asyncRoutes) {
//动态添加路由
addRoute(router, _asyncRoutes)
addRoute(router, _asyncRoutes);
}
router.addRoute({
path: '/:pathMatch(.*)',
redirect: '/404'
})
console.log(router.getRoutes());
path: "/:pathMatch(.*)",
redirect: "/404",
});
}
//新创建一个router替代之前的router,并把matcher方法替换成新的router的matcher
......@@ -135,4 +129,4 @@ export function resetRouter() {
router.matcher = newRouter.matcher;
}
export default router
export default router;
......@@ -2,7 +2,6 @@ import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
const path = require("path");
console.log(__dirname);
function resolve_path(dir) {
return path.join(__dirname, "./", dir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment