docs
This commit is contained in:
parent
69c6b03dd7
commit
db75223449
20
assets/js/users.js
Normal file
20
assets/js/users.js
Normal 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
|
||||
}
|
@ -74,6 +74,7 @@ export default {
|
||||
|
||||
.main
|
||||
>header.header
|
||||
z-index: 100
|
||||
position: fixed
|
||||
top: 0
|
||||
left: 0
|
||||
|
48
pages/docs/index.vue
Normal file
48
pages/docs/index.vue
Normal 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>
|
Loading…
Reference in New Issue
Block a user