feat: read raw content
This commit is contained in:
@@ -6,14 +6,22 @@ const pager = usePageStore()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="hero bg-base-200">
|
||||
<div class="hero bg-base-200" v-if="pager.page !== 'raw'">
|
||||
<div class="hero-content text-center">
|
||||
<div class="max-w-md">
|
||||
<h1 class="text-5xl font-bold">Pastebin!</h1>
|
||||
<p class="py-6">本网站旨在用作各方之间粘贴信息的短期交换。提交的数据不保证是永久性的,并且可能随时被删除</p>
|
||||
<RouterLink :to="{name: pager.reversal()}" class="btn btn-primary">
|
||||
<span v-if="pager.reversal() === 'home'">首页</span>
|
||||
<span v-else>列表</span>
|
||||
<RouterLink :to="{name: 'list'}" class="btn btn-primary" v-if="pager.page === 'home'">
|
||||
列表
|
||||
</RouterLink>
|
||||
<RouterLink :to="{name: 'home'}" class="btn btn-primary" v-if="pager.page === 'list'">
|
||||
首页
|
||||
</RouterLink>
|
||||
<RouterLink :to="{name: 'home'}" class="btn btn-primary" v-if="pager.page === 'doc'">
|
||||
首页
|
||||
</RouterLink>
|
||||
<RouterLink :to="{name: 'list'}" class="btn btn-primary ml-2" v-if="pager.page === 'doc'">
|
||||
列表
|
||||
</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -119,6 +119,14 @@ export interface PastebinServiceGetResp {
|
||||
record: PastebinServiceRecord | undefined;
|
||||
}
|
||||
|
||||
export interface PastebinServiceRawReq {
|
||||
key: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
export interface PastebinServiceRawResp {
|
||||
}
|
||||
|
||||
function createBasePastebinServiceRecord(): PastebinServiceRecord {
|
||||
return {
|
||||
id: 0,
|
||||
@@ -279,18 +287,18 @@ export const PastebinServiceRecord = {
|
||||
|
||||
fromJSON(object: any): PastebinServiceRecord {
|
||||
return {
|
||||
id: isSet(object.id) ? Number(object.id) : 0,
|
||||
key: isSet(object.key) ? String(object.key) : "",
|
||||
title: isSet(object.title) ? String(object.title) : "",
|
||||
content: isSet(object.content) ? String(object.content) : "",
|
||||
created_at: isSet(object.createdAt) ? String(object.createdAt) : "",
|
||||
expired_at: isSet(object.expiredAt) ? String(object.expiredAt) : "",
|
||||
need_password: isSet(object.needPassword) ? Boolean(object.needPassword) : false,
|
||||
editable: isSet(object.editable) ? Boolean(object.editable) : false,
|
||||
id: isSet(object.id) ? globalThis.Number(object.id) : 0,
|
||||
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
||||
title: isSet(object.title) ? globalThis.String(object.title) : "",
|
||||
content: isSet(object.content) ? globalThis.String(object.content) : "",
|
||||
created_at: isSet(object.createdAt) ? globalThis.String(object.createdAt) : "",
|
||||
expired_at: isSet(object.expiredAt) ? globalThis.String(object.expiredAt) : "",
|
||||
need_password: isSet(object.needPassword) ? globalThis.Boolean(object.needPassword) : false,
|
||||
editable: isSet(object.editable) ? globalThis.Boolean(object.editable) : false,
|
||||
expire_level: isSet(object.expireLevel) ? expireLevelFromJSON(object.expireLevel) : 0,
|
||||
password: isSet(object.password) ? String(object.password) : "",
|
||||
lang: isSet(object.lang) ? String(object.lang) : "",
|
||||
author: isSet(object.author) ? String(object.author) : "",
|
||||
password: isSet(object.password) ? globalThis.String(object.password) : "",
|
||||
lang: isSet(object.lang) ? globalThis.String(object.lang) : "",
|
||||
author: isSet(object.author) ? globalThis.String(object.author) : "",
|
||||
};
|
||||
},
|
||||
|
||||
@@ -403,8 +411,8 @@ export const PastebinServiceListReq = {
|
||||
|
||||
fromJSON(object: any): PastebinServiceListReq {
|
||||
return {
|
||||
page_size: isSet(object.pageSize) ? Number(object.pageSize) : 0,
|
||||
current_page: isSet(object.currentPage) ? Number(object.currentPage) : 0,
|
||||
page_size: isSet(object.pageSize) ? globalThis.Number(object.pageSize) : 0,
|
||||
current_page: isSet(object.currentPage) ? globalThis.Number(object.currentPage) : 0,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -477,8 +485,10 @@ export const PastebinServiceListResp = {
|
||||
|
||||
fromJSON(object: any): PastebinServiceListResp {
|
||||
return {
|
||||
items: Array.isArray(object?.items) ? object.items.map((e: any) => PastebinServiceRecord.fromJSON(e)) : [],
|
||||
has_more: isSet(object.hasMore) ? Boolean(object.hasMore) : false,
|
||||
items: globalThis.Array.isArray(object?.items)
|
||||
? object.items.map((e: any) => PastebinServiceRecord.fromJSON(e))
|
||||
: [],
|
||||
has_more: isSet(object.hasMore) ? globalThis.Boolean(object.hasMore) : false,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -755,8 +765,8 @@ export const PastebinServiceGetReq = {
|
||||
|
||||
fromJSON(object: any): PastebinServiceGetReq {
|
||||
return {
|
||||
key: isSet(object.key) ? String(object.key) : "",
|
||||
password: isSet(object.password) ? String(object.password) : "",
|
||||
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
||||
password: isSet(object.password) ? globalThis.String(object.password) : "",
|
||||
};
|
||||
},
|
||||
|
||||
@@ -841,6 +851,123 @@ export const PastebinServiceGetResp = {
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePastebinServiceRawReq(): PastebinServiceRawReq {
|
||||
return { key: "", password: "" };
|
||||
}
|
||||
|
||||
export const PastebinServiceRawReq = {
|
||||
encode(message: PastebinServiceRawReq, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
if (message.key !== "") {
|
||||
writer.uint32(10).string(message.key);
|
||||
}
|
||||
if (message.password !== "") {
|
||||
writer.uint32(18).string(message.password);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceRawReq {
|
||||
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePastebinServiceRawReq();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
case 1:
|
||||
if (tag !== 10) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.key = reader.string();
|
||||
continue;
|
||||
case 2:
|
||||
if (tag !== 18) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.password = reader.string();
|
||||
continue;
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skipType(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(object: any): PastebinServiceRawReq {
|
||||
return {
|
||||
key: isSet(object.key) ? globalThis.String(object.key) : "",
|
||||
password: isSet(object.password) ? globalThis.String(object.password) : "",
|
||||
};
|
||||
},
|
||||
|
||||
toJSON(message: PastebinServiceRawReq): unknown {
|
||||
const obj: any = {};
|
||||
if (message.key !== "") {
|
||||
obj.key = message.key;
|
||||
}
|
||||
if (message.password !== "") {
|
||||
obj.password = message.password;
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<PastebinServiceRawReq>, I>>(base?: I): PastebinServiceRawReq {
|
||||
return PastebinServiceRawReq.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<PastebinServiceRawReq>, I>>(object: I): PastebinServiceRawReq {
|
||||
const message = createBasePastebinServiceRawReq();
|
||||
message.key = object.key ?? "";
|
||||
message.password = object.password ?? "";
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
function createBasePastebinServiceRawResp(): PastebinServiceRawResp {
|
||||
return {};
|
||||
}
|
||||
|
||||
export const PastebinServiceRawResp = {
|
||||
encode(_: PastebinServiceRawResp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
||||
return writer;
|
||||
},
|
||||
|
||||
decode(input: _m0.Reader | Uint8Array, length?: number): PastebinServiceRawResp {
|
||||
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
||||
let end = length === undefined ? reader.len : reader.pos + length;
|
||||
const message = createBasePastebinServiceRawResp();
|
||||
while (reader.pos < end) {
|
||||
const tag = reader.uint32();
|
||||
switch (tag >>> 3) {
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
}
|
||||
reader.skipType(tag & 7);
|
||||
}
|
||||
return message;
|
||||
},
|
||||
|
||||
fromJSON(_: any): PastebinServiceRawResp {
|
||||
return {};
|
||||
},
|
||||
|
||||
toJSON(_: PastebinServiceRawResp): unknown {
|
||||
const obj: any = {};
|
||||
return obj;
|
||||
},
|
||||
|
||||
create<I extends Exact<DeepPartial<PastebinServiceRawResp>, I>>(base?: I): PastebinServiceRawResp {
|
||||
return PastebinServiceRawResp.fromPartial(base ?? ({} as any));
|
||||
},
|
||||
fromPartial<I extends Exact<DeepPartial<PastebinServiceRawResp>, I>>(_: I): PastebinServiceRawResp {
|
||||
const message = createBasePastebinServiceRawResp();
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* @route_group: true
|
||||
* @base_url: /v1/pastebin
|
||||
@@ -875,6 +1002,13 @@ export interface PastebinService {
|
||||
* @api: /get
|
||||
*/
|
||||
Get(request: PastebinServiceGetReq): Promise<PastebinServiceGetResp>;
|
||||
/**
|
||||
* @desc: 获取原文内容
|
||||
* @author: Young Xu
|
||||
* @method: GET
|
||||
* @api: /raw
|
||||
*/
|
||||
Raw(request: PastebinServiceRawReq): Promise<PastebinServiceRawResp>;
|
||||
}
|
||||
|
||||
export const PastebinServiceServiceName = "api_services.v1.PastebinService";
|
||||
@@ -888,6 +1022,7 @@ export class PastebinServiceClientImpl implements PastebinService {
|
||||
this.Add = this.Add.bind(this);
|
||||
this.Update = this.Update.bind(this);
|
||||
this.Get = this.Get.bind(this);
|
||||
this.Raw = this.Raw.bind(this);
|
||||
}
|
||||
List(request: PastebinServiceListReq): Promise<PastebinServiceListResp> {
|
||||
const data = PastebinServiceListReq.encode(request).finish();
|
||||
@@ -912,35 +1047,23 @@ export class PastebinServiceClientImpl implements PastebinService {
|
||||
const promise = this.rpc.request(this.service, "Get", data);
|
||||
return promise.then((data) => PastebinServiceGetResp.decode(_m0.Reader.create(data)));
|
||||
}
|
||||
|
||||
Raw(request: PastebinServiceRawReq): Promise<PastebinServiceRawResp> {
|
||||
const data = PastebinServiceRawReq.encode(request).finish();
|
||||
const promise = this.rpc.request(this.service, "Raw", data);
|
||||
return promise.then((data) => PastebinServiceRawResp.decode(_m0.Reader.create(data)));
|
||||
}
|
||||
}
|
||||
|
||||
interface Rpc {
|
||||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
||||
}
|
||||
|
||||
declare const self: any | undefined;
|
||||
declare const window: any | undefined;
|
||||
declare const global: any | undefined;
|
||||
const tsProtoGlobalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") {
|
||||
return globalThis;
|
||||
}
|
||||
if (typeof self !== "undefined") {
|
||||
return self;
|
||||
}
|
||||
if (typeof window !== "undefined") {
|
||||
return window;
|
||||
}
|
||||
if (typeof global !== "undefined") {
|
||||
return global;
|
||||
}
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin ? T
|
||||
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
@@ -949,8 +1072,8 @@ export type Exact<P, I extends P> = P extends Builtin ? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
||||
|
||||
function longToNumber(long: Long): number {
|
||||
if (long.gt(Number.MAX_SAFE_INTEGER)) {
|
||||
throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
||||
if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
|
||||
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
||||
}
|
||||
return long.toNumber();
|
||||
}
|
||||
|
||||
@@ -179,17 +179,17 @@ export const ModelPastebin = {
|
||||
|
||||
fromJSON(object: any): ModelPastebin {
|
||||
return {
|
||||
id: isSet(object.id) ? Number(object.id) : 0,
|
||||
created_at: isSet(object.createdAt) ? Number(object.createdAt) : 0,
|
||||
expired_at: isSet(object.expiredAt) ? Number(object.expiredAt) : 0,
|
||||
short_id: isSet(object.shortId) ? String(object.shortId) : "",
|
||||
title: isSet(object.title) ? String(object.title) : "",
|
||||
author: isSet(object.author) ? String(object.author) : "",
|
||||
content: isSet(object.content) ? String(object.content) : "",
|
||||
lang: isSet(object.lang) ? String(object.lang) : "",
|
||||
password: isSet(object.password) ? String(object.password) : "",
|
||||
need_password: isSet(object.needPassword) ? Boolean(object.needPassword) : false,
|
||||
editable: isSet(object.editable) ? Boolean(object.editable) : false,
|
||||
id: isSet(object.id) ? globalThis.Number(object.id) : 0,
|
||||
created_at: isSet(object.createdAt) ? globalThis.Number(object.createdAt) : 0,
|
||||
expired_at: isSet(object.expiredAt) ? globalThis.Number(object.expiredAt) : 0,
|
||||
short_id: isSet(object.shortId) ? globalThis.String(object.shortId) : "",
|
||||
title: isSet(object.title) ? globalThis.String(object.title) : "",
|
||||
author: isSet(object.author) ? globalThis.String(object.author) : "",
|
||||
content: isSet(object.content) ? globalThis.String(object.content) : "",
|
||||
lang: isSet(object.lang) ? globalThis.String(object.lang) : "",
|
||||
password: isSet(object.password) ? globalThis.String(object.password) : "",
|
||||
need_password: isSet(object.needPassword) ? globalThis.Boolean(object.needPassword) : false,
|
||||
editable: isSet(object.editable) ? globalThis.Boolean(object.editable) : false,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -251,29 +251,11 @@ export const ModelPastebin = {
|
||||
},
|
||||
};
|
||||
|
||||
declare const self: any | undefined;
|
||||
declare const window: any | undefined;
|
||||
declare const global: any | undefined;
|
||||
const tsProtoGlobalThis: any = (() => {
|
||||
if (typeof globalThis !== "undefined") {
|
||||
return globalThis;
|
||||
}
|
||||
if (typeof self !== "undefined") {
|
||||
return self;
|
||||
}
|
||||
if (typeof window !== "undefined") {
|
||||
return window;
|
||||
}
|
||||
if (typeof global !== "undefined") {
|
||||
return global;
|
||||
}
|
||||
throw "Unable to locate global object";
|
||||
})();
|
||||
|
||||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
||||
|
||||
export type DeepPartial<T> = T extends Builtin ? T
|
||||
: T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
|
||||
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
||||
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: Partial<T>;
|
||||
|
||||
@@ -282,8 +264,8 @@ export type Exact<P, I extends P> = P extends Builtin ? P
|
||||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
||||
|
||||
function longToNumber(long: Long): number {
|
||||
if (long.gt(Number.MAX_SAFE_INTEGER)) {
|
||||
throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
||||
if (long.gt(globalThis.Number.MAX_SAFE_INTEGER)) {
|
||||
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
||||
}
|
||||
return long.toNumber();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,10 @@ import {useRouter} from "vue-router";
|
||||
const router = useRouter()
|
||||
let doc_id = ref(router.currentRoute.value.params.id);
|
||||
|
||||
import {usePageStore} from "@stores/counter";
|
||||
const pager = usePageStore()
|
||||
pager.change('doc')
|
||||
|
||||
import {get} from "@request/api";
|
||||
import {PastebinServiceGetResp, PastebinServiceRecord} from "@gen/api_services/v1/pastebin_module.ts";
|
||||
import {onMounted, reactive, ref} from "vue";
|
||||
@@ -28,6 +32,10 @@ async function document() {
|
||||
doc.instance = response.data.record as PastebinServiceRecord
|
||||
}
|
||||
|
||||
function getDocumentLink(key:string) {
|
||||
return "/v1/pastebin/raw?key="+key
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await document()
|
||||
})
|
||||
@@ -70,7 +78,7 @@ onMounted(async () => {
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="join grid grid-cols-2 content-center place-items-center mt-8">
|
||||
<button class="join-item btn btn-neutral self-auto">查看原文</button>
|
||||
<a :href="getDocumentLink(doc.instance.key)" class="join-item btn btn-neutral self-auto">查看原文</a>
|
||||
<button class="join-item btn btn-neutral self-auto" v-if="doc.instance.editable">编辑原文</button>
|
||||
<button class="join-item btn btn-neutral self-auto" v-else disabled>编辑原文</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user