Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix(style): editor size in fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
hibig committed Mar 6, 2024
1 parent 0c8c37a commit 79362bc
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 83 deletions.
4 changes: 4 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare module 'vue' {
ADescriptions: typeof import('@arco-design/web-vue')['Descriptions'];
ADivider: typeof import('@arco-design/web-vue')['Divider'];
ADoption: typeof import('@arco-design/web-vue')['Doption'];
ADropdown: typeof import('@arco-design/web-vue')['Dropdown'];
AEmpty: typeof import('@arco-design/web-vue')['Empty'];
AForm: typeof import('@arco-design/web-vue')['Form'];
AFormItem: typeof import('@arco-design/web-vue')['FormItem'];
Expand All @@ -25,8 +26,10 @@ declare module 'vue' {
AInput: typeof import('@arco-design/web-vue')['Input'];
AInputNumber: typeof import('@arco-design/web-vue')['InputNumber'];
AInputPassword: typeof import('@arco-design/web-vue')['InputPassword'];
AInputSearch: typeof import('@arco-design/web-vue')['InputSearch'];
ALayout: typeof import('@arco-design/web-vue')['Layout'];
ALayoutContent: typeof import('@arco-design/web-vue')['LayoutContent'];
ALayoutFooter: typeof import('@arco-design/web-vue')['LayoutFooter'];
ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider'];
ALink: typeof import('@arco-design/web-vue')['Link'];
AMenu: typeof import('@arco-design/web-vue')['Menu'];
Expand All @@ -48,6 +51,7 @@ declare module 'vue' {
ATag: typeof import('@arco-design/web-vue')['Tag'];
ATextarea: typeof import('@arco-design/web-vue')['Textarea'];
ATooltip: typeof import('@arco-design/web-vue')['Tooltip'];
AUpload: typeof import('@arco-design/web-vue')['Upload'];
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/assets/style/variable.less
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ body {
--color-data-card-shadow: 0 0 6px rgba(229, 230, 235, 0.3);

// form card shadow
--color-form-card-shadow: 0 4px 3px -1px rgba(234, 236, 238, 1),
--color-form-card-shadow: 0 4px 3px -2px rgba(234, 236, 238, 1),
0 1px 4px 0 rgba(169, 174, 184, 0.2);
--color-form-card-shadow-hover: rgba(169, 174, 184, 1) 0 3px 6px -1px,
rgba(169, 174, 184, 0.2) 0 3px 6px 0;
Expand Down
13 changes: 12 additions & 1 deletion src/components/code-diff-view/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="tsx">
import _ from 'lodash';
import { defineComponent, ref, watch, computed, PropType } from 'vue';
import useCodeView from '@/hooks/use-code-view';
import CodeChunk from './code-chunk.vue';
Expand All @@ -17,6 +18,12 @@
return true;
}
},
maxHeight: {
type: [Number, String],
default() {
return '300px';
}
},
leftTitle: {
type: String,
default: ''
Expand Down Expand Up @@ -52,6 +59,11 @@
<>
{rightChunks.value.length || leftChunks.value.length ? (
<div
style={{
maxHeight: _.isString(props.maxHeight)
? props.maxHeight
: `${props.maxHeight}px`
}}
class={[
'chunk-box',
{
Expand Down Expand Up @@ -123,7 +135,6 @@
position: relative;
display: flex;
justify-content: space-between;
max-height: 300px;
overflow: hidden;
overflow-y: auto;
font-size: var(--font-size-small);
Expand Down
5 changes: 2 additions & 3 deletions src/components/highlight-block/code-viewer.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script lang="tsx">
import hljs from 'highlight.js';
import 'highlight.js/styles/atom-one-light.css';
import { ref, computed, defineComponent, watch } from 'vue';
import 'highlight.js/lib/common';
import hljs from 'highlight.js/lib/core';
import { escapeHtml } from './utils';
export default defineComponent({
Expand All @@ -13,7 +12,7 @@
},
lang: {
type: String,
default: 'json'
default: ''
},
autodetect: {
type: Boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/components/highlight-block/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="high-light-wrapper" :class="{ dark: appStore.isDark }">
<CodeViewer :lang="lang" :code="code" :autodetect="false" />
<CodeViewer :lang="lang" :code="code" />
<slot></slot>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion src/components/menu/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const avatarMenu = [
itemStyle: {},
children: [
{
name: 'darkMode',
name: 'navbar.appearance',
key: 'darkMode'
},
{
Expand Down
112 changes: 73 additions & 39 deletions src/components/menu/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@
return travel(menuTree.value);
};
const handleClickUserMenu = (item) => {
if (item.key === 'darkMode') {
isDark.value = !isDark.value;
toggleTheme(isDark.value);
}
if (item.key === 'UserCenter') {
router.push({
name: item.route
Expand Down Expand Up @@ -296,6 +300,50 @@
changeLocale(item.value);
}
};
const renderModeButton = () => {
return (
<div
class="flex flex-align-center"
style={{ height: '36px', lineHeight: '36px' }}
onMouseover={() => {
checkedColor.value = isDark.value
? 'var(--black-2)'
: 'var(--black-1)';
}}
onMouseout={() => {
if (isDark.value) {
checkedColor.value = 'var(--black-1)';
}
}}
>
<a-switch
size="small"
onChange={toggleTheme}
v-model={isDark.value}
checked-color={checkedColor.value}
v-slots={{
'checked-icon': () => (
<icon-moon
style={{
fontSize: '16px',
color: 'var(--color-text-2)'
}}
/>
),
'unchecked-icon': () => (
<icon-sun
style={{
fontSize: '16px',
color: 'var(--color-text-2)'
}}
/>
)
}}
></a-switch>
</div>
);
};
const renderUserMenu = (menuConfig) => {
function travel() {
const nodes: any[] = [];
Expand Down Expand Up @@ -343,45 +391,31 @@
}}
>
{cItem.key === 'darkMode' ? (
<div
class="flex flex-align-center"
style={{ height: '36px', lineHeight: '36px' }}
onMouseover={() => {
checkedColor.value = isDark.value
? 'var(--black-2)'
: 'var(--black-1)';
}}
onMouseout={() => {
if (isDark.value) {
checkedColor.value = 'var(--black-1)';
}
}}
>
<a-switch
size="small"
onChange={toggleTheme}
v-model={isDark.value}
checked-color={checkedColor.value}
v-slots={{
'checked-icon': () => (
<icon-moon
style={{
fontSize: '16px',
color: 'var(--color-text-2)'
}}
/>
),
'unchecked-icon': () => (
<icon-sun
style={{
fontSize: '16px',
color: 'var(--color-text-2)'
}}
/>
)
}}
></a-switch>
</div>
<span class="flex flex-align-center">
{isDark.value ? (
<icon-moon
style={{
fontSize: '14px',
color: 'var(--color-text-2)',
marginLeft: '1px'
}}
/>
) : (
<icon-sun
style={{
fontSize: '14px',
color: 'var(--color-text-2)',
marginLeft: '1px'
}}
/>
)}
<span
class="title"
style={{ fontSize: '12px', marginLeft: '7px' }}
>
{t(cItem.name)}
</span>
</span>
) : (
<span class="title" style={{ fontSize: '12px' }}>
{t(cItem.name)}
Expand Down
22 changes: 2 additions & 20 deletions src/components/seal-form/components/seal-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,7 @@
allow-clear={false}
class="v-sel"
v-slots={{
..._.reduce(
_.keys(slots),
(result, key) => {
if (slots[key]) {
result[key] = () => slots[key]?.();
}
return result;
},
{}
),
...slots,
empty: () => (
<a-empty
description={
Expand Down Expand Up @@ -148,16 +139,7 @@
onFocus={(e) => handleFocus(e)}
onInputValueChange={(value) => handleInputValueChange(value)}
v-slots={{
..._.reduce(
_.keys(slots),
(result, key) => {
if (slots[key]) {
result[key] = (data) => slots[key]?.(data);
}
return result;
},
{}
),
...slots,
empty: () => (
<a-empty
description={
Expand Down
5 changes: 5 additions & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ declare module 'tippy.js' {
export default tippy;
}

declare module 'highlight.js' {
import hljs from 'highlight.js';

export default hljs;
}
declare module '@vueuse/core' {
export {
createReusableTemplate,
Expand Down
1 change: 1 addition & 0 deletions src/locale/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default {
'navbar.operatorhub': 'Operation Hub',
'navbar.action.locale': 'Switch to English',
'navbar.totalView': 'Dashboard',
'navbar.appearance': 'Appearance',
...localeCommon,
...localeSettings,
...localeLogin,
Expand Down
1 change: 1 addition & 0 deletions src/locale/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default {
'navbar.operatorhub': '运维中心',
'navbar.action.locale': '切换为中文',
'navbar.totalView': '概览',
'navbar.appearance': '外观',
...localeCommon,
...localeSettings,
...localeLogin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@
key="attributes"
:title="$t('resource.revisons.detail.attributes')"
>
<runAttributes :run-data="basicData"></runAttributes>
<runAttributes
:run-data="basicData"
:fullscreen="fullscreen"
></runAttributes>
</a-tab-pane>
<a-tab-pane key="logs" :title="$t('applications.instance.tab.log')">
<runLogs
Expand All @@ -86,7 +89,10 @@
key="history"
:title="$t('applications.applications.history.changeList')"
>
<runChangeHistory :run-data="basicData"></runChangeHistory>
<runChangeHistory
:run-data="basicData"
:fullscreen="fullscreen"
></runChangeHistory>
</a-tab-pane>
</a-tabs>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
default() {
return {};
}
},
fullscreen: {
type: Boolean,
default: false
}
},
setup(props, ctx) {
Expand All @@ -38,6 +42,10 @@
const yamlAttributes = ref('');
const serviceInfo = inject(ProvideServiceInfoKey, ref<any>({}));
const maxHeight = computed(() => {
return props.fullscreen ? 'calc(100vh - 360px)' : '380px';
});
const serviceDetail = computed(() => {
return {
...serviceInfo.value,
Expand Down Expand Up @@ -75,7 +83,7 @@
editorId="yaml_editor"
editor-default-value={yamlAttributes.value}
lang="yaml"
height={380}
height={maxHeight.value}
></AceEditor>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
default() {
return {};
}
},
fullscreen: {
type: Boolean,
default() {
return false;
}
}
},
setup(props, ctx) {
Expand All @@ -22,6 +28,10 @@
});
const loading = ref(false);
const maxHeight = computed(() => {
return props.fullscreen ? 'calc(100vh - 360px)' : '300px';
});
const getRevisionChange = async () => {
if (!props.runData.id || !props.runData.resource?.id) {
return;
Expand Down Expand Up @@ -77,6 +87,7 @@
) : null}
<a-spin loading={loading.value} style={{ width: '100%' }}>
<CodeDiffView
maxHeight={maxHeight.value}
content={diffContent.value}
class="m-t-10 m-b-10"
v-slots={{
Expand Down
Loading

0 comments on commit 79362bc

Please sign in to comment.