Browse Source

一些问题

master
1549469775 3 years ago
parent
commit
7f3d698b2b
  1. 3
      .gitignore
  2. 3
      docs/.vitepress/theme/index.js
  3. 8
      packages/components/captcha/index.ts
  4. 15
      packages/components/captcha/index.vue
  5. 6
      packages/components/components.ts
  6. 8
      packages/components/send/index.ts
  7. 3
      packages/playground/components.d.ts
  8. 12
      packages/playground/src/App.vue
  9. 40
      packages/princess-ui/PrincessResolver.js
  10. 6
      packages/princess-ui/components.d.ts
  11. 20
      packages/princess-ui/lib/button/index.d.ts
  12. 19
      packages/princess-ui/lib/button/index.js
  13. 2
      packages/princess-ui/lib/button/index.umd.js
  14. 1
      packages/princess-ui/lib/button/style.css
  15. 84
      packages/princess-ui/lib/captcha/index.d.ts
  16. 75
      packages/princess-ui/lib/captcha/index.js
  17. 1
      packages/princess-ui/lib/captcha/index.umd.js
  18. 4
      packages/princess-ui/lib/components.d.ts
  19. 129
      packages/princess-ui/lib/index.js
  20. 2
      packages/princess-ui/lib/index.umd.js
  21. 16
      packages/princess-ui/lib/send/index.js
  22. 1
      packages/princess-ui/lib/send/index.umd.js
  23. 1
      packages/princess-ui/lib/send/style.css
  24. 2
      packages/princess-ui/lib/style.css
  25. 4
      packages/theme-chalk/src/captcha.scss
  26. 1
      packages/theme-chalk/src/index.scss

3
.gitignore

@ -2,3 +2,6 @@ node_modules
.temp .temp
.cache .cache
dist dist
princess-ui/lib
princess-ui/theme-chalk
princess-ui/components.d.ts

3
docs/.vitepress/theme/index.js

@ -1,10 +1,11 @@
import DefaultTheme from 'vitepress/dist/client/theme-default' import DefaultTheme from 'vitepress/dist/client/theme-default'
import PrincessUI from "@princess-ui/components"
export default { export default {
...DefaultTheme, ...DefaultTheme,
enhanceApp({ app, router, siteData }) { enhanceApp({ app, router, siteData }) {
// app is the Vue 3 app instance from `createApp()`. router is VitePress' // app is the Vue 3 app instance from `createApp()`. router is VitePress'
// custom router. `siteData`` is a `ref`` of current site-level metadata. // custom router. `siteData`` is a `ref`` of current site-level metadata.
app.use(PrincessUI)
} }
} }

8
packages/components/captcha/index.ts

@ -0,0 +1,8 @@
import PsCaptcha from "./index.vue"
PsCaptcha.name = "ps-captcha"
export {
PsCaptcha
}
export default PsCaptcha

15
packages/components/send/index.vue → packages/components/captcha/index.vue

@ -1,11 +1,11 @@
<template> <template>
<button @click="onClick" :disabled="isDisabled" :loading="isLoading" type="button" size="small"> <div class="ps-send" @click="onClick" :disabled="isDisabled" :loading="isLoading" type="button" size="small">
{{ text }} {{ text }}
</button> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onBeforeUnmount, ref, watchEffect } from "vue" import { onBeforeUnmount, ref } from "vue"
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
duration?: number duration?: number
@ -24,13 +24,12 @@ const props = withDefaults(
) )
const emits = defineEmits<{ const emits = defineEmits<{
(event: "update:modelValue", show: boolean): void (event: "update:modelValue", show: boolean): void
(event: "send", start: () => void, done: (isDone: boolean) => void): void (event: "send", start: () => void, done: (isDone?: boolean) => void): void
}>() }>()
const text = ref(props.initText) const text = ref(props.initText)
const isDisabled = ref(false) const isDisabled = ref(false)
const isLoading = ref(false) const isLoading = ref(false)
let number = props.duration
let timeID: any let timeID: any
onBeforeUnmount(() => { onBeforeUnmount(() => {
@ -39,7 +38,6 @@ onBeforeUnmount(() => {
function stop() { function stop() {
clearInterval(timeID) clearInterval(timeID)
number = props.duration
text.value = props.resetText text.value = props.resetText
isLoading.value = false isLoading.value = false
isDisabled.value = false isDisabled.value = false
@ -51,6 +49,7 @@ function getText(second: string | number): string {
} }
function run() { function run() {
isLoading.value = false isLoading.value = false
let number = props.duration
text.value = getText(number) text.value = getText(number)
clearInterval(timeID) clearInterval(timeID)
timeID = setInterval(() => { timeID = setInterval(() => {
@ -63,6 +62,8 @@ function run() {
} }
function onClick() { function onClick() {
if (isDisabled.value) return
if (isLoading.value) return
emits( emits(
"send", "send",
() => { () => {
@ -70,7 +71,7 @@ function onClick() {
isLoading.value = true isLoading.value = true
text.value = props.loadingText text.value = props.loadingText
}, },
(isDone: boolean) => { (isDone: boolean = true) => {
if (isDone) { if (isDone) {
run() run()
} else { } else {

6
packages/components/components.ts

@ -1,9 +1,9 @@
// 该文件为自动生成,请勿修改!!! // 该文件为自动生成,请勿修改!!!
import PsButton from "./button" import PsButton from "./button"
import PsCaptcha from "./captcha"
import PsFuck from "./fuck" import PsFuck from "./fuck"
import PsSend from "./send"
export { export {
PsButton, PsButton,
PsFuck, PsCaptcha,
PsSend PsFuck
} }

8
packages/components/send/index.ts

@ -1,8 +0,0 @@
import PsSend from "./index.vue"
PsSend.name = "ps-send"
export {
PsSend
}
export default PsSend

3
packages/playground/components.d.ts

@ -6,8 +6,7 @@ import '@vue/runtime-core'
declare module '@vue/runtime-core' { declare module '@vue/runtime-core' {
export interface GlobalComponents { export interface GlobalComponents {
HelloWorld: typeof import('./src/components/HelloWorld.vue')['default'] HelloWorld: typeof import('./src/components/HelloWorld.vue')['default']
PsButton: typeof import('@princess-ui/components/button')['PsButton'] PsCaptcha: typeof import('@princess-ui/components/captcha')['PsCaptcha']
PsSend: typeof import('@princess-ui/components/send')['PsSend']
} }
} }

12
packages/playground/src/App.vue

@ -2,13 +2,17 @@
// This starter template is using Vue 3 <script setup> SFCs // This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup // Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import HelloWorld from './components/HelloWorld.vue' import HelloWorld from './components/HelloWorld.vue'
function send(start: () => void, done: (isDone: boolean) => void) {
start()
setTimeout(() => {
done(true)
}, 2500);
}
</script> </script>
<template> <template>
<img alt="Vue logo" src="./assets/logo.png" /> <ps-captcha @send="send" :duration="5">sada</ps-captcha>
<HelloWorld msg="Hello Vue 3 + TypeScript + Vite" />
<ps-button color="red" aaa="dd">sada</ps-button>
<ps-send color="red" aaa="dd">sada</ps-send>
</template> </template>
<style> <style>

40
packages/princess-ui/PrincessResolver.js

@ -6,24 +6,44 @@ exports.__esModule = true;
var fs_1 = __importDefault(require("fs")); var fs_1 = __importDefault(require("fs"));
var path_1 = __importDefault(require("path")); var path_1 = __importDefault(require("path"));
function existCss(compName) { function existCss(compName) {
if (fs_1["default"].existsSync(path_1["default"].resolve(__dirname, "./lib/" + compName[0].toLowerCase() + compName.slice(1) + "/style.css"))) { if (fs_1["default"].existsSync(path_1["default"].resolve(__dirname, './lib/' +
compName[0].toLowerCase() +
compName.slice(1) +
'/style.css'))) {
return true; return true;
} }
return false; return false;
} }
exports["default"] = (function (name, p) { function existTheme(compName) {
if (name === void 0) { name = "princess-ui"; } if (fs_1["default"].existsSync(path_1["default"].resolve(__dirname, './theme-chalk/ps-' +
if (p === void 0) { p = "/lib"; } compName[0].toLowerCase() +
compName.slice(1) +
'.css'))) {
return true;
}
return false;
}
exports["default"] = (function () {
return { return {
type: "component", type: 'component',
resolve: function (componentName) { resolve: function (componentName) {
if (componentName.startsWith("Ps")) { if (componentName.startsWith('Ps')) {
var css = [];
var n = componentName.slice(2);
if (existCss(n)) {
css.push((function getSideEffects(compName) {
return "princess-ui/lib/".concat(compName[0].toLowerCase() + compName.slice(1), "/style.css");
})(n));
}
if (existTheme(n)) {
css.push((function getSideEffects(compName) {
return "princess-ui/theme-chalk/ps-".concat(compName[0].toLowerCase() + compName.slice(1), ".css");
})(n));
}
return { return {
name: componentName, name: componentName,
from: name, from: 'princess-ui',
sideEffects: existCss(componentName.slice(2)) ? (function getSideEffects(compName) { sideEffects: css
return "".concat(name).concat(p, "/").concat(compName[0].toLowerCase() + compName.slice(1), "/style.css");
})(componentName.slice(2)) : undefined
}; };
} }
} }

6
packages/princess-ui/components.d.ts

@ -1,8 +1,8 @@
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
PsButton: typeof import('./lib')['PsButton'], PsButton: typeof import('./lib/button')['PsButton'],
PsFuck: typeof import('./lib')['PsFuck'], PsCaptcha: typeof import('./lib/captcha')['PsCaptcha'],
PsSend: typeof import('./lib')['PsSend'] PsFuck: typeof import('./lib/fuck')['PsFuck']
} }
} }
export { } export { }

20
packages/princess-ui/lib/button/index.d.ts

@ -1,21 +1,7 @@
import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes, PropType } from 'vue'; import type { DefineComponent, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
declare const _sfc_main: DefineComponent<{ declare const _sfc_main: DefineComponent<{
color: { text: StringConstructor;
type: PropType<"blue" | "red">;
required: true;
};
aaa: {
type: PropType<"red" | "dd">;
required: true;
};
}, unknown, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{ }, unknown, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
color: { text: StringConstructor;
type: PropType<"blue" | "red">;
required: true;
};
aaa: {
type: PropType<"red" | "dd">;
required: true;
};
}>>, {}>; }>>, {}>;
export default _sfc_main; export default _sfc_main;

19
packages/princess-ui/lib/button/index.js

@ -1,5 +1,4 @@
import { defineComponent, openBlock, createElementBlock, toDisplayString } from "vue"; import { defineComponent, openBlock, createElementBlock, renderSlot, createTextVNode, toDisplayString } from "vue";
var index_vue_vue_type_style_index_0_lang = "";
var _export_sfc = (sfc, props) => { var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc; const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) { for (const [key, val] of props) {
@ -9,18 +8,16 @@ var _export_sfc = (sfc, props) => {
}; };
const _sfc_main = defineComponent({ const _sfc_main = defineComponent({
props: { props: {
color: { text: String
type: String,
required: true
},
aaa: {
type: String,
required: true
}
} }
}); });
const _hoisted_1 = { class: "ps-button" };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, " sada" + toDisplayString(_ctx.color), 1); return openBlock(), createElementBlock("div", _hoisted_1, [
renderSlot(_ctx.$slots, "default", {}, () => [
createTextVNode(toDisplayString(_ctx.text), 1)
])
]);
} }
var PsButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); var PsButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
PsButton.name = "ps-button"; PsButton.name = "ps-button";

2
packages/princess-ui/lib/button/index.umd.js

@ -1 +1 @@
(function(e,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(e=typeof globalThis!="undefined"?globalThis:e||self,t(e.psButton={},e.Vue))})(this,function(e,t){"use strict";var c="",d=(n,i)=>{const r=n.__vccOpts||n;for(const[u,s]of i)r[u]=s;return r};const p=t.defineComponent({props:{color:{type:String,required:!0},aaa:{type:String,required:!0}}});function a(n,i,r,u,s,f){return t.openBlock(),t.createElementBlock("div",null," sada"+t.toDisplayString(n.color),1)}var o=d(p,[["render",a]]);o.name="ps-button",e.PsButton=o,e.default=o,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); (function(t,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.psButton={},t.Vue))})(this,function(t,e){"use strict";var u=(n,r)=>{const s=n.__vccOpts||n;for(const[i,d]of r)s[i]=d;return s};const f=e.defineComponent({props:{text:String}}),p={class:"ps-button"};function c(n,r,s,i,d,a){return e.openBlock(),e.createElementBlock("div",p,[e.renderSlot(n.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(n.text),1)])])}var o=u(f,[["render",c]]);o.name="ps-button",t.PsButton=o,t.default=o,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

1
packages/princess-ui/lib/button/style.css

@ -1 +0,0 @@
div{background-color:#639}div{color:red}

84
packages/princess-ui/lib/captcha/index.d.ts

@ -0,0 +1,84 @@
import type { DefineComponent, Ref, ComponentOptionsMixin, VNodeProps, AllowedComponentProps, ComponentCustomProps, ExtractPropTypes } from 'vue';
declare const _sfc_main: DefineComponent<{
duration: {
type: NumberConstructor;
required: false;
default: number;
};
initText: {
type: StringConstructor;
required: false;
default: string;
};
runText: {
type: StringConstructor;
required: false;
default: string;
};
loadingText: {
type: StringConstructor;
required: false;
default: string;
};
resetText: {
type: StringConstructor;
required: false;
default: string;
};
}, {
props: {
duration: number;
initText: string;
runText: string;
loadingText: string;
resetText: string;
};
emits: {
(event: "update:modelValue", show: boolean): void;
(event: "send", start: () => void, done: (isDone?: boolean) => void): void;
};
text: Ref<string>;
isDisabled: Ref<boolean>;
isLoading: Ref<boolean>;
timeID: any;
stop: () => void;
getText: (second: string | number) => string;
run: () => void;
onClick: () => void;
}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("update:modelValue" | "send")[], "update:modelValue" | "send", VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
duration: {
type: NumberConstructor;
required: false;
default: number;
};
initText: {
type: StringConstructor;
required: false;
default: string;
};
runText: {
type: StringConstructor;
required: false;
default: string;
};
loadingText: {
type: StringConstructor;
required: false;
default: string;
};
resetText: {
type: StringConstructor;
required: false;
default: string;
};
}>> & {
"onUpdate:modelValue"?: (...args: any[]) => any;
onSend?: (...args: any[]) => any;
}, {
duration: number;
initText: string;
runText: string;
loadingText: string;
resetText: string;
}>;
export default _sfc_main;

75
packages/princess-ui/lib/captcha/index.js

@ -0,0 +1,75 @@
import { defineComponent, ref, onBeforeUnmount, openBlock, createElementBlock, toDisplayString } from "vue";
const _hoisted_1 = ["disabled", "loading"];
const _sfc_main = /* @__PURE__ */ defineComponent({
name: "index",
props: {
duration: { default: 60 },
initText: { default: "\u83B7\u53D6\u9A8C\u8BC1\u7801" },
runText: { default: "{%s}s \u540E\u91CD\u65B0\u53D1\u9001" },
loadingText: { default: "\u6B63\u5728\u53D1\u9001" },
resetText: { default: "\u91CD\u65B0\u83B7\u53D6" }
},
emits: ["update:modelValue", "send"],
setup(__props, { emit: emits }) {
const props = __props;
const text = ref(props.initText);
const isDisabled = ref(false);
const isLoading = ref(false);
let timeID;
onBeforeUnmount(() => {
stop();
});
function stop() {
clearInterval(timeID);
text.value = props.resetText;
isLoading.value = false;
isDisabled.value = false;
emits("update:modelValue", false);
}
function getText(second) {
return props.runText.replace(/\{([^{]*?)%s(.*?)\}/g, String(second));
}
function run() {
isLoading.value = false;
let number = props.duration;
text.value = getText(number);
clearInterval(timeID);
timeID = setInterval(() => {
number--;
text.value = getText(number);
if (number <= 0) {
stop();
}
}, 1e3);
}
function onClick() {
if (isDisabled.value)
return;
if (isLoading.value)
return;
emits("send", () => {
isDisabled.value = true;
isLoading.value = true;
text.value = props.loadingText;
}, (isDone = true) => {
if (isDone) {
run();
} else {
stop();
}
});
}
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
class: "ps-send",
onClick,
disabled: isDisabled.value,
loading: isLoading.value,
type: "button",
size: "small"
}, toDisplayString(text.value), 9, _hoisted_1);
};
}
});
_sfc_main.name = "ps-captcha";
export { _sfc_main as PsCaptcha, _sfc_main as default };

1
packages/princess-ui/lib/captcha/index.umd.js

@ -0,0 +1 @@
(function(u,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(u=typeof globalThis!="undefined"?globalThis:u||self,e(u.psCaptcha={},u.Vue))})(this,function(u,e){"use strict";const c=["disabled","loading"],s=e.defineComponent({name:"index",props:{duration:{default:60},initText:{default:"\u83B7\u53D6\u9A8C\u8BC1\u7801"},runText:{default:"{%s}s \u540E\u91CD\u65B0\u53D1\u9001"},loadingText:{default:"\u6B63\u5728\u53D1\u9001"},resetText:{default:"\u91CD\u65B0\u83B7\u53D6"}},emits:["update:modelValue","send"],setup(p,{emit:d}){const n=p,a=e.ref(n.initText),i=e.ref(!1),l=e.ref(!1);let o;e.onBeforeUnmount(()=>{r()});function r(){clearInterval(o),a.value=n.resetText,l.value=!1,i.value=!1,d("update:modelValue",!1)}function f(t){return n.runText.replace(/\{([^{]*?)%s(.*?)\}/g,String(t))}function m(){l.value=!1;let t=n.duration;a.value=f(t),clearInterval(o),o=setInterval(()=>{t--,a.value=f(t),t<=0&&r()},1e3)}function v(){i.value||l.value||d("send",()=>{i.value=!0,l.value=!0,a.value=n.loadingText},(t=!0)=>{t?m():r()})}return(t,x)=>(e.openBlock(),e.createElementBlock("div",{class:"ps-send",onClick:v,disabled:i.value,loading:l.value,type:"button",size:"small"},e.toDisplayString(a.value),9,c))}});s.name="ps-captcha",u.PsCaptcha=s,u.default=s,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

4
packages/princess-ui/lib/components.d.ts

@ -1,4 +1,4 @@
import PsButton from "./button"; import PsButton from "./button";
import PsCaptcha from "./captcha";
import PsFuck from "./fuck"; import PsFuck from "./fuck";
import PsSend from "./send"; export { PsButton, PsCaptcha, PsFuck };
export { PsButton, PsFuck, PsSend };

129
packages/princess-ui/lib/index.js

@ -1,5 +1,4 @@
import { defineComponent, openBlock, createElementBlock, toDisplayString, createTextVNode, createVNode, unref } from "vue"; import { defineComponent, openBlock, createElementBlock, renderSlot, createTextVNode, toDisplayString, ref, onBeforeUnmount, createVNode, unref } from "vue";
var index_vue_vue_type_style_index_0_lang$2 = "";
var _export_sfc = (sfc, props) => { var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc; const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) { for (const [key, val] of props) {
@ -9,25 +8,106 @@ var _export_sfc = (sfc, props) => {
}; };
const _sfc_main$2 = defineComponent({ const _sfc_main$2 = defineComponent({
props: { props: {
color: { text: String
type: String,
required: true
},
aaa: {
type: String,
required: true
}
} }
}); });
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { const _hoisted_1$1 = { class: "ps-button" };
return openBlock(), createElementBlock("div", null, " sada" + toDisplayString(_ctx.color), 1); function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", _hoisted_1$1, [
renderSlot(_ctx.$slots, "default", {}, () => [
createTextVNode(toDisplayString(_ctx.text), 1)
])
]);
} }
var PsButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1]]); var PsButton = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render]]);
PsButton.name = "ps-button"; PsButton.name = "ps-button";
var index_vue_vue_type_style_index_0_lang$1 = ""; var __glob_2_0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
PsButton,
"default": PsButton
}, Symbol.toStringTag, { value: "Module" }));
const _hoisted_1 = ["disabled", "loading"];
const _sfc_main$1 = /* @__PURE__ */ defineComponent({ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
name: "index", name: "index",
props: { props: {
duration: { default: 60 },
initText: { default: "\u83B7\u53D6\u9A8C\u8BC1\u7801" },
runText: { default: "{%s}s \u540E\u91CD\u65B0\u53D1\u9001" },
loadingText: { default: "\u6B63\u5728\u53D1\u9001" },
resetText: { default: "\u91CD\u65B0\u83B7\u53D6" }
},
emits: ["update:modelValue", "send"],
setup(__props, { emit: emits }) {
const props = __props;
const text = ref(props.initText);
const isDisabled = ref(false);
const isLoading = ref(false);
let timeID;
onBeforeUnmount(() => {
stop();
});
function stop() {
clearInterval(timeID);
text.value = props.resetText;
isLoading.value = false;
isDisabled.value = false;
emits("update:modelValue", false);
}
function getText(second) {
return props.runText.replace(/\{([^{]*?)%s(.*?)\}/g, String(second));
}
function run() {
isLoading.value = false;
let number = props.duration;
text.value = getText(number);
clearInterval(timeID);
timeID = setInterval(() => {
number--;
text.value = getText(number);
if (number <= 0) {
stop();
}
}, 1e3);
}
function onClick() {
if (isDisabled.value)
return;
if (isLoading.value)
return;
emits("send", () => {
isDisabled.value = true;
isLoading.value = true;
text.value = props.loadingText;
}, (isDone = true) => {
if (isDone) {
run();
} else {
stop();
}
});
}
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
class: "ps-send",
onClick,
disabled: isDisabled.value,
loading: isLoading.value,
type: "button",
size: "small"
}, toDisplayString(text.value), 9, _hoisted_1);
};
}
});
_sfc_main$1.name = "ps-captcha";
var __glob_2_1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
PsCaptcha: _sfc_main$1,
"default": _sfc_main$1
}, Symbol.toStringTag, { value: "Module" }));
var index_vue_vue_type_style_index_0_lang = "";
const _sfc_main = /* @__PURE__ */ defineComponent({
name: "index",
props: {
color: null color: null
}, },
setup(__props) { setup(__props) {
@ -42,20 +122,19 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
}; };
} }
}); });
_sfc_main$1.name = "ps-fuck"; _sfc_main.name = "ps-fuck";
var index_vue_vue_type_style_index_0_lang = ""; var __glob_2_2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
const _sfc_main = {}; __proto__: null,
function _sfc_render(_ctx, _cache) { PsFuck: _sfc_main,
return openBlock(), createElementBlock("div", null, " send "); "default": _sfc_main
} }, Symbol.toStringTag, { value: "Module" }));
var PsSend = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
PsSend.name = "ps-send";
var componets = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ var componets = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null, __proto__: null,
PsButton, PsButton,
PsFuck: _sfc_main$1, PsCaptcha: _sfc_main$1,
PsSend PsFuck: _sfc_main
}, Symbol.toStringTag, { value: "Module" })); }, Symbol.toStringTag, { value: "Module" }));
console.log({ "./button/index.ts": __glob_2_0, "./captcha/index.ts": __glob_2_1, "./fuck/index.ts": __glob_2_2 });
function install(app) { function install(app) {
for (const key in componets) { for (const key in componets) {
const component = componets[key]; const component = componets[key];
@ -65,4 +144,4 @@ function install(app) {
var index = { var index = {
install install
}; };
export { PsButton, _sfc_main$1 as PsFuck, PsSend, index as default, install }; export { PsButton, _sfc_main$1 as PsCaptcha, _sfc_main as PsFuck, index as default, install };

2
packages/princess-ui/lib/index.umd.js

@ -1 +1 @@
(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.ps={},n.Vue))})(this,function(n,e){"use strict";var g="",i=(t,o)=>{const r=t.__vccOpts||t;for(const[_,u]of o)r[_]=u;return r};const p=e.defineComponent({props:{color:{type:String,required:!0},aaa:{type:String,required:!0}}});function f(t,o,r,_,u,x){return e.openBlock(),e.createElementBlock("div",null," sada"+e.toDisplayString(t.color),1)}var c=i(p,[["render",f]]);c.name="ps-button";var k="";const s=e.defineComponent({name:"index",props:{color:null},setup(t){return(o,r)=>(e.openBlock(),e.createElementBlock("div",null,[e.createTextVNode(" sada"+e.toDisplayString(t.color)+" ",1),e.createVNode(e.unref(c),{color:"red",aaa:"red"})]))}});s.name="ps-fuck";var S="";const m={};function y(t,o){return e.openBlock(),e.createElementBlock("div",null," send ")}var a=i(m,[["render",y]]);a.name="ps-send";var d=Object.freeze(Object.defineProperty({__proto__:null,PsButton:c,PsFuck:s,PsSend:a},Symbol.toStringTag,{value:"Module"}));function l(t){for(const o in d){const r=d[o];t.component(r.name||"ps-"+o,r)}}var v={install:l};n.PsButton=c,n.PsFuck=s,n.PsSend=a,n.default=v,n.install=l,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); (function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n.ps={},n.Vue))})(this,function(n,e){"use strict";var b=(o,a)=>{const t=o.__vccOpts||o;for(const[r,u]of a)t[r]=u;return t};const x=e.defineComponent({props:{text:String}}),v={class:"ps-button"};function y(o,a,t,r,u,i){return e.openBlock(),e.createElementBlock("div",v,[e.renderSlot(o.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(o.text),1)])])}var s=b(x,[["render",y]]);s.name="ps-button";var T=Object.freeze(Object.defineProperty({__proto__:null,PsButton:s,default:s},Symbol.toStringTag,{value:"Module"}));const B=["disabled","loading"],c=e.defineComponent({name:"index",props:{duration:{default:60},initText:{default:"\u83B7\u53D6\u9A8C\u8BC1\u7801"},runText:{default:"{%s}s \u540E\u91CD\u65B0\u53D1\u9001"},loadingText:{default:"\u6B63\u5728\u53D1\u9001"},resetText:{default:"\u91CD\u65B0\u83B7\u53D6"}},emits:["update:modelValue","send"],setup(o,{emit:a}){const t=o,r=e.ref(t.initText),u=e.ref(!1),i=e.ref(!1);let f;e.onBeforeUnmount(()=>{p()});function p(){clearInterval(f),r.value=t.resetText,i.value=!1,u.value=!1,a("update:modelValue",!1)}function g(l){return t.runText.replace(/\{([^{]*?)%s(.*?)\}/g,String(l))}function h(){i.value=!1;let l=t.duration;r.value=g(l),clearInterval(f),f=setInterval(()=>{l--,r.value=g(l),l<=0&&p()},1e3)}function C(){u.value||i.value||a("send",()=>{u.value=!0,i.value=!0,r.value=t.loadingText},(l=!0)=>{l?h():p()})}return(l,j)=>(e.openBlock(),e.createElementBlock("div",{class:"ps-send",onClick:C,disabled:u.value,loading:i.value,type:"button",size:"small"},e.toDisplayString(r.value),9,B))}});c.name="ps-captcha";var S=Object.freeze(Object.defineProperty({__proto__:null,PsCaptcha:c,default:c},Symbol.toStringTag,{value:"Module"})),D="";const d=e.defineComponent({name:"index",props:{color:null},setup(o){return(a,t)=>(e.openBlock(),e.createElementBlock("div",null,[e.createTextVNode(" sada"+e.toDisplayString(o.color)+" ",1),e.createVNode(e.unref(s),{color:"red",aaa:"red"})]))}});d.name="ps-fuck";var P=Object.freeze(Object.defineProperty({__proto__:null,PsFuck:d,default:d},Symbol.toStringTag,{value:"Module"})),_=Object.freeze(Object.defineProperty({__proto__:null,PsButton:s,PsCaptcha:c,PsFuck:d},Symbol.toStringTag,{value:"Module"}));console.log({"./button/index.ts":T,"./captcha/index.ts":S,"./fuck/index.ts":P});function m(o){for(const a in _){const t=_[a];o.component(t.name||"ps-"+a,t)}}var k={install:m};n.PsButton=s,n.PsCaptcha=c,n.PsFuck=d,n.default=k,n.install=m,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

16
packages/princess-ui/lib/send/index.js

@ -1,16 +0,0 @@
import { openBlock, createElementBlock } from "vue";
var index_vue_vue_type_style_index_0_lang = "";
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _sfc_main = {};
function _sfc_render(_ctx, _cache) {
return openBlock(), createElementBlock("div", null, " send ");
}
var PsSend = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
PsSend.name = "ps-send";
export { PsSend, PsSend as default };

1
packages/princess-ui/lib/send/index.umd.js

@ -1 +0,0 @@
(function(e,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],n):(e=typeof globalThis!="undefined"?globalThis:e||self,n(e.psSend={},e.Vue))})(this,function(e,n){"use strict";var f="",u=(d,o)=>{const s=d.__vccOpts||d;for(const[_,c]of o)s[_]=c;return s};const i={};function r(d,o){return n.openBlock(),n.createElementBlock("div",null," send ")}var t=u(i,[["render",r]]);t.name="ps-send",e.PsSend=t,e.default=t,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

1
packages/princess-ui/lib/send/style.css

@ -1 +0,0 @@
div{color:gold}

2
packages/princess-ui/lib/style.css

@ -1 +1 @@
div{background-color:#639}div{color:red}div{color:green}div{color:gold} div{color:green}

4
packages/theme-chalk/src/captcha.scss

@ -0,0 +1,4 @@
.ps-send{
color: blue;
cursor: pointer;
}

1
packages/theme-chalk/src/index.scss

@ -1,4 +1,5 @@
@import "./button.scss"; @import "./button.scss";
@import "./send.scss";
div{ div{
color: rosybrown; color: rosybrown;
} }
Loading…
Cancel
Save