'轻舟', 'site_description' => '实用工具与软件服务平台', 'icp' => '', 'grace_days' => '3', 'sms_register_creates_user' => '1', 'mail_enabled' => '0', ] as $key => $value) { Setting::query()->updateOrCreate(['key' => $key], ['value' => $value]); } $admin = User::query()->create([ 'nickname' => '舟管', 'password' => 'Admin123456', 'role' => 'super_admin', 'status' => 'active', ]); $admin->identities()->create(['type' => 'phone', 'identifier' => '13800138000', 'verified_at' => now()]); $admin->identities()->create(['type' => 'email', 'identifier' => 'admin@qingzhou.local', 'verified_at' => now()]); $user = User::query()->create([ 'nickname' => '体验用户', 'password' => 'User123456', 'role' => 'user', 'status' => 'active', ]); $user->identities()->create(['type' => 'phone', 'identifier' => '13900139000', 'verified_at' => now()]); $user->identities()->create(['type' => 'email', 'identifier' => 'user@qingzhou.local', 'verified_at' => now()]); $free = Plan::query()->create(['code' => 'free', 'name' => '免费', 'price_cents' => 0, 'period' => 'month', 'description' => '浏览平台并使用免费工具', 'sort' => 30, 'status' => 'published']); $member = Plan::query()->create(['code' => 'member', 'name' => '会员', 'price_cents' => 2900, 'period' => 'month', 'description' => '解锁会员工具和更高额度', 'sort' => 20, 'status' => 'published']); $enterprise = Plan::query()->create(['code' => 'enterprise', 'name' => '企业', 'price_cents' => 9900, 'period' => 'month', 'description' => '更高额度、优先支持和部署申请', 'sort' => 10, 'status' => 'published']); $free->entitlements()->create(['entitlement_key' => 'tool:notes:access', 'entitlement_value' => 'true']); foreach ([$member, $enterprise] as $plan) { $plan->entitlements()->create(['entitlement_key' => 'tool:notes:access', 'entitlement_value' => 'true']); $plan->entitlements()->create(['entitlement_key' => 'tool:convert:access', 'entitlement_value' => 'true']); } $member->entitlements()->create(['entitlement_key' => 'quota:convert:monthly', 'entitlement_value' => '200']); $enterprise->entitlements()->create(['entitlement_key' => 'quota:convert:monthly', 'entitlement_value' => '2000']); $enterprise->entitlements()->create(['entitlement_key' => 'support:priority', 'entitlement_value' => 'true']); $enterprise->entitlements()->create(['entitlement_key' => 'deploy:instance', 'entitlement_value' => 'true']); $office = Category::query()->create(['name' => '效率办公', 'slug' => 'office', 'icon' => '舟', 'sort' => 30, 'show_in_nav' => true, 'status' => 'published']); $media = Category::query()->create(['name' => '多媒体', 'slug' => 'media', 'icon' => '声', 'sort' => 20, 'show_in_nav' => true, 'status' => 'published']); $dev = Category::query()->create(['name' => '开发辅助', 'slug' => 'dev', 'icon' => '码', 'sort' => 10, 'show_in_nav' => true, 'status' => 'published']); $docs = Category::query()->create(['parent_id' => $dev->id, 'name' => '文档', 'slug' => 'docs', 'icon' => '册', 'sort' => 5, 'show_in_nav' => true, 'status' => 'published']); $tagNote = Tag::query()->create(['name' => '笔记', 'slug' => 'notes']); $tagAi = Tag::query()->create(['name' => '文本', 'slug' => 'text']); $tagDev = Tag::query()->create(['name' => '开发', 'slug' => 'dev']); $notes = $this->tool('轻舟记事', 'notes', '记', '登录后就能用的示例记事工具,用来验证统一账号。', 'integrated', 'http://127.0.0.1:8090/notes', 'PHP', 'free', null, true, [$office->id], [$tagNote->id]); $convert = $this->tool('轻舟转写', 'convert', '转', '会员可用的示例工具。未开通会员也能登录,付费功能会提示升级。', 'integrated', 'http://127.0.0.1:8090/convert', 'PHP', 'member', 'tool:convert:access', true, [$media->id], [$tagAi->id]); $vue = $this->tool('Vue 文档', 'vue-docs', 'V', '收录链接,只统计点击,不共享登录状态。', 'link', 'https://cn.vuejs.org/', null, 'free', null, false, [$docs->id], [$tagDev->id]); $laravel = $this->tool('Laravel 文档', 'laravel-docs', 'L', 'Laravel 框架文档。', 'link', 'https://laravel.com/docs/11.x', null, 'free', null, false, [$docs->id], [$tagDev->id]); $element = $this->tool('Element Plus', 'element-plus', 'E', 'Vue 3 组件库文档。', 'link', 'https://element-plus.org/zh-CN/', null, 'free', null, true, [$docs->id], [$tagDev->id]); $hot = HomeSection::query()->create(['title' => '热门推荐', 'slug' => 'hot', 'sort' => 30, 'display_limit' => 8, 'status' => 'published']); $hot->tools()->sync([$notes->id => ['sort' => 0], $convert->id => ['sort' => 1], $element->id => ['sort' => 2]]); $officeSection = HomeSection::query()->create(['title' => '效率办公', 'slug' => 'office', 'sort' => 20, 'display_limit' => 8, 'status' => 'published']); $officeSection->tools()->sync([$notes->id => ['sort' => 0]]); $devSection = HomeSection::query()->create(['title' => '开发辅助', 'slug' => 'dev', 'sort' => 10, 'display_limit' => 8, 'status' => 'published']); $devSection->tools()->sync([$vue->id => ['sort' => 0], $laravel->id => ['sort' => 1], $element->id => ['sort' => 2]]); $this->client('轻舟记事', 'qz_notes', 'demo-notes-secret', 'http://127.0.0.1:8090/callback/notes', $notes->id); $this->client('轻舟转写', 'qz_convert', 'demo-convert-secret', 'http://127.0.0.1:8090/callback/convert', $convert->id); Article::query()->create([ 'type' => 'announcement', 'title' => '轻舟开始内测', 'slug' => 'welcome', 'summary' => '一次登录,即可在已接入的工具间共用账号和会员权益。', 'body' => '
轻舟把多个在线工具收进同一套账号。打开接入工具时不需要再次输入密码。
', 'status' => 'published', 'published_at' => now(), ]); Article::query()->create([ 'type' => 'help', 'title' => '如何登录', 'slug' => 'how-to-login', 'summary' => '可以使用手机验证码,或邮箱、手机号加密码。', 'body' => '密码在浏览器里加密后再提交。本地调试时,短信验证码固定为 123456。
', 'status' => 'published', 'published_at' => now(), ]); Article::query()->create([ 'type' => 'help', 'title' => '会员如何生效', 'slug' => 'membership', 'summary' => '提交订单后,由运营确认收款并开通。', 'body' => '登录和会员是两件事。没有会员也可以进入工具,付费功能会提示升级。
', 'status' => 'published', 'published_at' => now(), ]); Agreement::query()->create(['type' => 'terms', 'title' => '用户协议', 'body' => '使用轻舟即表示你同意遵守平台规则,并不把账号出借给他人。
']); Agreement::query()->create(['type' => 'privacy', 'title' => '隐私政策', 'body' => '手机号和邮箱只用于登录与安全通知。工具默认拿不到你的手机号。
']); Navigation::query()->create(['group_name' => 'header', 'title' => '会员', 'link' => '/pricing', 'sort' => 20, 'status' => 'published']); Navigation::query()->create(['group_name' => 'header', 'title' => '帮助', 'link' => '/help', 'sort' => 10, 'status' => 'published']); Navigation::query()->create(['group_name' => 'footer', 'title' => '用户协议', 'link' => '/agreements/terms', 'sort' => 20, 'status' => 'published']); Navigation::query()->create(['group_name' => 'footer', 'title' => '隐私政策', 'link' => '/agreements/privacy', 'sort' => 10, 'status' => 'published']); } private function tool(string $name, string $slug, string $icon, string $summary, string $type, string $url, ?string $language, string $badge, ?string $entitlement, bool $recommended, array $categories, array $tags): Tool { $tool = Tool::query()->create([ 'name' => $name, 'slug' => $slug, 'icon' => $icon, 'summary' => $summary, 'content' => ''.$summary.'
', 'type' => $type, 'open_url' => $url, 'language' => $language, 'badge' => $badge, 'required_entitlement' => $entitlement, 'sort' => 10, 'is_recommended' => $recommended, 'status' => 'published', 'published_at' => now(), ]); $tool->categories()->sync($categories); $tool->tags()->sync($tags); return $tool; } private function client(string $name, string $clientId, string $secret, string $redirect, int $toolId): void { OauthClient::query()->create([ 'name' => $name, 'client_id' => $clientId, 'secret_hash' => hash('sha256', $secret), 'redirect_uris' => [$redirect], 'logout_uris' => ['http://127.0.0.1:8090/backchannel'], 'tool_id' => $toolId, 'is_first_party' => true, 'is_public' => false, 'status' => 'active', ]); } }