优化
This commit is contained in:
@@ -10,7 +10,7 @@ module.exports = {
|
|||||||
mediaQuery: true,
|
mediaQuery: true,
|
||||||
propList: ['*'],
|
propList: ['*'],
|
||||||
rootValue: 16,
|
rootValue: 16,
|
||||||
unitPrecision: 3,
|
unitPrecision: 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -142,6 +142,11 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.el-input {
|
.el-input {
|
||||||
|
&.is-disabled .el-input__inner {
|
||||||
|
background-color: #FFF;
|
||||||
|
color: #888;
|
||||||
|
}
|
||||||
|
|
||||||
input::-webkit-inner-spin-button,
|
input::-webkit-inner-spin-button,
|
||||||
input::-webkit-outer-spin-button {
|
input::-webkit-outer-spin-button {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
|
@@ -10,11 +10,7 @@ class Utils {
|
|||||||
* @param {string} [value] 新的标题
|
* @param {string} [value] 新的标题
|
||||||
*/
|
*/
|
||||||
changeTitle(value) {
|
changeTitle(value) {
|
||||||
if (value) {
|
document.title = (value ? (value + ' - ') : '') + config.siteName;
|
||||||
document.title = config.siteName + ' - ' + value;
|
|
||||||
} else {
|
|
||||||
document.title = config.siteName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tool-elem">
|
<div class="tool-page">
|
||||||
|
|
||||||
<div class="ctrl">
|
<div class="ctrl">
|
||||||
<div class="title">控制</div>
|
<div class="title">控制</div>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tool-elem">
|
<div class="tool-page">
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="title">配置选项 & 结果</div>
|
<div class="title">配置选项 & 结果</div>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tool-elem">
|
<div class="tool-page">
|
||||||
|
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="title">信息</div>
|
<div class="title">信息</div>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tool-elem">
|
<div class="tool-page">
|
||||||
|
|
||||||
<!-- 输入 -->
|
<!-- 输入 -->
|
||||||
<div class="input">
|
<div class="input">
|
||||||
@@ -137,7 +137,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.tool-elem {
|
.tool-page {
|
||||||
@lineHeight: 1.25rem;
|
@lineHeight: 1.25rem;
|
||||||
|
|
||||||
padding-bottom: 5rem;
|
padding-bottom: 5rem;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tool-elem">
|
<div class="tool-page">
|
||||||
|
|
||||||
<!-- 操作 -->
|
<!-- 操作 -->
|
||||||
<div class="ctrl">
|
<div class="ctrl">
|
||||||
|
@@ -4,13 +4,19 @@
|
|||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
|
||||||
<!-- 工具分类 -->
|
<!-- 工具分类 -->
|
||||||
<div v-for="(categoryItem, categoryKey) in toolList" :key="categoryKey" class="category">
|
<div
|
||||||
|
v-for="(categoryItem, categoryKey) in toolList"
|
||||||
|
:key="categoryKey"
|
||||||
|
class="category"
|
||||||
|
>
|
||||||
|
|
||||||
<!-- 标题 -->
|
<!-- 标题 -->
|
||||||
<div class="title">{{ categoryItem.title }}</div>
|
<div class="title">{{ categoryItem.title }}</div>
|
||||||
|
|
||||||
<!-- 工具项 -->
|
<!-- 工具项 -->
|
||||||
<div v-for="(toolItem, toolKey) in categoryItem.list" :key="toolKey"
|
<div
|
||||||
|
v-for="(toolItem, toolKey) in categoryItem.list"
|
||||||
|
:key="toolKey"
|
||||||
:class="['tool-item', 'shadow-2', { disabled: !toolItem.enabled }]"
|
:class="['tool-item', 'shadow-2', { disabled: !toolItem.enabled }]"
|
||||||
@click="detailOpen(categoryKey, toolKey)"
|
@click="detailOpen(categoryKey, toolKey)"
|
||||||
>
|
>
|
||||||
@@ -22,10 +28,16 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 弹出 -->
|
<!-- 弹出层 -->
|
||||||
<el-drawer custom-class="drawer-full" direction="btt" size="100%"
|
<el-drawer
|
||||||
:append-to-body="true" :destroy-on-close="true" :title="detail.title"
|
custom-class="drawer-full"
|
||||||
:visible.sync="detail.show" :before-close="detailClose"
|
direction="btt"
|
||||||
|
size="100%"
|
||||||
|
:append-to-body="true"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
:title="detail.title"
|
||||||
|
:visible.sync="detail.show"
|
||||||
|
:before-close="detailClose"
|
||||||
>
|
>
|
||||||
|
|
||||||
<!-- 标题区域 -->
|
<!-- 标题区域 -->
|
||||||
@@ -61,14 +73,14 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeRouteEnter(to, from, next) {
|
beforeRouteEnter(to, from, next) {
|
||||||
next(vm => {
|
next(vm => {
|
||||||
var route = vm.$route;
|
const { name: rName, params: rParams } = vm.$route;
|
||||||
|
|
||||||
// 判断进入的路由
|
// 判断进入的路由
|
||||||
if (route.name === 'ToolsDetail') {
|
if (rName === 'ToolsDetail') {
|
||||||
// 进入:工具内容页面
|
// [工具内容页面]
|
||||||
vm.detailOpen(route.params.category, route.params.name);
|
vm.detailOpen(rParams.category, rParams.name);
|
||||||
} else {
|
} else {
|
||||||
// 进入:工具列表页面
|
// [工具列表页面]
|
||||||
vm.utils.changeTitle('小工具');
|
vm.utils.changeTitle('小工具');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -82,12 +94,13 @@ export default {
|
|||||||
this.$confirm('是否关闭?').then(() => {
|
this.$confirm('是否关闭?').then(() => {
|
||||||
// 关闭 drawer
|
// 关闭 drawer
|
||||||
done();
|
done();
|
||||||
// 路由跳转
|
// 返回工具页面
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'Tools'
|
name: 'Tools'
|
||||||
});
|
}).then(() => {
|
||||||
// 更新页面标题
|
// 更新标题
|
||||||
this.utils.changeTitle('小工具');
|
this.utils.changeTitle('小工具');
|
||||||
|
});
|
||||||
}).catch(() => { });
|
}).catch(() => { });
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -98,19 +111,11 @@ export default {
|
|||||||
* @param {string} toolName 工具名称
|
* @param {string} toolName 工具名称
|
||||||
*/
|
*/
|
||||||
detailOpen(toolCatrgory, toolName) {
|
detailOpen(toolCatrgory, toolName) {
|
||||||
// 当前工具信息
|
const errMsg = `无法打开该工具(分类:${toolCatrgory} 名称:${toolName})`;
|
||||||
var info = {
|
|
||||||
title: '',
|
|
||||||
update: '',
|
|
||||||
version: '',
|
|
||||||
};
|
|
||||||
// 错误提示
|
|
||||||
var errMsg = `无法打开该工具(分类:${toolCatrgory} 名称:${toolName})`;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
info = this.toolList[toolCatrgory]['list'][toolName];
|
var info = this.toolList[toolCatrgory]['list'][toolName];
|
||||||
|
|
||||||
if (info === undefined) {
|
if (info === undefined) {
|
||||||
throw new Error(errMsg);
|
throw new Error(errMsg);
|
||||||
}
|
}
|
||||||
@@ -120,7 +125,7 @@ export default {
|
|||||||
console.warn('[打开工具]', err);
|
console.warn('[打开工具]', err);
|
||||||
this.$message({
|
this.$message({
|
||||||
message: errMsg,
|
message: errMsg,
|
||||||
type: 'warning'
|
type: 'error'
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -135,12 +140,14 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新页面标题
|
const {
|
||||||
this.utils.changeTitle(info.title);
|
title: iTitle,
|
||||||
// 更新 drawer 标题
|
version: iVersion,
|
||||||
this.detail.title = `${info.title} [${info.version || '未知'}][${info.update || '未知'}]`;
|
update: iUpdate,
|
||||||
|
} = info;
|
||||||
|
|
||||||
// 路由跳转
|
// 路由跳转
|
||||||
// 注:当前路由相同时也进行跳转,以更新 query
|
// 注:当前路由相同时也进行跳转
|
||||||
this.$router.push({
|
this.$router.push({
|
||||||
name: 'ToolsDetail',
|
name: 'ToolsDetail',
|
||||||
params: {
|
params: {
|
||||||
@@ -148,10 +155,14 @@ export default {
|
|||||||
name: toolName
|
name: toolName
|
||||||
}
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log('[路由跳转]', err.name);
|
console.log('[打开工具]', err.name);
|
||||||
});
|
}).finally(() => {
|
||||||
|
// 更新标题
|
||||||
|
this.utils.changeTitle(iTitle);
|
||||||
|
this.detail.title = `${iTitle} [${iVersion || '未知'}][${iUpdate || '未知'}]`;
|
||||||
// 显示 drawer
|
// 显示 drawer
|
||||||
this.detail.show = true;
|
this.detail.show = true;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -174,6 +185,7 @@ export default {
|
|||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
background-color: @colorWhite;
|
background-color: @colorWhite;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.wrapper {
|
.wrapper {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -233,7 +245,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.drawer-full {
|
.drawer-full {
|
||||||
.header {
|
.header {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tools-detail">
|
<div class="tools-detail">
|
||||||
<component :is="toolElem" />
|
<component :is="toolPage" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -13,16 +13,18 @@ export default {
|
|||||||
return {
|
return {
|
||||||
utils: this.$root.utils,
|
utils: this.$root.utils,
|
||||||
toolList: navTools,
|
toolList: navTools,
|
||||||
toolElem: null,
|
toolPage: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeRouteEnter(to, from, next) {
|
beforeRouteEnter(to, from, next) {
|
||||||
next(vm => {
|
next(vm => {
|
||||||
var params = vm.$route.params;
|
const { params, query } = vm.$route;
|
||||||
var toolComponent = vm.toolList[params.category]['list'][params.name].component;
|
const { category: cCategory, name: cName } = params;
|
||||||
|
const componentName = vm.toolList[cCategory]['list'][cName].component;
|
||||||
|
|
||||||
var loading = null;
|
var loading = null;
|
||||||
|
|
||||||
console.log('[打开工具] params', params);
|
console.log('[打开工具]', { params, query });
|
||||||
|
|
||||||
// 异步,防止找不到 target
|
// 异步,防止找不到 target
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -35,18 +37,18 @@ export default {
|
|||||||
});
|
});
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
vm.toolElem = (() => {
|
vm.toolPage = (() => {
|
||||||
// 动态引入组件
|
// 动态引入组件
|
||||||
var elem = import(`@/components/tools/${toolComponent}.vue`);
|
const component = import(`@/components/tools/${componentName}.vue`);
|
||||||
|
|
||||||
Promise.all([elem]).then(() => {
|
Promise.all([component]).then(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// 关闭 Loading
|
// 关闭 Loading
|
||||||
loading.close();
|
loading.close();
|
||||||
}, 200);
|
}, 200);
|
||||||
});
|
});
|
||||||
|
|
||||||
return elem;
|
return component;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -58,8 +60,9 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
/deep/ .tool-elem {
|
/deep/ .tool-page {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 60rem;
|
max-width: 60rem;
|
||||||
|
|
||||||
@@ -82,9 +85,9 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
> .content {
|
> .content {
|
||||||
|
line-height: 1.6em;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
Reference in New Issue
Block a user