Skip to content

Commit 1817537

Browse files
feat: document
1 parent e63572b commit 1817537

File tree

5 files changed

+373
-129
lines changed

5 files changed

+373
-129
lines changed

ui/src/components/app-icon/icons/document.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default {
2020
])
2121
},
2222
},
23+
2324
'app-document-active': {
2425
iconReader: () => {
2526
return h('i', [
@@ -52,4 +53,88 @@ export default {
5253
])
5354
},
5455
},
56+
'app-close': {
57+
iconReader: () => {
58+
return h('i', [
59+
h(
60+
'svg',
61+
{
62+
style: { height: '100%', width: '100%' },
63+
viewBox: '0 0 16 16',
64+
version: '1.1',
65+
xmlns: 'http://www.w3.org/2000/svg',
66+
},
67+
[
68+
h('path', {
69+
d: 'M7.96141 6.98572L12.4398 2.50738C12.5699 2.3772 12.781 2.3772 12.9112 2.50738L13.3826 2.97878C13.5127 3.10895 13.5127 3.32001 13.3826 3.45018L8.90422 7.92853L13.3826 12.4069C13.5127 12.537 13.5127 12.7481 13.3826 12.8783L12.9112 13.3497C12.781 13.4799 12.5699 13.4799 12.4398 13.3497L7.96141 8.87134L3.48307 13.3497C3.35289 13.4799 3.14184 13.4799 3.01166 13.3497L2.54026 12.8783C2.41008 12.7481 2.41008 12.537 2.54026 12.4069L7.0186 7.92853L2.54026 3.45018C2.41008 3.32001 2.41008 3.10895 2.54026 2.97878L3.01166 2.50738C3.14184 2.3772 3.35289 2.3772 3.48307 2.50738L7.96141 6.98572Z',
70+
fill: 'currentColor',
71+
}),
72+
],
73+
),
74+
])
75+
},
76+
},
77+
'app-document-refresh': {
78+
iconReader: () => {
79+
return h('i', [
80+
h(
81+
'svg',
82+
{
83+
style: { height: '100%', width: '100%' },
84+
viewBox: '0 0 1024 1024',
85+
version: '1.1',
86+
xmlns: 'http://www.w3.org/2000/svg',
87+
},
88+
[
89+
h('path', {
90+
d: 'M512 170.666667a85.333333 85.333333 0 0 1 85.333333-85.333334h256a85.333333 85.333333 0 0 1 85.333334 85.333334v256a85.333333 85.333333 0 0 1-85.333334 85.333333h-256a85.333333 85.333333 0 0 1-85.333333-85.333333V170.666667z m85.333333 0v256h256V170.666667h-256zM85.333333 597.333333a85.333333 85.333333 0 0 1 85.333334-85.333333h256a85.333333 85.333333 0 0 1 85.333333 85.333333v256a85.333333 85.333333 0 0 1-85.333333 85.333334H170.666667a85.333333 85.333333 0 0 1-85.333334-85.333334v-256z m85.333334 0v256h256v-256H170.666667zM128 298.666667a213.333333 213.333333 0 0 1 213.333333-213.333334h85.333334v85.333334H341.333333a128 128 0 0 0-128 128h57.514667a12.8 12.8 0 0 1 9.728 21.12l-100.181333 116.906666a12.8 12.8 0 0 1-19.456 0l-100.181334-116.906666A12.8 12.8 0 0 1 70.485333 298.666667H128zM896 725.333333a213.333333 213.333333 0 0 1-213.333333 213.333334h-85.333334v-85.333334h85.333334a128 128 0 0 0 128-128v-21.333333h-57.514667a12.8 12.8 0 0 1-9.728-21.12l100.181333-116.906667a12.8 12.8 0 0 1 19.456 0l100.181334 116.906667a12.8 12.8 0 0 1-9.728 21.12H896v21.333333z',
91+
fill: 'currentColor',
92+
}),
93+
],
94+
),
95+
])
96+
},
97+
},
98+
'app-migrate': {
99+
iconReader: () => {
100+
return h('i', [
101+
h(
102+
'svg',
103+
{
104+
style: { height: '100%', width: '100%' },
105+
viewBox: '0 0 1024 1024',
106+
version: '1.1',
107+
xmlns: 'http://www.w3.org/2000/svg'
108+
},
109+
[
110+
h('path', {
111+
d: 'M896.128 113.792a42.666667 42.666667 0 0 1 42.24 36.864l0.426667 5.802667v711.509333a42.666667 42.666667 0 0 1-36.906667 42.24l-5.76 0.426667h-263.082667a21.333333 21.333333 0 0 1-20.906666-17.066667l-0.426667-4.266667v-42.666666a21.333333 21.333333 0 0 1 17.066667-20.906667l4.266666-0.426667h220.416V199.125333H281.941333l0.042667 192.170667a21.333333 21.333333 0 0 1-21.333333 21.333333h-42.666667a21.333333 21.333333 0 0 1-21.333333-21.333333V135.125333a21.333333 21.333333 0 0 1 17.066666-20.906666l4.266667-0.426667h678.144zM424.96 485.973333c6.272 0 12.373333 2.218667 17.152 6.272l178.858667 151.338667a26.538667 26.538667 0 0 1 0 40.533333l-178.858667 151.381334a26.538667 26.538667 0 0 1-43.690667-20.266667v-103.765333H135.168a21.333333 21.333333 0 0 1-21.333333-21.333334v-42.666666a21.333333 21.333333 0 0 1 21.333333-21.333334H398.506667l-0.042667-113.621333c0-14.677333 11.904-26.538667 26.538667-26.538667z',
112+
fill: 'currentColor'
113+
})
114+
]
115+
)
116+
])
117+
}
118+
},
119+
'app-export': {
120+
iconReader: () => {
121+
return h('i', [
122+
h(
123+
'svg',
124+
{
125+
style: { height: '100%', width: '100%' },
126+
viewBox: '0 0 1024 1024',
127+
version: '1.1',
128+
xmlns: 'http://www.w3.org/2000/svg'
129+
},
130+
[
131+
h('path', {
132+
d: 'M791.04 554.24l-386.432-1.728a21.248 21.248 0 0 1-21.12-21.248L383.36 490.88c-0.064-11.776 9.408-21.376 21.12-21.44h0.192l394.112 1.728-97.664-98.112a21.44 21.44 0 0 1 0-30.208l30.08-30.144a21.12 21.12 0 0 1 29.952 0l165.12 165.952a42.88 42.88 0 0 1 0 60.288l-165.12 165.952a21.12 21.12 0 0 1-30.016 0l-30.016-30.144a21.44 21.44 0 0 1 0-30.208L791.04 554.24z m-132.672-383.552H170.24v682.624h488.128c11.712 0 21.184 9.6 21.184 21.376v42.624a21.248 21.248 0 0 1-21.248 21.376h-530.56A42.56 42.56 0 0 1 85.376 896V128c0-23.552 19.008-42.688 42.496-42.688h530.56c11.712 0 21.184 9.6 21.184 21.376v42.624a21.248 21.248 0 0 1-21.248 21.376z',
133+
fill: 'currentColor'
134+
})
135+
]
136+
)
137+
])
138+
}
139+
},
55140
}

ui/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import AppTable from './app-table/index.vue'
1414
import CodemirrorEditor from './codemirror-editor/index.vue'
1515
import InfiniteScroll from './infinite-scroll/index.vue'
1616
import ModelSelect from './model-select/index.vue'
17+
import ReadWrite from './read-write/index.vue'
1718
export default {
1819
install(app: App) {
1920
app.component('LogoFull', LogoFull)
@@ -31,5 +32,6 @@ export default {
3132
app.component('CodemirrorEditor', CodemirrorEditor)
3233
app.component('InfiniteScroll', InfiniteScroll)
3334
app.component('ModelSelect', ModelSelect)
35+
app.component('ReadWrite', ReadWrite)
3436
},
3537
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<template>
2+
<div class="cursor w-full">
3+
<slot name="read">
4+
<div class="flex align-center" v-if="!isEdit" @dblclick="dblclick">
5+
<auto-tooltip :content="data">
6+
{{ data }}
7+
</auto-tooltip>
8+
9+
<el-button
10+
v-if="trigger === 'default' && showEditIcon"
11+
class="ml-4"
12+
@click.stop="editNameHandle"
13+
text
14+
>
15+
<el-icon><EditPen /></el-icon>
16+
</el-button>
17+
</div>
18+
</slot>
19+
<slot>
20+
<div class="flex align-center" @click.stop v-if="isEdit">
21+
<div class="w-full">
22+
<el-input
23+
ref="inputRef"
24+
v-model="writeValue"
25+
:placeholder="$t('common.inputPlaceholder')"
26+
autofocus
27+
:maxlength="maxlength || '-'"
28+
:show-word-limit="maxlength ? true : false"
29+
@blur="isEdit = false"
30+
@keyup.enter="submit"
31+
clearable
32+
></el-input>
33+
</div>
34+
35+
<span class="ml-4">
36+
<el-button type="primary" text @mousedown="submit" :disabled="loading">
37+
<el-icon><Select /></el-icon>
38+
</el-button>
39+
</span>
40+
<span>
41+
<el-button text @click.stop="isEdit = false" :disabled="loading">
42+
<el-icon><CloseBold /></el-icon>
43+
</el-button>
44+
</span>
45+
</div>
46+
</slot>
47+
</div>
48+
</template>
49+
<script setup lang="ts">
50+
import { ref, watch, onMounted, nextTick } from 'vue'
51+
defineOptions({ name: 'ReadWrite' })
52+
const props = defineProps({
53+
data: {
54+
type: String,
55+
default: ''
56+
},
57+
showEditIcon: {
58+
type: Boolean,
59+
default: false
60+
},
61+
maxlength: {
62+
type: Number,
63+
default: () => 0
64+
},
65+
trigger: {
66+
type: String,
67+
default: 'default',
68+
validator: (value: string) => ['default', 'dblclick', 'manual'].includes(value)
69+
},
70+
write: {
71+
type: Boolean,
72+
default: false
73+
}
74+
})
75+
const emit = defineEmits(['change', 'close'])
76+
const inputRef = ref()
77+
const isEdit = ref(false)
78+
const writeValue = ref('')
79+
const loading = ref(false)
80+
81+
watch(isEdit, (bool) => {
82+
if (!bool) {
83+
writeValue.value = ''
84+
emit('close')
85+
} else {
86+
setTimeout(() => {
87+
nextTick(() => {
88+
inputRef.value?.focus()
89+
})
90+
}, 200)
91+
}
92+
})
93+
94+
watch(
95+
() => props.write,
96+
(bool) => {
97+
if (bool && props.trigger === 'manual') {
98+
editNameHandle()
99+
} else {
100+
isEdit.value = false
101+
}
102+
}
103+
)
104+
105+
function dblclick() {
106+
if (props.trigger === 'dblclick') {
107+
editNameHandle()
108+
}
109+
}
110+
111+
function submit() {
112+
loading.value = true
113+
emit('change', writeValue.value)
114+
setTimeout(() => {
115+
isEdit.value = false
116+
loading.value = false
117+
}, 200)
118+
}
119+
function editNameHandle() {
120+
writeValue.value = props.data
121+
isEdit.value = true
122+
}
123+
124+
onMounted(() => {})
125+
</script>
126+
<style lang="scss" scoped></style>

ui/src/enums/document.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum hitHandlingMethod {
2+
optimization = 'views.document.hitHandlingMethod.optimization',
3+
directly_return = 'views.document.hitHandlingMethod.directly_return'
4+
}

0 commit comments

Comments
 (0)