Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin panel #1

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 17.x]
node-version: [16.x, 17.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
Expand All @@ -44,16 +44,20 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
cache: pnpm
- name: Install dependencies
run: |
pnpm install
pnpm add -g codecov
run: pnpm install
- name: Build
run: pnpm run build
run: |
pnpm run build
pnpm -r run build
- name: Lint with ESLint
run: pnpm run lint
- name: Test with Jest
- name: Test with Jest & Vitest
run: |
pnpm run test --ci --coverage
codecov
pnpm -r run test:unit --coverage
- name: Codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
16 changes: 16 additions & 0 deletions admin/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-env node */
require("@rushstack/eslint-patch/modern-module-resolution");

module.exports = {
root: true,
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/eslint-config-typescript/recommended",
"@vue/eslint-config-prettier",
],
env: {
"vue/setup-compiler-macros": true,
},
rules: { "prettier/prettier": "error" },
};
28 changes: 28 additions & 0 deletions admin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions admin/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
52 changes: 52 additions & 0 deletions admin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# admin

This template should help get you started developing with Vue 3 in Vite.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).

## Type Support for `.vue` Imports in TS

TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:

1. Disable the built-in TypeScript Extension
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.

## Customize configuration

See [Vite Configuration Reference](https://vitejs.dev/config/).

## Project Setup

```sh
pnpm install
```

### Compile and Hot-Reload for Development

```sh
pnpm dev
```

### Type-Check, Compile and Minify for Production

```sh
pnpm build
```

### Run Unit Tests with [Vitest](https://vitest.dev/)

```sh
pnpm test:unit
```

### Lint with [ESLint](https://eslint.org/)

```sh
pnpm lint
```
56 changes: 56 additions & 0 deletions admin/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/// <reference types="vite/client" />

declare module "xncolorpicker/src/xncolorpicker" {
namespace XNColorPicker {
interface Single {
color: {
hex: string;
hsla: string;
hslav: [string, string, string, string];
rgba: string;
rgbav: [string, string, string, string];
};
colorType: "single";
}
interface Gradient<colorType, angleType> {
color: {
arry: {
angle: angleType;
colors: { color: string; per: number }[];
type: colorType;
};
str: string;
};
colorType: colorType;
}
type Color =
| Single
| Gradient<"linear-gradient", string>
| Gradient<"radial-gradient", number>;
}
class XNColorPicker {
constructor(options: {
color?: string;
selector: string;
showprecolor?: boolean;
prevcolors?: string[] | null;
showhistorycolor?: boolean;
historycolornum?: number;
format?: "rgba" | "hex" | "hsla";
showPalette?: boolean;
show?: boolean;
lang?: "en" | "cn";
colorTypeOption?: string;
canMove?: boolean;
alwaysShow?: boolean;
autoConfirm?: boolean;
hideInputer?: boolean;
hideCancelButton?: boolean;
hideConfirmButton?: boolean;
onCancel?: (color: XNColorPicker.Color) => void;
onChange?: (color: XNColorPicker.Color) => void;
onConfirm?: (color: XNColorPicker.Color) => void;
});
}
export default XNColorPicker;
}
13 changes: 13 additions & 0 deletions admin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
42 changes: 42 additions & 0 deletions admin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "admin",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "run-p type-check build-only",
"preview": "vite preview --port 4173",
"test:unit": "vitest --environment jsdom",
"build-only": "vite build",
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@popperjs/core": "^2.11.5",
"bootstrap": "5.2.0-beta1",
"pinia": "^2.0.14",
"vue": "^3.2.37",
"vue-router": "^4.0.16",
"xncolorpicker": "github:fanaiai/xncolorpicker"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.1.3",
"@types/jsdom": "^16.2.14",
"@types/node": "^16.11.41",
"@vitejs/plugin-vue": "^2.3.3",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/test-utils": "^2.0.0",
"@vue/tsconfig": "^0.1.3",
"c8": "^7.11.3",
"eslint": "^8.18.0",
"eslint-plugin-vue": "^8.7.1",
"jsdom": "^19.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"sass": "^1.52.3",
"typescript": "~4.7.4",
"vite": "^2.9.12",
"vitest": "^0.13.1",
"vue-tsc": "^0.35.2"
}
}
Binary file added admin/public/favicon.ico
Binary file not shown.
126 changes: 126 additions & 0 deletions admin/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<script setup lang="ts">
import { RouterLink, RouterView } from "vue-router";
import HelloWorld from "@/components/HelloWorld.vue";
</script>

<template>
<header>
<img
alt="Vue logo"
class="logo"
src="@/assets/logo.svg"
width="125"
height="125"
/>

<div class="wrapper">
<HelloWorld msg="You did it!" />

<nav>
<RouterLink :to="{ name: 'home' }">Home</RouterLink>
<RouterLink :to="{ name: 'about' }">About</RouterLink>
<RouterLink :to="{ name: 'badge' }">Badge</RouterLink>
</nav>
</div>
</header>

<RouterView />
</template>

<style>
@import "@/assets/base.css";

#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;

font-weight: normal;
}

header {
line-height: 1.5;
max-height: 100vh;
}

.logo {
display: block;
margin: 0 auto 2rem;
}

a,
.green {
text-decoration: none;
color: hsla(160, 100%, 37%, 1);
transition: 0.4s;
}

@media (hover: hover) {
a:hover {
background-color: hsla(160, 100%, 37%, 0.2);
}
}

nav {
width: 100%;
font-size: 12px;
text-align: center;
margin-top: 2rem;
}

nav a.router-link-exact-active {
color: var(--color-text);
}

nav a.router-link-exact-active:hover {
background-color: transparent;
}

nav a {
display: inline-block;
padding: 0 1rem;
border-left: 1px solid var(--color-border);
}

nav a:first-of-type {
border: 0;
}

@media (min-width: 1024px) {
body {
display: flex;
place-items: center;
}

#app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem;
}

header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}

header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}

.logo {
margin: 0 2rem 0 0;
}

nav {
text-align: left;
margin-left: -1rem;
font-size: 1rem;

padding: 1rem 0;
margin-top: 1rem;
}
}
</style>
Loading