Skip to content

Commit

Permalink
更新一波基础设施
Browse files Browse the repository at this point in the history
  • Loading branch information
Redlnn committed Oct 1, 2024
1 parent 87df4db commit 2a774dd
Show file tree
Hide file tree
Showing 35 changed files with 4,069 additions and 4,012 deletions.
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

33 changes: 0 additions & 33 deletions .eslintrc.cjs

This file was deleted.

56 changes: 1 addition & 55 deletions docs/.vitepress/components/Curtain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,7 @@ withDefaults(defineProps<Props>(), {
</script>

<template>
<span :title="title" class="heimu">
<span :title="title" class="heimu" tabindex="-1">
<slot></slot>
</span>
</template>

<style scoped lang="scss">
.heimu {
color: rgba(60, 60, 67);
border-radius: 4px;
padding: 1.5px 4px;
margin: 0 2px;
text-shadow: none;
background-color: rgba(60, 60, 67);
transition:
color 0.13s linear,
background-color 0.13s linear;

html.dark & {
background-color: #e3e3e3;
color: #e3e3e3;
}

&:deep() {
code {
padding: 0.1rem 0.25rem;
background-color: rgba(60, 60, 67);
color: rgba(60, 60, 67);
html.dark & {
background-color: #e3e3e3;
color: #e3e3e3;
}
}
a {
color: rgba(60, 60, 67);
html.dark & {
color: #e3e3e3;
}
}
}

&:hover,
&:focus,
&:active {
color: var(--vp-c-bg) !important;

&:deep() code {
background-color: var(--vp-c-bg) !important;
color: rgba(60, 60, 67) !important;
}

html.dark &:deep() a,
&:deep() a {
color: var(--vp-c-bg);
text-decoration: underline;
}
}
}
</style>
2 changes: 1 addition & 1 deletion docs/.vitepress/components/FakeQQ/ChatFile.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, ref, type Ref } from 'vue'
import { onMounted, ref } from 'vue'
const props = defineProps<{
name: string
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/components/FakeQQ/ChatImg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface Props {
tagBgColor?: string
tagColor?: string
src: string
onright: boolean
onright?: boolean
}
withDefaults(defineProps<Props>(), {
Expand Down Expand Up @@ -40,8 +40,8 @@ withDefaults(defineProps<Props>(), {
<div class="user-name text-ellipsis">
<span class="text-ellipsis">{{ name }}</span>
<div
class="q-tag member-role-tag"
v-if="tag"
class="q-tag member-role-tag"
:style="{ backgroundColor: tagBgColor, color: tagColor }"
>
{{ tag }}
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/components/FakeQQ/ChatMsg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ withDefaults(defineProps<Props>(), {
<div class="user-name text-ellipsis">
<span class="text-ellipsis">{{ name }}</span>
<div
class="q-tag member-role-tag"
v-if="tag"
class="q-tag member-role-tag"
:style="{ backgroundColor: tagBgColor, color: tagColor }"
>
{{ tag }}
Expand Down
4 changes: 2 additions & 2 deletions docs/.vitepress/components/FakeQQ/ChatVoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Props {
tagBgColor?: string
tagColor?: string
audioSrc: string
onright: boolean
onright?: boolean
}
withDefaults(defineProps<Props>(), {
Expand Down Expand Up @@ -109,8 +109,8 @@ async function playVoice() {
<div class="user-name text-ellipsis">
<span class="text-ellipsis">{{ name }}</span>
<div
class="q-tag member-role-tag"
v-if="tag"
class="q-tag member-role-tag"
:style="{ backgroundColor: tagBgColor, color: tagColor }"
>
{{ tag }}
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/components/FakeQQ/ForwardChat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ withDefaults(defineProps<Props>(), {
<div class="user-name text-ellipsis">
<span class="text-ellipsis">{{ name }}</span>
<div
class="q-tag member-role-tag"
v-if="tag"
class="q-tag member-role-tag"
:style="{ backgroundColor: tagBgColor, color: tagColor }"
>
{{ tag }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
*
*/

import { IconBase } from '../plugins/utils/IconBase'
import { h } from 'vue'
import { IconBase } from './utils/IconBase'

import type { FunctionalComponent } from 'vue'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,13 @@
*
*/

import { computed, defineComponent, h, onMounted, ref, shallowRef, watch } from 'vue'
import { useMutationObserver, useDark } from '@vueuse/core'
import { LoadingIcon } from './Icons'
import { unzlibSync, strToU8, strFromU8 } from 'fflate'
import type { VNode } from 'vue'
import mermaid from 'mermaid'
import type { MermaidConfig } from 'mermaid'
import { computed, defineComponent, h, onMounted, ref, shallowRef, watch } from 'vue'
import { useDark, useMutationObserver } from '@vueuse/core'

const DEFAULT_CHART_OPTIONS = { useMaxWidth: false }
const DEFAULT_CHART_OPTIONS = { useMaxWidth: false, htmlLabels: false }
const isDark = useDark()

const getThemeVariables = (isDarkMode: boolean): Record<string, unknown> => {
Expand Down Expand Up @@ -273,33 +271,49 @@ const getThemeVariables = (isDarkMode: boolean): Record<string, unknown> => {
}
}

function atou(base64: string): string {
const binary = atob(base64)
// function atou(base64: string): string {
// const binary = atob(base64)

// zlib header (x78), level 9 (xDA)
if (binary.startsWith('\x78\xDA')) {
const buffer = strToU8(binary, true)
const unzipped = unzlibSync(buffer)
return strFromU8(unzipped)
}
// // zlib header (x78), level 9 (xDA)
// if (binary.startsWith('\x78\xDA')) {
// const buffer = strToU8(binary, true)
// const unzipped = unzlibSync(buffer)
// return strFromU8(unzipped)
// }

// old unicode hacks for backward compatibility
// https://base64.guru/developers/javascript/examples/unicode-strings
return decodeURIComponent(escape(binary))
}
// // old unicode hacks for backward compatibility
// // https://base64.guru/developers/javascript/examples/unicode-strings
// return decodeURIComponent(escape(binary))
// }

export default defineComponent({
// eslint-disable-next-line vue/multi-word-component-names
name: 'Mermaid',

props: {
/**
* Mermaid id
*/
id: { type: String, required: true },
code: { type: String, required: true }

/**
* Mermaid config
*
* Mermaid 配置
*/
code: { type: String, required: true },

/**
* Mermaid title
*
* Mermaid 标题
*/
title: { type: String, default: '' }
},

setup(props) {
const mermaidElement = shallowRef<HTMLElement>()
const code = computed(() => atou(props.code))

const code = computed(() => props.code)

const svgCode = ref('')

Expand All @@ -318,7 +332,6 @@ export default defineComponent({
startOnLoad: false
})

// eslint-disable-next-line
svgCode.value = (await mermaid.render(props.id, code.value)).svg
}

Expand Down Expand Up @@ -352,7 +365,7 @@ export default defineComponent({
const a = document.createElement('a')

a.setAttribute('href', dataURI)
a.setAttribute('download', `${props.id}.svg`)
a.setAttribute('download', `${props.title || props.id}.svg`)
a.click()
}

Expand Down Expand Up @@ -383,34 +396,36 @@ export default defineComponent({
})

return (): VNode[] => [
h('div', { class: 'mermaid-actions' }, [
h('button', {
class: 'preview-button',
onClick: () => preview(),
title: 'preview',
innerHTML:
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1316 1024" fill="currentColor"><path d="M658.286 0C415.89 0 0 297.106 0 512c0 214.82 415.89 512 658.286 512 242.322 0 658.285-294.839 658.285-512S900.608 0 658.286 0zm0 877.714c-161.573 0-512-221.769-512-365.714 0-144.018 350.427-365.714 512-365.714 161.572 0 512 217.16 512 365.714s-350.428 365.714-512 365.714z"/><path d="M658.286 292.571a219.429 219.429 0 1 0 0 438.858 219.429 219.429 0 0 0 0-438.858zm0 292.572a73.143 73.143 0 1 1 0-146.286 73.143 73.143 0 0 1 0 146.286z"/></svg>'
}),
h('button', {
class: 'download-button',
onClick: () => download(),
title: 'download',
innerHTML:
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path d="M828.976 894.125H190.189c-70.55 0-127.754-57.185-127.754-127.753V606.674c0-17.634 14.31-31.933 31.933-31.933h63.889c17.634 0 31.932 14.299 31.932 31.933v95.822c0 35.282 28.596 63.877 63.877 63.877h511.033c35.281 0 63.877-28.595 63.877-63.877v-95.822c0-17.634 14.298-31.933 31.943-31.933h63.878c17.635 0 31.933 14.299 31.933 31.933v159.7c0 70.566-57.191 127.751-127.754 127.751zM249.939 267.51c12.921-12.92 33.885-12.92 46.807 0l148.97 148.972V94.893c0-17.634 14.302-31.947 31.934-31.947h63.876c17.638 0 31.946 14.313 31.946 31.947v321.589l148.97-148.972c12.922-12.92 33.876-12.92 46.797 0l46.814 46.818c12.922 12.922 12.922 33.874 0 46.807L552.261 624.93c-1.14 1.138-21.664 13.684-42.315 13.693-20.877.01-41.88-12.542-43.021-13.693L203.122 361.135c-12.923-12.934-12.923-33.885 0-46.807l46.817-46.818z"/></svg>'
})
]),
h(
'div',
{
ref: mermaidElement,
class: 'mermaid-wrapper'
},
svgCode.value
? // mermaid
h('div', { class: 'mermaid-content', innerHTML: svgCode.value })
: // loading
h(LoadingIcon, { class: 'mermaid-loading', height: 96 })
)
h('div', { class: 'mermaid-contianer' }, [
h('div', { class: 'mermaid-actions' }, [
h('button', {
class: 'preview-button',
onClick: () => preview(),
title: 'preview',
innerHTML:
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1316 1024" fill="currentColor"><path d="M658.286 0C415.89 0 0 297.106 0 512c0 214.82 415.89 512 658.286 512 242.322 0 658.285-294.839 658.285-512S900.608 0 658.286 0zm0 877.714c-161.573 0-512-221.769-512-365.714 0-144.018 350.427-365.714 512-365.714 161.572 0 512 217.16 512 365.714s-350.428 365.714-512 365.714z"/><path d="M658.286 292.571a219.429 219.429 0 1 0 0 438.858 219.429 219.429 0 0 0 0-438.858zm0 292.572a73.143 73.143 0 1 1 0-146.286 73.143 73.143 0 0 1 0 146.286z"/></svg>'
}),
h('button', {
class: 'download-button',
onClick: () => download(),
title: 'download',
innerHTML:
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path d="M828.976 894.125H190.189c-70.55 0-127.754-57.185-127.754-127.753V606.674c0-17.634 14.31-31.933 31.933-31.933h63.889c17.634 0 31.932 14.299 31.932 31.933v95.822c0 35.282 28.596 63.877 63.877 63.877h511.033c35.281 0 63.877-28.595 63.877-63.877v-95.822c0-17.634 14.298-31.933 31.943-31.933h63.878c17.635 0 31.933 14.299 31.933 31.933v159.7c0 70.566-57.191 127.751-127.754 127.751zM249.939 267.51c12.921-12.92 33.885-12.92 46.807 0l148.97 148.972V94.893c0-17.634 14.302-31.947 31.934-31.947h63.876c17.638 0 31.946 14.313 31.946 31.947v321.589l148.97-148.972c12.922-12.92 33.876-12.92 46.797 0l46.814 46.818c12.922 12.922 12.922 33.874 0 46.807L552.261 624.93c-1.14 1.138-21.664 13.684-42.315 13.693-20.877.01-41.88-12.542-43.021-13.693L203.122 361.135c-12.923-12.934-12.923-33.885 0-46.807l46.817-46.818z"/></svg>'
})
]),
h(
'div',
{
ref: mermaidElement,
class: 'mermaid-wrapper'
},
svgCode.value
? // mermaid
h('div', { class: 'mermaid-content', innerHTML: svgCode.value })
: // loading
h(LoadingIcon, { class: 'mermaid-loading', height: 96 })
)
])
]
}
})
Loading

0 comments on commit 2a774dd

Please sign in to comment.