This commit is contained in:
satori 2022-02-05 05:08:17 +08:00
parent 69c6b03dd7
commit db75223449
3 changed files with 69 additions and 0 deletions

20
assets/js/users.js Normal file
View File

@ -0,0 +1,20 @@
export default class {
// 角色信息缓存加载器, 可以主动更新?
// 后端本可以实现基于缓存的优化
// 如果通过前端实现, 则前端主动查询并缓存每个用户信息摘要
// 每读取到用户信息时,, 仅通过 uid 调用实现组件, 而组件信息来源是独立的
// 可能会造成用户信息显示延迟,, 和反复调用的情况..?
// 如果不从服务器即开始载入用户信息, SSR 如何处理?
// 实际在数据传输过程会压缩用户信息, 因而占用不大(虽然压缩过程效率低下)
constructor() {
this.list = new Map() // 储存所有仍用到的用户信息
}
set(id, user) {
this.list.set(id, user)
}
// 使用某个用户信息时是立即返回结果的,, 这与 SSR 冲突
// 只适合聊天室使用, 防止大量分发重复数据
// 在 asyncData 中调用 server db 方法获取 data
// 在 asyncData 中判断是否 浏览器环境, 调用 data
}

View File

@ -74,6 +74,7 @@ export default {
.main .main
>header.header >header.header
z-index: 100
position: fixed position: fixed
top: 0 top: 0
left: 0 left: 0

48
pages/docs/index.vue Normal file
View File

@ -0,0 +1,48 @@
<template lang="pug">
.docs-index
.docs.circumscription
.outline
ul
li 下载安装
li 接口使用
li 插件制作
li 基础开发
.content
p 其构建目的是使实现所需越简单越好,, 避免仅为实现一个简单功能而牵涉到一堆较深层级的知识体系
p SDK
p 由于实现前端功能为直接目标, 为避免牵涉到其它知识体系, 此处将基于cookie的登录与权限判定逻辑均装入js库以直接调用
p
div
p import kana from 'kana-sdk'
p
p const ctx = new Kana() // , ,
p console.log(ctx.title) //
p console.log(ctx.info) //
p console.log(ctx.list) // , Map()
p
p const threadlist = ctx.list.get("thread") // thread
p console.log(threadlist) //
p console.log(threadlist[1].posts) //
p console.log(threadlist[1].posts[1].data) //
p console.log(threadlist[1].posts[1].user.name) //
p
p 维度是可变的
p ctx.list.get("post")
p 按照某一条件检索获得post列表
</template>
<style lang="sass">
.docs-index
margin: 8rem 4rem
.docs
display: flex
width: 100%
.outline
width: 12rem
padding: 2rem
background: #ccefef
.content
padding: 2rem
background: #ffefef
flex: 1
</style>