Skip to content

Commit

Permalink
fix(projects): 修复项目配置拷贝功能
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Feb 7, 2022
1 parent 2c9660f commit a7a269d
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<n-divider title-placement="center">主题配置</n-divider>
<textarea id="themeConfigCopyTarget" v-model="dataClipboardText" class="absolute opacity-0" />
<n-space vertical>
<div ref="copyRef" :data-clipboard-text="dataClipboardText">
<div ref="copyRef" data-clipboard-target="#themeConfigCopyTarget">
<n-button type="primary" :block="true">拷贝当前配置</n-button>
</div>
<n-button type="warning" :block="true" @click="handleResetConfig">重置当前配置</n-button>
Expand All @@ -17,6 +18,7 @@ import { useThemeStore } from '@/store';
const theme = useThemeStore();
const copyRef = ref<HTMLElement>();
const dataClipboardText = ref(getClipboardText());
function getClipboardText() {
Expand All @@ -29,8 +31,7 @@ function handleResetConfig() {
}
function clipboardEventListener() {
if (!copyRef.value) return;
const copy = new Clipboard(copyRef.value);
const copy = new Clipboard(copyRef.value!);
copy.on('success', () => {
window.$dialog?.success({
title: '操作成功',
Expand Down
4 changes: 3 additions & 1 deletion src/service/request/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { createRequest } from './request';
import { serviceEnv } from '~/.env-config';

const { url } = serviceEnv[import.meta.env.VITE_HTTP_ENV];
const env = import.meta.env.VITE_HTTP_ENV || 'test';

const { url } = serviceEnv[env];

export const request = createRequest({ baseURL: url });

Expand Down
142 changes: 142 additions & 0 deletions src/settings/theme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"darkMode": false,
"layout": {
"minWidth": 900,
"mode": "vertical",
"modeList": [
{
"value": "vertical",
"label": "左侧菜单模式"
},
{
"value": "vertical-mix",
"label": "左侧菜单混合模式"
},
{
"value": "horizontal",
"label": "顶部菜单模式"
},
{
"value": "horizontal-mix",
"label": "顶部菜单混合模式"
}
]
},
"themeColor": "#1890ff",
"themeColorList": [
"#1890ff",
"#409EFF",
"#2d8cf0",
"#007AFF",
"#5ac8fa",
"#5856D6",
"#536dfe",
"#9c27b0",
"#AF52DE",
"#0096c7",
"#00C1D4",
"#34C759",
"#43a047",
"#7cb342",
"#c0ca33",
"#78DEC7",
"#e53935",
"#d81b60",
"#f4511e",
"#fb8c00",
"#ffb300",
"#fdd835",
"#6d4c41",
"#546e7a"
],
"otherColor": {
"info": "#0099ad",
"success": "#52c41a",
"warning": "#faad14",
"error": "#f5222d"
},
"isCustomizeInfoColor": false,
"fixedHeaderAndTab": true,
"showReload": true,
"header": {
"height": 56,
"crumb": {
"visible": true,
"showIcon": true
}
},
"tab": {
"visible": true,
"height": 44,
"mode": "chrome",
"modeList": [
{
"value": "chrome",
"label": "谷歌风格"
},
{
"value": "button",
"label": "按钮风格"
}
],
"isCache": true
},
"sider": {
"width": 220,
"collapsedWidth": 64,
"mixWidth": 80,
"mixCollapsedWidth": 48,
"mixChildMenuWidth": 200
},
"menu": {
"horizontalPosition": "flex-start",
"horizontalPositionList": [
{
"value": "flex-start",
"label": "居左"
},
{
"value": "center",
"label": "居中"
},
{
"value": "flex-end",
"label": "居右"
}
]
},
"footer": {
"fixed": false,
"height": 48
},
"page": {
"animate": true,
"animateMode": "fade-slide",
"animateModeList": [
{
"value": "fade-slide",
"label": "滑动"
},
{
"value": "fade",
"label": "消退"
},
{
"value": "fade-bottom",
"label": "底部消退"
},
{
"value": "fade-scale",
"label": "缩放消退"
},
{
"value": "zoom-fade",
"label": "渐变"
},
{
"value": "zoom-out",
"label": "闪现"
}
]
}
}
3 changes: 2 additions & 1 deletion src/settings/theme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EnumThemeLayoutMode, EnumThemeTabMode, EnumThemeHorizontalMenuPosition, EnumThemeAnimateMode } from '@/enum';
import type { ThemeSetting } from '@/interface';
import jsonSetting from './theme.json';

const themeColorList = [
'#1890ff',
Expand Down Expand Up @@ -101,4 +102,4 @@ const defaultThemeSetting: ThemeSetting = {
}
};

export const themeSetting = defaultThemeSetting;
export const themeSetting = (jsonSetting as ThemeSetting) || defaultThemeSetting;
2 changes: 1 addition & 1 deletion src/typings/common/route.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ declare namespace AuthRoute {
type SingleRouteParentPath = KeyToPath<SingleRouteParentKey>;

/** 路由key转换路由path */
type KeyToPath<Key extends RouteKey> = Key extends `${infer Left}_${infer Right}`
type KeyToPath<Key extends string> = Key extends `${infer Left}_${infer Right}`
? KeyToPath<`${Left}/${Right}`>
: `/${Key}`;

Expand Down

1 comment on commit a7a269d

@vercel
Copy link

@vercel vercel bot commented on a7a269d Feb 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.