mirror of
https://github.com/purocean/yn.git
synced 2026-10-16 07:26:07 +08:00
feat: demo 增加表格
This commit is contained in:
@@ -119,8 +119,8 @@ function buildSrcdoc (repo: string, path: string, full: boolean) {
|
||||
}
|
||||
</style>
|
||||
<div id="lucky-sheet" style="height: 100%"></div>
|
||||
<script defer src="/luckysheet/plugins/js/plugin.js"></script>
|
||||
<script defer src="/luckysheet/luckysheet.umd.js"></script>
|
||||
<script src="/luckysheet/plugins/js/plugin.js"></script>
|
||||
<script src="/luckysheet/luckysheet.umd.js"></script>
|
||||
<script>
|
||||
async function fetchHttp (input, init) {
|
||||
const response = await fetch(input, init)
|
||||
|
||||
@@ -8,6 +8,7 @@ if (FLAG_DEMO) {
|
||||
setTheme('dark')
|
||||
|
||||
const xFetch = window.fetch
|
||||
const xOpen = window.open
|
||||
const cache: {[key: string]: string} = {}
|
||||
|
||||
window.addEventListener('click', e => {
|
||||
@@ -65,13 +66,65 @@ if (FLAG_DEMO) {
|
||||
}
|
||||
|
||||
if (uri.startsWith('/api/tree')) {
|
||||
return Promise.resolve({ status: 'ok', message: '获取成功', data: [{ name: '/', type: 'dir', path: '/', repo: 'test', children: [{ name: '工作', path: '工作', type: 'dir', repo: 'test', children: [{ name: '1.md', path: '工作/1.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635402958.447, mtime: 1623635402958.447 }, { name: '2.md', path: '工作/2.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635406528.4639, mtime: 1623635406528.4639 }, { name: '3.md', path: '工作/3.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635410176.051, mtime: 1623635410177.0498 }] }, { name: '学习', path: '学习', type: 'dir', repo: 'test', children: [{ name: 'a.md', path: '学习/a.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635423871.2678, mtime: 1623635423871.2678 }, { name: 'b.md', path: '学习/b.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635427472.3079, mtime: 1623635427472.3079 }, { name: 'c.md', path: '学习/c.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635431935.041, mtime: 1623635431935.041 }] }, { name: 'TEST.md', path: 'TEST.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635389096.3315, mtime: 1623635389097.3403 }, { name: 'TODO.md', path: 'TODO.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635437968.1262, mtime: 1623635437969.1235 }, { name: '重要账号.c.md', path: '重要账号.c.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635542753.2976, mtime: 1623635542753.2976 }] }] })
|
||||
return Promise.resolve({ status: 'ok', message: '获取成功', data: [{ name: '/', type: 'dir', path: '/', repo: 'test', children: [{ name: '工作', path: '工作', type: 'dir', repo: 'test', children: [{ name: '1.md', path: '工作/1.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635402958.447, mtime: 1623635402958.447 }, { name: '2.md', path: '工作/2.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635406528.4639, mtime: 1623635406528.4639 }, { name: '3.md', path: '工作/3.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635410176.051, mtime: 1623635410177.0498 }] }, { name: '学习', path: '学习', type: 'dir', repo: 'test', children: [{ name: 'a.md', path: '学习/a.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635423871.2678, mtime: 1623635423871.2678 }, { name: 'b.md', path: '学习/b.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635427472.3079, mtime: 1623635427472.3079 }, { name: 'c.md', path: '学习/c.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635431935.041, mtime: 1623635431935.041 }] }, { name: 'TEST.md', path: 'TEST.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635389096.3315, mtime: 1623635389097.3403 }, { name: 'TODO.md', path: 'TODO.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635437968.1262, mtime: 1623635437969.1235 }, { name: '重要账号.c.md', path: '重要账号.c.md', type: 'file', repo: 'test', marked: false, birthtime: 1623635542753.2976, mtime: 1623635542753.2976 }, { name: '表格.luckysheet', path: '表格.luckysheet', type: 'file', repo: 'test', marked: false, birthtime: 1623635542753.2976, mtime: 1623635542753.2976 }] }] })
|
||||
}
|
||||
|
||||
if (uri.startsWith('/api/help') || uri.startsWith('/api/file')) {
|
||||
if (method === 'POST') {
|
||||
return Promise.resolve({ status: 'ok', message: '保存成功' })
|
||||
} else if (method === 'GET') {
|
||||
if ((url.searchParams.get('path') || '').endsWith('.luckysheet')) {
|
||||
const content = JSON.stringify([{
|
||||
name: 'Sheet1',
|
||||
color: '',
|
||||
status: 1,
|
||||
order: 0,
|
||||
data: Array(20).fill(Array(14).fill(null)),
|
||||
config: {
|
||||
merge: {},
|
||||
rowlen: {},
|
||||
rowhidden: {}
|
||||
},
|
||||
index: 0,
|
||||
jfgird_select_save: [],
|
||||
luckysheet_select_save: [{
|
||||
row: [0, 0],
|
||||
column: [0, 0],
|
||||
row_focus: 0,
|
||||
column_focus: 0,
|
||||
left: 0,
|
||||
width: 73,
|
||||
top: 0,
|
||||
height: 19,
|
||||
left_move: 0,
|
||||
width_move: 73,
|
||||
top_move: 0,
|
||||
height_move: 19
|
||||
}],
|
||||
visibledatarow: [],
|
||||
visibledatacolumn: [],
|
||||
ch_width: 4560,
|
||||
rh_height: 1760,
|
||||
luckysheet_selection_range: [],
|
||||
zoomRatio: 1,
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0,
|
||||
calcChain: [],
|
||||
filter_select: null,
|
||||
filter: null,
|
||||
luckysheet_conditionformat_save: [],
|
||||
luckysheet_alternateformat_save: [],
|
||||
dataVerification: {},
|
||||
hyperlink: {},
|
||||
celldata: []
|
||||
}])
|
||||
return Promise.resolve({
|
||||
status: 'ok',
|
||||
message: '获取成功',
|
||||
data: { content, hash: 'test' }
|
||||
})
|
||||
}
|
||||
|
||||
const path = '/' + (url.searchParams.get('doc') || 'FEATURES.md')
|
||||
const data = {
|
||||
status: 'ok',
|
||||
@@ -103,4 +156,10 @@ if (FLAG_DEMO) {
|
||||
return Promise.resolve({ status: 'error', message })
|
||||
}
|
||||
} as any)
|
||||
|
||||
window.open = function (...args: any[]) {
|
||||
const win = xOpen(...args)
|
||||
win!.fetch = window.fetch
|
||||
return win
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user