init
This commit is contained in:
parent
ad47674e0c
commit
8ef319ad48
|
@ -0,0 +1,24 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
|
@ -0,0 +1,61 @@
|
|||
import axios, { InternalAxiosRequestConfig, AxiosResponse } from "axios";
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { Config } from "./sdk";
|
||||
|
||||
// 创建 axios 实例
|
||||
const service = axios.create({
|
||||
baseURL: Config.BaseUrl,
|
||||
timeout: 50000,
|
||||
headers: {
|
||||
"Request-ID":uuidv4(),
|
||||
"Workspace":Config.Workspace,
|
||||
"Content-Type": "application/json;charset=utf-8"
|
||||
},
|
||||
});
|
||||
|
||||
// 请求拦截器
|
||||
service.interceptors.request.use(
|
||||
(config: InternalAxiosRequestConfig) => {
|
||||
const accessToken = localStorage.getItem("token");
|
||||
if (accessToken) {
|
||||
config.headers.Authorization = accessToken;
|
||||
}
|
||||
return config;
|
||||
},
|
||||
(error: any) => {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(
|
||||
(response: AxiosResponse) => {
|
||||
const { code, msg } = response.data;
|
||||
if (code === "00000") {
|
||||
return response.data;
|
||||
}
|
||||
// 响应数据为二进制流处理(Excel导出)
|
||||
if (response.data instanceof ArrayBuffer) {
|
||||
return response;
|
||||
}
|
||||
|
||||
// ElMessage.error(msg || "系统出错");
|
||||
return Promise.reject(new Error(msg || "Error"));
|
||||
},
|
||||
(error: any) => {
|
||||
if (error.response.data) {
|
||||
const { code, msg } = error.response.data;
|
||||
// token 过期,重新登录
|
||||
if (code === "A0230") {
|
||||
return Promise.reject(new Error(msg || "Error"));
|
||||
} else {
|
||||
// ElMessage.error(msg || "系统出错")
|
||||
return Promise.reject(new Error(msg || "Error"));
|
||||
}
|
||||
}
|
||||
return Promise.reject(error.message);
|
||||
}
|
||||
);
|
||||
|
||||
// 导出 axios 实例
|
||||
export default service;
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
export class Config {
|
||||
static BaseUrl: string; // 服务器地址
|
||||
static Workspace: string; // 工作空间
|
||||
|
||||
constructor(url:string,ws:string){
|
||||
Config.BaseUrl = url;
|
||||
Config.Workspace = ws;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
import request from "../../request";
|
||||
import { AxiosPromise } from "axios";
|
||||
import { ByPosRequest,ByPosReply } from "./types";
|
||||
|
||||
// 通过广告位获取广告信息
|
||||
export function ByPos(data: ByPosRequest): AxiosPromise<ByPosReply> {
|
||||
return request({
|
||||
url: "/ads.Fetch.ByPos",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
export interface ByPosRequest {
|
||||
key?: string; // ping码
|
||||
}
|
||||
|
||||
export interface ByPosReply {
|
||||
data?: AdsItem[];// 状态码
|
||||
}
|
||||
|
||||
export interface AdsItem {
|
||||
id?: number;
|
||||
title?: string;//广告名称
|
||||
content?: string;//广告内容
|
||||
number?: number;//广告类型 1.文本 2.图片 3.视频
|
||||
toUrl?: string;
|
||||
created?: string;
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import request from "../../request";
|
||||
import { AxiosPromise } from "axios";
|
||||
import { Crc,StatusReply } from "./types";
|
||||
|
||||
export function Hello(data: Crc): AxiosPromise<StatusReply> {
|
||||
return request({
|
||||
url: "/initialize.Check.Hello",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
export interface Crc {
|
||||
code?: string; // ping码
|
||||
}
|
||||
|
||||
export interface StatusReply {
|
||||
status?: number;// 状态码
|
||||
identity?: string; // 标识码
|
||||
message?: string; //状态说明
|
||||
timeseq?: number; // 响应时间序列
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
{
|
||||
"name": "javascript",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"devDependencies": {
|
||||
"axios": "^1.6.7",
|
||||
"uuid": "^9.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.6.7",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
|
||||
"integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.4",
|
||||
"form-data": "^4.0.0",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.5",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
|
||||
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
|
||||
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa",
|
||||
"https://github.com/sponsors/ctavan"
|
||||
],
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"axios": "^1.6.7",
|
||||
"uuid": "^9.0.1"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
syntax = "proto3";
|
||||
package ads;
|
||||
option go_package = "./ads";
|
||||
|
||||
//广告子系统
|
||||
service Fetch{
|
||||
//通过广告位获取广告信息
|
||||
rpc ByPos(ByPosRequest) returns (ByPosReply) {}
|
||||
}
|
||||
message ByPosRequest{
|
||||
string key = 1;
|
||||
}
|
||||
|
||||
message ByPosReply{
|
||||
repeated AdsItem data =1;
|
||||
}
|
||||
|
||||
message AdsItem{
|
||||
int64 id = 1;
|
||||
string title = 2;//广告名称
|
||||
string content = 3;//广告内容
|
||||
int32 type = 4;//广告类型 1.文本 2.图片 3.视频
|
||||
string toUrl = 5;
|
||||
string created = 6;
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
syntax = "proto3";
|
||||
package initialize;
|
||||
option go_package = "./;initialize";
|
||||
|
||||
|
||||
|
||||
// initialize-检测是否有新版或新的配置
|
||||
service Check{
|
||||
|
||||
// HELLO
|
||||
rpc Hello(Crc) returns (StatusReply){}
|
||||
|
||||
// 检查更新
|
||||
rpc Updates(CheckForUpdatesRequest) returns (CheckForUpdatesReply) {}
|
||||
|
||||
|
||||
}
|
||||
|
||||
message Crc{
|
||||
string code = 1;
|
||||
}
|
||||
|
||||
message StatusReply{
|
||||
int64 status = 1; // 状态码
|
||||
string identity=2; // 标识码
|
||||
string message=3; //状态说明
|
||||
int64 timeseq=4; // 响应时间序列
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
message CheckForUpdatesRequest {
|
||||
string app = 1; // 应用程序名称 <必填>
|
||||
string os = 2; // 操作系统 <必填>
|
||||
string arch = 3; // 构架名称 <必填>
|
||||
string version = 4; // 版本号 <必填>
|
||||
}
|
||||
|
||||
|
||||
message CheckForUpdatesReply {
|
||||
string identity = 1; // 唯一码
|
||||
string version = 2; // 版本号
|
||||
string summary = 3; // 更析说明
|
||||
string files = 4; // 更新文件以及文件hash
|
||||
string pubdate =5; // 发布时间
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
syntax = "proto3";
|
||||
package initialize;
|
||||
option go_package = "./;initialize";
|
||||
|
||||
|
||||
// initialize-数据
|
||||
service Data{
|
||||
|
||||
// 获取应用的相关配置信息
|
||||
rpc Configure(ConfigureRequest) returns (ConfigureReply) {}
|
||||
|
||||
// 系统区域数据
|
||||
rpc Areas(Empty) returns (AreasReply) {}
|
||||
|
||||
// 系统标签数据
|
||||
rpc Tags(Empty) returns (TagsReply) {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
message Empty{
|
||||
}
|
||||
|
||||
message ConfigureRequest {
|
||||
string app = 1; // 应用程序名称 <必填>
|
||||
string os = 2; // 操作系统 <必填>
|
||||
}
|
||||
|
||||
message ConfigureReply {
|
||||
repeated ConfigureItem data=1; // 配置参数列表
|
||||
}
|
||||
|
||||
message ConfigureItem {
|
||||
string Identity=1; //唯一标识
|
||||
string key=2; //配置键
|
||||
string value=3; //配置值
|
||||
int64 version=4; //版本号
|
||||
}
|
||||
|
||||
|
||||
message AreasReply {
|
||||
repeated AreasItem areas=1;
|
||||
}
|
||||
|
||||
message AreasItem {
|
||||
string id =1;
|
||||
string pid=2;
|
||||
string deep=3;
|
||||
string name=4;
|
||||
string pinyin_prefix=5;
|
||||
string pinyin=6;
|
||||
string ext_id=7;
|
||||
string ext_name=8;
|
||||
}
|
||||
message TagsReply {
|
||||
repeated TagsItem tags=1;
|
||||
}
|
||||
|
||||
message TagsItem {
|
||||
int64 id =1;
|
||||
int32 type=2;
|
||||
string key=3;
|
||||
string title=4;
|
||||
string remark=5;
|
||||
string icon=6;
|
||||
}
|
Loading…
Reference in New Issue