前人工作区变更归档(元审计遗留处置·冰朔授权'交给你来处理'·不否定过去原则):hololake-phase-b-staging删除组/WORK区/submodule指针/0826壳源/neural-chain/skills-mirror/codex恢复帧/.zcode本地配置等140项原样冻结入库——不删除不修改不评判,作为历史一环保留;WX-SECRETS回执经查仅含公开AppID无AppSecret,安全
This commit is contained in:
parent
28480f466c
commit
a40f29c12e
2442 changed files with 596545 additions and 6601 deletions
60
~/Projects/guanghulab-miniapp/pages/editor/editor.js
Normal file
60
~/Projects/guanghulab-miniapp/pages/editor/editor.js
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
// 编辑页:新建/编辑条目(原型:写回本地假数据)
|
||||
Page({
|
||||
data: {
|
||||
id: null,
|
||||
title: '',
|
||||
content: '',
|
||||
tagStr: '',
|
||||
visibility: 'private',
|
||||
aiReadable: true
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
if (query.id) {
|
||||
const n = getApp().globalData.notes.find(x => x.id === query.id)
|
||||
if (n) {
|
||||
this.setData({
|
||||
id: n.id, title: n.title, content: n.content,
|
||||
tagStr: n.tags.join(','),
|
||||
visibility: n.visibility, aiReadable: n.aiReadable
|
||||
})
|
||||
wx.setNavigationBarTitle({ title: '编辑条目' })
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onTitle(e) { this.setData({ title: e.detail.value }) },
|
||||
onContent(e) { this.setData({ content: e.detail.value }) },
|
||||
onTags(e) { this.setData({ tagStr: e.detail.value }) },
|
||||
onVis(e) { this.setData({ visibility: e.detail.value ? 'public' : 'private' }) },
|
||||
onAI(e) { this.setData({ aiReadable: e.detail.value }) },
|
||||
|
||||
onSave() {
|
||||
if (!this.data.title.trim()) {
|
||||
wx.showToast({ title: '标题不能为空', icon: 'none' })
|
||||
return
|
||||
}
|
||||
const app = getApp()
|
||||
const tags = this.data.tagStr.split(/[,,]/).map(t => t.trim()).filter(Boolean)
|
||||
const now = new Date()
|
||||
const stamp = `${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}`
|
||||
|
||||
if (this.data.id) {
|
||||
const n = app.globalData.notes.find(x => x.id === this.data.id)
|
||||
Object.assign(n, {
|
||||
title: this.data.title, content: this.data.content, tags,
|
||||
visibility: this.data.visibility, aiReadable: this.data.aiReadable, updatedAt: stamp
|
||||
})
|
||||
} else {
|
||||
app.globalData.notes.unshift({
|
||||
id: 'n' + Date.now(),
|
||||
title: this.data.title, content: this.data.content, tags,
|
||||
summary: this.data.content.replace(/[#*\-\n]/g, ' ').slice(0, 40),
|
||||
visibility: this.data.visibility, aiReadable: this.data.aiReadable,
|
||||
updatedAt: stamp
|
||||
})
|
||||
}
|
||||
wx.showToast({ title: '已保存(原型)' })
|
||||
setTimeout(() => wx.navigateBack(), 600)
|
||||
}
|
||||
})
|
||||
Loading…
Reference in a new issue