Skip to content

Commit

Permalink
refactor: 接口命名规则统一为kebab-case串式命名法
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxian521 committed Sep 27, 2023
1 parent 73b5d3e commit 320ee2b
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.en_US.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
- Add front-end single sign-on, test address https://yiming_chang.gitee.io/vue-pure-admin/#/pure-table/index?username=sso&roles=admin&accessToken=eyJhbGciOiJIUzUxMiJ9.admin
- Add more examples for [@pureadmin/table](https://github.com/pure-admin/pure-admin-table) and `element-plus` [table](https://element-plus.org /zh-CN/component/table.html) example remains the same
- Rich watermark function page (supports customizing various colors, shadows, text, additional attributes, setting undeletable watermarks and setting watermarks for specified elements)
- Optimize the menu, add `MenuArrowIconNoTransition` global configuration, configure it in `public/serverConfig.json`, for the left menu mode, the menu expansion can be set `MenuArrowIconNoTransition: true` to solve
- Optimize the menu, add `MenuArrowIconNoTransition` global configuration, configure it in `public/platform-config.json`, for the left menu mode, the menu expansion can be set `MenuArrowIconNoTransition: true` to solve
- Replacement form designer component demo

### 🐞 Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
- Add front-end single sign-on, test address https://yiming_chang.gitee.io/vue-pure-admin/#/pure-table/index?username=sso&roles=admin&accessToken=eyJhbGciOiJIUzUxMiJ9.admin
- Add more examples for [@pureadmin/table](https://github.com/pure-admin/pure-admin-table) and `element-plus` [table](https://element-plus.org /zh-CN/component/table.html) example remains the same
- Rich watermark function page (supports customizing various colors, shadows, text, additional attributes, setting undeletable watermarks and setting watermarks for specified elements)
- Optimize the menu, add `MenuArrowIconNoTransition` global configuration, configure it in `public/serverConfig.json`, for the left menu mode, the menu expansion can be set `MenuArrowIconNoTransition: true` to solve
- Optimize the menu, add `MenuArrowIconNoTransition` global configuration, configure it in `public/platform-config.json`, for the left menu mode, the menu expansion can be set `MenuArrowIconNoTransition: true` to solve
- Replacement form designer component demo

### 🐞 Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
- 添加前端单点登录,测试地址 https://yiming_chang.gitee.io/vue-pure-admin/#/pure-table/index?username=sso&roles=admin&accessToken=eyJhbGciOiJIUzUxMiJ9.admin
-[@pureadmin/table](https://github.com/pure-admin/pure-admin-table) 添加更多的示例和 `element-plus`[table](https://element-plus.org/zh-CN/component/table.html) 示例保持一致
- 丰富水印功能页面(支持自定义各种颜色、阴影、文字、额外属性、设置不可删除水印以及给指定元素设置水印)
- 优化菜单,添加 `MenuArrowIconNoTransition` 全局配置,在 `public/serverConfig.json` 中配置即可,对于出现左侧菜单模式,菜单展开卡顿的可设置 `MenuArrowIconNoTransition: true` 即可解决
- 优化菜单,添加 `MenuArrowIconNoTransition` 全局配置,在 `public/platform-config.json` 中配置即可,对于出现左侧菜单模式,菜单展开卡顿的可设置 `MenuArrowIconNoTransition: true` 即可解决
- 更换表单设计器组件演示

### 🐞 Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion mock/asyncRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const tabsRouter = {

export default [
{
url: "/getAsyncRoutes",
url: "/get-async-routes",
method: "get",
response: () => {
return {
Expand Down
4 changes: 2 additions & 2 deletions mock/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MockMethod } from "vite-plugin-mock";

export default [
{
url: "/getCardList",
url: "/get-card-list",
method: "post",
response: () => {
return {
Expand Down Expand Up @@ -559,7 +559,7 @@ export default [
{
created_at: "2022-11-21T09:14:22Z",
published_at: "2022-11-21T09:15:24Z",
body: "# 3.7.0 (2022-11-21)\r\n\r\n### ✔️ refactor\r\n\r\n- 使用 `intro.js` 替换 `driver.js`\r\n\r\n### 🎫 Feat\r\n\r\n- 添加前端单点登录,测试地址 https://yiming_chang.gitee.io/vue-pure-admin/#/pure-table/index?username=sso&roles=admin&accessToken=eyJhbGciOiJIUzUxMiJ9.admin\r\n- 为 [@pureadmin/table](https://github.com/xiaoxian521/pure-admin-table) 添加更多的示例和 `element-plus` 的 [table](https://element-plus.org/zh-CN/component/table.html) 示例保持一致\r\n- 丰富水印功能页面(支持自定义各种颜色、阴影、文字、额外属性、设置不可删除水印以及给指定元素设置水印)\r\n- 优化菜单,添加 `MenuArrowIconNoTransition` 全局配置,在 `public/serverConfig.json` 中配置即可,对于出现左侧菜单模式,菜单展开卡顿的可设置 `MenuArrowIconNoTransition: true` 即可解决\r\n- 更换表单设计器组件演示\r\n\r\n### 🐞 Bug fixes\r\n\r\n- 修复页内菜单带参互相跳转,标签没有选中高亮\r\n\r\n### 🍏 Perf\r\n\r\n- 删除已废弃的 `$baseUrl`\r\n- 兼容引入某个库导致 `global is not defined` 报错,将 `src/utils/globalPolyfills.ts` 文件引入 `src/main.ts` 即可解决\r\n- 删除 `@vitejs/plugin-legacy`,`vue3` 无法通过任何工具使其支持 `ie`"
body: "# 3.7.0 (2022-11-21)\r\n\r\n### ✔️ refactor\r\n\r\n- 使用 `intro.js` 替换 `driver.js`\r\n\r\n### 🎫 Feat\r\n\r\n- 添加前端单点登录,测试地址 https://yiming_chang.gitee.io/vue-pure-admin/#/pure-table/index?username=sso&roles=admin&accessToken=eyJhbGciOiJIUzUxMiJ9.admin\r\n- 为 [@pureadmin/table](https://github.com/xiaoxian521/pure-admin-table) 添加更多的示例和 `element-plus` 的 [table](https://element-plus.org/zh-CN/component/table.html) 示例保持一致\r\n- 丰富水印功能页面(支持自定义各种颜色、阴影、文字、额外属性、设置不可删除水印以及给指定元素设置水印)\r\n- 优化菜单,添加 `MenuArrowIconNoTransition` 全局配置,在 `public/platform-config.json` 中配置即可,对于出现左侧菜单模式,菜单展开卡顿的可设置 `MenuArrowIconNoTransition: true` 即可解决\r\n- 更换表单设计器组件演示\r\n\r\n### 🐞 Bug fixes\r\n\r\n- 修复页内菜单带参互相跳转,标签没有选中高亮\r\n\r\n### 🍏 Perf\r\n\r\n- 删除已废弃的 `$baseUrl`\r\n- 兼容引入某个库导致 `global is not defined` 报错,将 `src/utils/globalPolyfills.ts` 文件引入 `src/main.ts` 即可解决\r\n- 删除 `@vitejs/plugin-legacy`,`vue3` 无法通过任何工具使其支持 `ie`"
},
{
created_at: "2022-11-10T04:17:05Z",
Expand Down
2 changes: 1 addition & 1 deletion mock/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const mapList = (): Array<mapType> => {

export default [
{
url: "/getMapInfo",
url: "/get-map-info",
method: "get",
response: () => {
return {
Expand Down
2 changes: 1 addition & 1 deletion mock/refreshToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MockMethod } from "vite-plugin-mock";
// 模拟刷新token接口
export default [
{
url: "/refreshToken",
url: "/refresh-token",
method: "post",
response: ({ body }) => {
if (body.refreshToken) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/api/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Result = {

/** 卡片列表 */
export const getCardList = (data?: object) => {
return http.request<Result>("post", "/getCardList", { data });
return http.request<Result>("post", "/get-card-list", { data });
};

/** 版本日志 */
Expand Down
2 changes: 1 addition & 1 deletion src/api/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type Result = {

/** 地图数据 */
export const mapJson = (params?: object) => {
return http.request<Result>("get", "/getMapInfo", { params });
return http.request<Result>("get", "/get-map-info", { params });
};
2 changes: 1 addition & 1 deletion src/api/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ type Result = {
};

export const getAsyncRoutes = () => {
return http.request<Result>("get", "/getAsyncRoutes");
return http.request<Result>("get", "/get-async-routes");
};
2 changes: 1 addition & 1 deletion src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export const getLogin = (data?: object) => {

/** 刷新token */
export const refreshTokenApi = (data?: object) => {
return http.request<RefreshTokenResult>("post", "/refreshToken", { data });
return http.request<RefreshTokenResult>("post", "/refresh-token", { data });
};
8 changes: 4 additions & 4 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const setConfig = (cfg?: unknown) => {
config = Object.assign(config, cfg);
};

const getConfig = (key?: string): ServerConfigs => {
const getConfig = (key?: string): PlatformConfigs => {
if (typeof key === "string") {
const arr = key.split(".");
if (arr && arr.length) {
Expand All @@ -27,11 +27,11 @@ const getConfig = (key?: string): ServerConfigs => {
};

/** 获取项目动态全局配置 */
export const getServerConfig = async (app: App): Promise<undefined> => {
export const getPlatformConfig = async (app: App): Promise<undefined> => {
app.config.globalProperties.$config = getConfig();
return axios({
method: "get",
url: `${VITE_PUBLIC_PATH}serverConfig.json`
url: `${VITE_PUBLIC_PATH}platform-config.json`
})
.then(({ data: config }) => {
let $config = app.config.globalProperties.$config;
Expand All @@ -45,7 +45,7 @@ export const getServerConfig = async (app: App): Promise<undefined> => {
return $config;
})
.catch(() => {
throw "请在public文件夹下添加serverConfig.json配置文件";
throw "请在public文件夹下添加platform-config.json配置文件";
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/layout/hooks/useLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function useLayout() {
}
};

/** 清空缓存后从serverConfig.json读取默认配置并赋值到storage中 */
/** 清空缓存后从platform-config.json读取默认配置并赋值到storage中 */
const layout = computed(() => {
return $storage?.layout.layout;
});
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import router from "./router";
import { setupStore } from "@/store";
import ElementPlus from "element-plus";
import { useI18n } from "@/plugins/i18n";
import { getServerConfig } from "./config";
import { getPlatformConfig } from "./config";
import { createApp, Directive } from "vue";
import { MotionPlugin } from "@vueuse/motion";
import { useEcharts } from "@/plugins/echarts";
Expand Down Expand Up @@ -45,7 +45,7 @@ app.component("FontIcon", FontIcon);
import { Auth } from "@/components/ReAuth";
app.component("Auth", Auth);

getServerConfig(app).then(async config => {
getPlatformConfig(app).then(async config => {
setupStore(app);
app.use(router);
await router.isReady();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/responsive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Storage from "responsive-storage";
import { routerArrays } from "@/layout/types";
import { responsiveStorageNameSpace } from "@/config";

export const injectResponsiveStorage = (app: App, config: ServerConfigs) => {
export const injectResponsiveStorage = (app: App, config: PlatformConfigs) => {
const nameSpace = responsiveStorageNameSpace();
const configObj = Object.assign(
{
Expand Down
12 changes: 6 additions & 6 deletions types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ declare global {
interface TableColumnList extends Array<TableColumns> {}

/**
* 对应 `public/serverConfig.json` 文件的类型声明
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
* 对应 `public/platform-config.json` 文件的类型声明
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#platform-config-json}
*/
interface ServerConfigs {
interface PlatformConfigs {
Version?: string;
Title?: string;
FixedHeader?: boolean;
Expand Down Expand Up @@ -108,8 +108,8 @@ declare global {
}

/**
* 与 `ServerConfigs` 类型不同,这里是缓存到浏览器本地存储的类型声明
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
* 与 `PlatformConfigs` 类型不同,这里是缓存到浏览器本地存储的类型声明
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#platform-config-json}
*/
interface StorageConfigs {
version?: string;
Expand Down Expand Up @@ -171,6 +171,6 @@ declare global {
interface GlobalPropertiesApi {
$echarts: ECharts;
$storage: ResponsiveStorage;
$config: ServerConfigs;
$config: PlatformConfigs;
}
}

1 comment on commit 320ee2b

@xiaoxian521
Copy link
Member Author

@xiaoxian521 xiaoxian521 commented on 320ee2b Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主要变化:

  1. public/serverConfig.json 文件重命名为 public/platform-config.json 语义更明确
  2. 平台所有用 mock 模拟接口的 url 命名规则统一为 kebab-case 串式命名法

Please sign in to comment.