初始版本 0.1.0:四道菜团队中台 DSH 插件
模型通道:接管官方 API Key 通道指向弹匣网关(GLM-5.3 / GLM-5.3-Flash) 登录:浏览器取一次性接入码 → 换成员专属 key → 写入 DSH 凭据 工具面:MCP 暴露查汇总/查任务/查项目/建任务/完成/改期/whoami 面板:侧边栏入口,个人看板 + 角色可见范围 + 行内操作 离职吊销:成员停用即吊销名下全部 TDB key 发布配置:scope 包名、私有 registry 锁定、prepack 自动构建、prepublishOnly 检查
This commit is contained in:
commit
ff8017bbbb
26 files changed
+2924
No files matched your search
Vendored
+434
@@ -0,0 +1,434 @@
|
||||
/**
|
||||
* 弹匣工作台 —— DSH 客户端半片(侧边栏面板)。
|
||||
*
|
||||
* 定位:DSH 里「我现在该干什么」+ 就地处理 + 一键跳回弹匣看全貌。
|
||||
* 数据与写操作全部走 /__markmag/*(宿主转调弹匣 API,鉴权用工具凭证)。
|
||||
*
|
||||
* 写操作的规矩:面板只把按钮接到弹匣已有的能力上(tasks_store.cycle / update / create),
|
||||
* 状态机、字段白名单、部门可见性、活动日志、依赖预警全在弹匣侧判定,这里一行规则都不重写。
|
||||
*
|
||||
* 默认个人看板;第二栏的可见范围由弹匣后端 _vis_ok 决定,面板只按角色给名字。
|
||||
* 产物由 scripts/build-client.mjs 从 panel.css + panel.template.js 合成。
|
||||
*/
|
||||
window.__ModuleLoader__.load({
|
||||
id: "dsh-markmag",
|
||||
factory: function (require) {
|
||||
const module = { exports: {} }
|
||||
const exports = module.exports
|
||||
|
||||
const reactMod = require("react")
|
||||
const React = reactMod && reactMod.default ? reactMod.default : reactMod
|
||||
const h = React.createElement
|
||||
const useState = React.useState
|
||||
const useEffect = React.useEffect
|
||||
const useCallback = React.useCallback
|
||||
const useMemo = React.useMemo
|
||||
|
||||
const KEY = "markmag"
|
||||
const BASE = "https://brain.sidaocai.cn/markmag/"
|
||||
const CSS = ".mm-wrap{\n --ink:var(--dsw-alias-label-primary,#111);\n --ink2:var(--dsw-alias-label-secondary,#555);\n --ink3:var(--dsw-alias-label-tertiary,#888);\n --ink4:var(--dsw-alias-label-caption,#aaa);\n --line:var(--dsw-alias-border-l2,rgba(0,0,0,.1));\n --line2:var(--dsw-alias-border-l4,rgba(0,0,0,.16));\n --card:var(--dsw-alias-bg-layer-2,#fff);\n --bg:var(--dsw-alias-bg-base,#f7f7f8);\n --hover:var(--dsw-alias-interactive-bg-hover,rgba(0,0,0,.04));\n --primary:var(--dsw-alias-button-primary-fill,#2E6BFF);\n --primary-hover:var(--dsw-alias-button-primary-hover,#4D82FF);\n --on-primary:var(--dsw-alias-label-primary-inverted,#fff);\n --ok:var(--dsw-alias-state-success-primary,#10B981);\n --warn:var(--dsw-alias-state-warn-primary,#D9A406);\n --err:var(--dsw-alias-state-error-primary,#E5484D);\n --info:var(--dsw-alias-state-business-primary,#2E6BFF);\n --idle:var(--dsw-alias-state-idle-primary,#9aa2ad);\n --r-sm:var(--dsw-radius-sm,8px);\n --r-md:var(--dsw-radius-md,12px);\n --r-xl:var(--dsw-radius-xl,20px);\n height:100%;overflow:auto;background:var(--bg);color:var(--ink);\n font-family:-apple-system,BlinkMacSystemFont,\"PingFang SC\",\"Microsoft YaHei\",sans-serif;\n font-size:13px;line-height:1.5;-webkit-font-smoothing:antialiased;\n}\n.mm-inner{max-width:1000px;margin:0 auto;padding:20px 22px 48px}\n.mm-head{display:flex;align-items:center;gap:11px;margin-bottom:14px}\n.mm-logo{width:32px;height:32px;border-radius:var(--r-md);flex:none;display:grid;place-items:center;\n background:var(--primary);color:var(--on-primary)}\n.mm-title{font-size:15.5px;font-weight:650;letter-spacing:.01em}\n.mm-sub{font-size:11.5px;color:var(--ink4);margin-top:2px}\n.mm-actions{margin-left:auto;display:flex;align-items:center;gap:8px;flex:none}\n.mm-btn{border:1px solid var(--line);background:transparent;color:var(--ink2);\n border-radius:var(--r-sm);padding:5px 11px;font-size:12px;cursor:pointer;transition:.15s;\n white-space:nowrap;font-family:inherit}\n.mm-btn:hover{background:var(--hover);color:var(--ink);border-color:var(--line2)}\n.mm-btn:disabled{cursor:default;opacity:.6}\n.mm-btn-primary{background:var(--primary);border-color:transparent;color:var(--on-primary);font-weight:560}\n.mm-btn-primary:hover{background:var(--primary-hover);color:var(--on-primary)}\n.mm-nav{display:flex;gap:4px;border-bottom:1px solid var(--line);margin-bottom:16px}\n.mm-nav-i{border:none;background:transparent;color:var(--ink3);font-size:13px;font-family:inherit;\n padding:8px 12px;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;transition:.15s;\n display:flex;align-items:center;gap:6px}\n.mm-nav-i:hover{color:var(--ink)}\n.mm-nav-on{color:var(--primary);border-bottom-color:var(--primary);font-weight:560}\n.mm-nav-c{font-size:10.5px;background:var(--hover);border-radius:999px;padding:0 6px;color:var(--ink3);\n font-variant-numeric:tabular-nums}\n.mm-nav-on .mm-nav-c{background:color-mix(in srgb,var(--primary) 16%,transparent);color:var(--primary)}\n.mm-stats{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:20px}\n.mm-stat{background:var(--card);border:1px solid var(--line);border-radius:var(--r-xl);padding:15px 17px}\n.mm-stat-n{font-size:26px;font-weight:660;letter-spacing:-.02em;line-height:1.1;font-variant-numeric:tabular-nums}\n.mm-stat-l{font-size:11.5px;color:var(--ink3);margin-top:4px}\n.mm-card{background:var(--card);border:1px solid var(--line);border-radius:var(--r-xl);overflow:hidden}\n.mm-row{display:flex;align-items:center;gap:11px;padding:10px 15px;border-top:1px solid var(--line);transition:background .12s}\n.mm-row:first-child{border-top:none}\n.mm-row:hover{background:var(--hover)}\n.mm-dot{width:7px;height:7px;border-radius:50%;flex:none}\n.mm-dot-ok{background:var(--ok)}\n.mm-dot-warn{background:var(--warn)}\n.mm-dot-err{background:var(--err)}\n.mm-dot-idle{background:var(--idle)}\n.mm-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink)}\n.mm-meta{font-size:11.5px;color:var(--ink3);flex:none;white-space:nowrap}\n.mm-date{font-family:ui-monospace,\"SF Mono\",Menlo,monospace;font-size:11.5px;color:var(--ink4);\n flex:none;font-variant-numeric:tabular-nums}\n.mm-date-late{color:var(--err)}\n.mm-badge{font-size:11px;font-weight:560;padding:2px 8px;border-radius:var(--r-sm);flex:none;white-space:nowrap}\n.mm-b-todo{background:var(--hover);color:var(--ink2)}\n.mm-b-doing{background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}\n.mm-b-blocked{background:color-mix(in srgb,var(--err) 14%,transparent);color:var(--err)}\n.mm-b-done{background:color-mix(in srgb,var(--ok) 14%,transparent);color:var(--ok)}\n.mm-empty{padding:24px 16px;text-align:center;color:var(--ink4);font-size:12.5px}\n.mm-err{background:color-mix(in srgb,var(--err) 10%,transparent);border:1px solid var(--err);\n color:var(--err);border-radius:var(--r-md);padding:10px 13px;font-size:12.5px;margin-bottom:16px}\n.mm-Line truncated
|
||||
|
||||
const HEALTH_CLASS = { green: "mm-dot-ok", yellow: "mm-dot-warn", amber: "mm-dot-warn", red: "mm-dot-err" }
|
||||
const HEALTH_TXT = { green: "健康", yellow: "注意", amber: "注意", red: "异常" }
|
||||
const STATUS = {
|
||||
todo: ["待办", "mm-b-todo"],
|
||||
doing: ["进行中", "mm-b-doing"],
|
||||
blocked: ["受阻", "mm-b-blocked"],
|
||||
done: ["已完成", "mm-b-done"],
|
||||
}
|
||||
const FILTERS = [["", "全部"], ["todo", "待办"], ["doing", "进行中"], ["blocked", "受阻"]]
|
||||
|
||||
function pad2(n) { return String(n).padStart(2, "0") }
|
||||
function todayStr() {
|
||||
const d = new Date()
|
||||
return d.getFullYear() + "-" + pad2(d.getMonth() + 1) + "-" + pad2(d.getDate())
|
||||
}
|
||||
function openInMarkmag(hash) { window.open(BASE + (hash || ""), "_blank", "noopener") }
|
||||
|
||||
async function postJson(url, body) {
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
method: "POST",
|
||||
credentials: "same-origin",
|
||||
headers: { "content-type": "application/json" },
|
||||
body: JSON.stringify(body || {}),
|
||||
})
|
||||
return await res.json()
|
||||
} catch (e) {
|
||||
return { ok: false, err: "请求失败:" + (e.message || e) }
|
||||
}
|
||||
}
|
||||
|
||||
function Icon(props) {
|
||||
const size = (props && props.size) || 20
|
||||
return h("svg", {
|
||||
width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor",
|
||||
strokeWidth: 1.9, strokeLinecap: "round", strokeLinejoin: "round",
|
||||
},
|
||||
h("rect", { x: 3, y: 4.5, width: 18, height: 15, rx: 2.5 }),
|
||||
h("path", { d: "M7.5 9.5h9" }),
|
||||
h("path", { d: "M7.5 13.5h5.5" })
|
||||
)
|
||||
}
|
||||
|
||||
function Logo() {
|
||||
return h("div", { className: "mm-logo" },
|
||||
h("svg", {
|
||||
width: 17, height: 17, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor",
|
||||
strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round",
|
||||
},
|
||||
h("rect", { x: 3.5, y: 5, width: 17, height: 14, rx: 2.5 }),
|
||||
h("path", { d: "M8 10h8" }),
|
||||
h("path", { d: "M8 14h4.5" })
|
||||
))
|
||||
}
|
||||
|
||||
function Badge(props) {
|
||||
const st = STATUS[props.status] || [props.status || "", "mm-b-todo"]
|
||||
return h("span", { className: "mm-badge " + st[1] }, st[0])
|
||||
}
|
||||
|
||||
function Skeleton() {
|
||||
return [0, 1, 2].map(function (i) {
|
||||
return h("div", { key: i, className: "mm-row" },
|
||||
h("div", { className: "mm-sk", style: { width: (150 + i * 60) + "px" } }))
|
||||
})
|
||||
}
|
||||
|
||||
function Panel() {
|
||||
const sMe = useState(null), me = sMe[0], setMe = sMe[1]
|
||||
const sTasks = useState([]), tasks = sTasks[0], setTasks = sTasks[1]
|
||||
const sProjects = useState([]), projects = sProjects[0], setProjects = sProjects[1]
|
||||
const sErr = useState(""), err = sErr[0], setErr = sErr[1]
|
||||
const sNote = useState(""), note = sNote[0], setNote = sNote[1]
|
||||
const sLoading = useState(true), loading = sLoading[0], setLoading = sLoading[1]
|
||||
const sAt = useState(""), at = sAt[0], setAt = sAt[1]
|
||||
const sTab = useState("mine"), tab = sTab[0], setTab = sTab[1]
|
||||
const sFilter = useState(""), filter = sFilter[0], setFilter = sFilter[1]
|
||||
const sUrgent = useState(false), urgent = sUrgent[0], setUrgent = sUrgent[1]
|
||||
const sBusy = useState(0), busy = sBusy[0], setBusy = sBusy[1]
|
||||
const sEditing = useState(0), editing = sEditing[0], setEditing = sEditing[1]
|
||||
const sNew = useState(false), showNew = sNew[0], setShowNew = sNew[1]
|
||||
const sForm = useState({ title: "", due: "", project: "" }), form = sForm[0], setForm = sForm[1]
|
||||
|
||||
const load = useCallback(function () {
|
||||
setLoading(true)
|
||||
setErr("")
|
||||
Promise.all([
|
||||
fetch("/__markmag/me", { credentials: "same-origin" }).then(function (r) { return r.json() }),
|
||||
fetch("/__markmag/tasks", { credentials: "same-origin" }).then(function (r) { return r.json() }),
|
||||
fetch("/__markmag/projects", { credentials: "same-origin" }).then(function (r) { return r.json() }),
|
||||
]).then(function (res) {
|
||||
const m = res[0], t = res[1], p = res[2]
|
||||
if (m && m.ok && m.result) setMe(m.result)
|
||||
else if (m && !m.ok) throw new Error(m.err || "读取身份失败")
|
||||
setTasks(t && t.ok && t.result && t.result.tasks ? t.result.tasks : [])
|
||||
setProjects(p && p.ok && p.result && p.result.projects ? p.result.projects : [])
|
||||
setAt(new Date().toLocaleTimeString("zh-CN", { hour: "2-digit", minute: "2-digit" }))
|
||||
}).catch(function (e) {
|
||||
setErr(e.message || String(e))
|
||||
}).then(function () {
|
||||
setLoading(false)
|
||||
})
|
||||
}, [])
|
||||
|
||||
useEffect(function () { load() }, [load])
|
||||
|
||||
// ── 写操作:都落到弹匣同一套 store,成功后重新拉一遍 ──
|
||||
async function doToggle(t) {
|
||||
setBusy(t.id); setErr(""); setNote("")
|
||||
const r = await postJson("/__markmag/task/toggle", { id: t.id })
|
||||
setBusy(0)
|
||||
if (r && r.ok) {
|
||||
const st = r.result && r.result.status
|
||||
setNote((st === "done" ? "已完成:" : "状态:" + (STATUS[st] ? STATUS[st][0] : st) + " ") + t.title)
|
||||
load()
|
||||
} else setErr((r && r.err) || "操作失败")
|
||||
}
|
||||
|
||||
async function doSetDue(t, due) {
|
||||
setEditing(0); setErr(""); setNote("")
|
||||
if (!due || due === t.due) return
|
||||
setBusy(t.id)
|
||||
const r = await postJson("/__markmag/task/update", { id: t.id, patch: { due: due } })
|
||||
setBusy(0)
|
||||
if (r && r.ok) { setNote("截止日已改为 " + due + ":" + t.title); load() }
|
||||
else setErr((r && r.err) || "改期失败")
|
||||
}
|
||||
|
||||
async function doCreate() {
|
||||
const title = (form.title || "").trim()
|
||||
if (!title) { setErr("先写个任务标题"); return }
|
||||
setBusy(-1); setErr(""); setNote("")
|
||||
const payload = { title: title }
|
||||
if (form.due) payload.due = form.due
|
||||
if (form.project) payload.project = form.project
|
||||
const r = await postJson("/__markmag/task/create", payload)
|
||||
setBusy(0)
|
||||
if (r && r.ok) {
|
||||
setNote("已建任务:" + title)
|
||||
setForm({ title: "", due: "", project: "" })
|
||||
setShowNew(false)
|
||||
load()
|
||||
} else setErr((r && r.err) || "建任务失败")
|
||||
}
|
||||
|
||||
const today = todayStr()
|
||||
const myName = (me && me.name) || ""
|
||||
const myRole = (me && me.role) || "member"
|
||||
const scopeLabel = myRole === "admin" ? "全团队" : (myRole === "dept_admin" ? "本部门" : "部门可见")
|
||||
|
||||
const mine = useMemo(function () {
|
||||
return tasks.filter(function (t) { return t.owner === myName || t.created_by === myName })
|
||||
}, [tasks, myName])
|
||||
|
||||
const openTasks = useMemo(function () {
|
||||
return tasks.filter(function (t) { return t.status !== "done" })
|
||||
}, [tasks])
|
||||
|
||||
const focus = useMemo(function () {
|
||||
return openTasks.filter(function (t) { return t.due && t.due <= today })
|
||||
.sort(function (a, b) { return a.due < b.due ? -1 : 1 })
|
||||
}, [openTasks, today])
|
||||
|
||||
const overdueCount = useMemo(function () {
|
||||
return openTasks.filter(function (t) { return t.due && t.due < today }).length
|
||||
}, [openTasks, today])
|
||||
|
||||
const base = tab === "mine" ? mine.filter(function (t) { return t.status !== "done" }) : openTasks
|
||||
const shown = useMemo(function () {
|
||||
let list = base
|
||||
if (urgent) list = list.filter(function (t) { return t.due && t.due < today })
|
||||
if (filter) list = list.filter(function (t) { return t.status === filter })
|
||||
return list.slice().sort(function (a, b) {
|
||||
if (!a.due && !b.due) return 0
|
||||
if (!a.due) return 1
|
||||
if (!b.due) return -1
|
||||
return a.due < b.due ? -1 : 1
|
||||
})
|
||||
}, [base, urgent, filter, today])
|
||||
|
||||
/** 一行任务:徽章 + 标题 + 负责人 + 日期(可改)+ hover 操作(完成/改期/去弹匣) */
|
||||
function TaskLine(t) {
|
||||
const late = t.due && t.due < today
|
||||
const isEditing = editing === t.id
|
||||
const ops = h("div", { className: "mm-row-ops" },
|
||||
h("button", {
|
||||
className: "mm-op mm-op-done",
|
||||
disabled: busy === t.id,
|
||||
onClick: function (e) { e.stopPropagation(); doToggle(t) },
|
||||
}, t.status === "done" ? "重开" : "完成"),
|
||||
h("button", {
|
||||
className: "mm-op",
|
||||
onClick: function (e) { e.stopPropagation(); setEditing(isEditing ? 0 : t.id) },
|
||||
}, "改期"),
|
||||
h("button", {
|
||||
className: "mm-op",
|
||||
onClick: function (e) { e.stopPropagation(); openInMarkmag("#today") },
|
||||
}, "弹匣"))
|
||||
const dateEl = isEditing
|
||||
? h("input", {
|
||||
className: "mm-date-in",
|
||||
type: "date",
|
||||
defaultValue: t.due || today,
|
||||
autoFocus: true,
|
||||
onClick: function (e) { e.stopPropagation() },
|
||||
onChange: function (e) { doSetDue(t, e.target.value) },
|
||||
onBlur: function () { setEditing(0) },
|
||||
})
|
||||
: h("span", {
|
||||
className: "mm-date mm-date-edit" + (late ? " mm-date-late" : ""),
|
||||
style: { width: 70, textAlign: "right" },
|
||||
onClick: function (e) { e.stopPropagation(); setEditing(t.id) },
|
||||
}, t.due || "设日期")
|
||||
return h("div", {
|
||||
key: t.id,
|
||||
className: "mm-row mm-row-click",
|
||||
onClick: function () { openInMarkmag("#today") },
|
||||
},
|
||||
h(Badge, { status: t.status }),
|
||||
h("span", { className: "mm-name" }, t.title),
|
||||
h("span", { className: "mm-meta", style: { flex: "none" } }, t.owner || ""),
|
||||
dateEl,
|
||||
ops)
|
||||
}
|
||||
|
||||
const focusEl = focus.length
|
||||
? h("div", { className: "mm-focus" },
|
||||
h("div", { className: "mm-focus-h" },
|
||||
h("span", { className: "mm-focus-t" },
|
||||
overdueCount ? "要处理:" + overdueCount + " 项已逾期" : "今天到期"),
|
||||
h("span", { className: "mm-focus-c" }, "可直接完成或改期")),
|
||||
focus.slice(0, 6).map(function (t) { return TaskLine(t) }))
|
||||
: null
|
||||
|
||||
const statsEl = h("div", { className: "mm-stats" },
|
||||
h("div", { className: "mm-stat", style: { cursor: "pointer" },
|
||||
onClick: function () { setTab("scope"); setUrgent(false); setFilter("") } },
|
||||
h("div", { className: "mm-stat-n" }, String(mine.filter(function (t) { return t.status !== "done" }).length)),
|
||||
h("div", { className: "mm-stat-l" }, "我的未完成")),
|
||||
h("div", { className: "mm-stat", style: { cursor: "pointer" },
|
||||
onClick: function () { setTab("scope"); setUrgent(true); setFilter("") } },
|
||||
h("div", { className: "mm-stat-n", style: overdueCount ? { color: "var(--err)" } : null }, String(overdueCount)),
|
||||
h("div", { className: "mm-stat-l" }, "已逾期")),
|
||||
h("div", { className: "mm-stat", style: { cursor: "pointer" },
|
||||
onClick: function () { openInMarkmag("#proj") } },
|
||||
h("div", { className: "mm-stat-n" }, String(projects.length)),
|
||||
h("div", { className: "mm-stat-l" }, "项目")))
|
||||
|
||||
const tabsEl = h("div", { className: "mm-actions-2" },
|
||||
[["mine", "我的"], ["scope", scopeLabel]].map(function (item) {
|
||||
const k = item[0], label = item[1]
|
||||
return h("button", {
|
||||
key: k,
|
||||
className: "mm-tab" + (tab === k ? " mm-tab-on" : ""),
|
||||
onClick: function () { setTab(k); setUrgent(false) },
|
||||
}, label)
|
||||
}),
|
||||
h("span", { style: { flex: 1 } }),
|
||||
urgent ? h("button", { className: "mm-tab mm-tab-on", onClick: function () { setUrgent(false) } }, "只看逾期 ×") : null)
|
||||
|
||||
const filtersEl = h("div", { className: "mm-actions-2" },
|
||||
FILTERS.map(function (f) {
|
||||
const v = f[0], label = f[1]
|
||||
return h("button", {
|
||||
key: "f" + v,
|
||||
className: "mm-tab" + (filter === v ? " mm-tab-on" : ""),
|
||||
onClick: function () { setFilter(v) },
|
||||
}, label)
|
||||
}))
|
||||
|
||||
const taskRows = shown.length
|
||||
? shown.map(function (t) { return TaskLine(t) })
|
||||
: (loading
|
||||
? h(Skeleton)
|
||||
: h("div", { className: "mm-empty-hint" },
|
||||
tab === "mine" ? "你手上没有到期任务" : "这个范围里没有任务"))
|
||||
|
||||
const projectOptions = projects.map(function (p) {
|
||||
return h("option", { key: p.id, value: p.id }, p.name)
|
||||
})
|
||||
|
||||
const newEl = h("div", { className: "mm-new" },
|
||||
showNew
|
||||
? h("div", { className: "mm-card" },
|
||||
h("div", { className: "mm-new-row" },
|
||||
h("input", {
|
||||
className: "mm-in mm-in-t",
|
||||
placeholder: "任务标题",
|
||||
value: form.title,
|
||||
autoFocus: true,
|
||||
onChange: function (e) { setForm(Object.assign({}, form, { title: e.target.value })) },
|
||||
onKeyDown: function (e) { if (e.key === "Enter") doCreate() },
|
||||
}),
|
||||
h("input", {
|
||||
className: "mm-in mm-in-d",
|
||||
type: "date",
|
||||
value: form.due,
|
||||
onChange: function (e) { setForm(Object.assign({}, form, { due: e.target.value })) },
|
||||
}),
|
||||
h("select", {
|
||||
className: "mm-in mm-in-s",
|
||||
value: form.project,
|
||||
onChange: function (e) { setForm(Object.assign({}, form, { project: e.target.value })) },
|
||||
}, h("option", { value: "" }, "不挂项目"), projectOptions),
|
||||
h("button", {
|
||||
className: "mm-btn mm-btn-primary",
|
||||
disabled: busy === -1,
|
||||
onClick: doCreate,
|
||||
}, busy === -1 ? "提交中…" : "建任务"),
|
||||
h("button", { className: "mm-btn", onClick: function () { setShowNew(false) } }, "取消")))
|
||||
: h("button", {
|
||||
className: "mm-btn",
|
||||
style: { width: "100%" },
|
||||
onClick: function () { setShowNew(true); setNote("") },
|
||||
}, "+ 快速建任务"))
|
||||
|
||||
const projectCards = projects.length
|
||||
? projects.map(function (p, i) {
|
||||
const key = String(p.health || "").toLowerCase()
|
||||
const pct = typeof p.progress === "number" ? Math.max(0, Math.min(100, p.progress)) : null
|
||||
return h("div", {
|
||||
key: p.id || i,
|
||||
className: "mm-pcard",
|
||||
onClick: function () { openInMarkmag(p.id ? "#d/" + p.id : "#proj") },
|
||||
},
|
||||
h("div", { className: "mm-pcard-n" }, p.name),
|
||||
h("div", { className: "mm-pcard-m" },
|
||||
h("span", { className: "mm-dot " + (HEALTH_CLASS[key] || "mm-dot-idle") }),
|
||||
h("span", null, HEALTH_TXT[key] || "—"),
|
||||
p.stage ? h("span", null, "· " + p.stage) : null,
|
||||
p.owner ? h("span", null, "· " + p.owner) : null),
|
||||
pct === null ? null : h("div", { className: "mm-bar" },
|
||||
h("div", { className: "mm-bar-i", style: { width: pct + "%" } })))
|
||||
})
|
||||
: h("div", { className: "mm-pcard" },
|
||||
h("div", { className: "mm-pcard-n" }, loading ? "读取中…" : "还没有项目"))
|
||||
|
||||
const identity = me
|
||||
? myName + (myRole === "admin" ? " · 团队负责人" : myRole === "dept_admin" ? " · 部门负责人" : "")
|
||||
: ""
|
||||
|
||||
return h("div", { className: "mm-wrap" },
|
||||
h("style", { dangerouslySetInnerHTML: { __html: CSS } }),
|
||||
h("div", { className: "mm-inner" },
|
||||
h("div", { className: "mm-head" },
|
||||
h(Logo),
|
||||
h("div", null,
|
||||
h("div", { className: "mm-title" }, "弹匣工作台"),
|
||||
h("div", { className: "mm-sub" }, identity || (at ? "数据更新于 " + at : "四道菜 · 团队作战台"))),
|
||||
h("div", { className: "mm-actions" },
|
||||
h("button", { className: "mm-btn", onClick: load, disabled: loading },
|
||||
loading ? "读取中…" : "刷新"),
|
||||
h("button", {
|
||||
className: "mm-btn mm-btn-primary",
|
||||
onClick: function () { openInMarkmag("#today") },
|
||||
}, "弹匣全貌"))),
|
||||
|
||||
err ? h("div", { className: "mm-err" }, err) : null,
|
||||
note ? h("div", { className: "mm-ok" }, note) : null,
|
||||
focusEl,
|
||||
statsEl,
|
||||
|
||||
h("div", { className: "mm-sec" },
|
||||
h("div", { className: "mm-sec-h" },
|
||||
h("span", { className: "mm-sec-t" }, "任务"),
|
||||
h("span", { className: "mm-sec-c" }, String(shown.length))),
|
||||
tabsEl,
|
||||
filtersEl,
|
||||
h("div", { className: "mm-card" }, taskRows),
|
||||
newEl),
|
||||
|
||||
h("div", { className: "mm-sec" },
|
||||
h("div", { className: "mm-sec-h" },
|
||||
h("span", { className: "mm-sec-t" }, "项目"),
|
||||
h("span", { className: "mm-sec-c" }, String(projects.length))),
|
||||
h("div", { className: "mm-grid" }, projectCards)),
|
||||
|
||||
h("div", { className: "mm-foot" }, "悬停任务行可完成 / 改期 · 写操作与弹匣同一套规则")))
|
||||
}
|
||||
|
||||
function apply(ctx) {
|
||||
ctx.slots.inject("main", function () {
|
||||
return ctx.slots.register({ name: "main", key: KEY }, Panel)
|
||||
})
|
||||
ctx.effect(function () {
|
||||
let dispose = null
|
||||
function mount() {
|
||||
if (dispose) dispose()
|
||||
dispose = ctx.slots.inject("sidebar.panellist", function () {
|
||||
return ctx.slots.register(
|
||||
{ name: "sidebar.panellist", id: KEY, order: 6, label: function () { return "弹匣工作台" } },
|
||||
Icon
|
||||
)
|
||||
})
|
||||
}
|
||||
mount()
|
||||
return function () { if (dispose) dispose() }
|
||||
}, "dsh-markmag: sidebar entry")
|
||||
}
|
||||
|
||||
module.exports = { inject: ["slots"], apply: apply }
|
||||
return module.exports
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user